HLSL中的 Semantics

HLSL中的 Semantics(语义)

在定义HLSL不管是函数中输入的参数变量或者返回的变量的时候经常要用到诸如xxx:POSITION的形式,这里是HLSL中变量与众不同的一个地方。:后面的叫做叫做语义,它用来描述变量的一些信息,说到本质上语义是规定着色器变量与硬件之间的关系,例如POSITION指定这个变量是被用在位置相关的寄存器。

顶点着色器的语义

语义都有输入跟输出的部分,关于顶点的输入和输出的见下:

Input

Description

Type

BINORMAL[n]

Binormal

float4

BLENDINDICES[n]

Blend indices

uint

BLENDWEIGHT[n]

Blend weights

float

COLOR[n]

Diffuse and specular color

float4

NORMAL[n]

Normal vector

float4

POSITION[n]

Vertex position in object space.

float4

POSITIONT

Transformed vertex position.

float4

PSIZE[n]

Point size

float

TANGENT[n]

Tangent

float4

TEXCOORD[n]

Texture coordinates

float4


 

OutputDescriptionType
COLOR[n]Diffuse or specular colorfloat4

FOG

Vertex fogfloat
POSITION[n]Position of a vertex in homogenous space. Compute position in screen-space by dividing (x,y,z) by w. Every vertex shader must write out a parameter with this semantic.float4
PSIZEPoint sizefloat
TESSFACTOR[n]Tessellation factorfloat
TEXCOORD[n]Texture coordinatesfloat4

从上可以看出变量后面的语义不是随便乱加的,首先它指明了变量的用处,其次针对输入和输出都有专门限制的语义,我们不能把一个用作输入的语义来用作输出。

n是寄存器的索引值,最大值依赖于硬件的支持。如POSITION1.

像素着色器的语义

 

Input

Description

Type

COLOR[n]

Diffuse or specular color.

float4

TEXCOORD[n]

Texture coordinates

float4

VFACE

Floating-point scalar that indicates a back-facing primitive. A negative value faces backwards, while a positive value faces the camera.

float

VPOS

The pixel location (x,y) in screen space. 

在屏幕中的像素位置

float2

Output

Description

Type

COLOR[n]

Output color

float4

DEPTH[n]

Output depth

float

 

 

 

 


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值