unity3d - Cant understand CG semantic -


i beginner in cg , simple shader. can't understand means code

float4 vert(float4 vertexpos : position) : sv_position {   ... } 

rather moment: announced parameter type float4.question: this

": position" , ": sv_position"

or give reference this

thanks in advance!

just thought following might helpful understand.

source: http://http.developer.nvidia.com/cgtutorial/cg_tutorial_chapter02.html

 struct c2e1v_output {    float4 position : position;    float4 color    : color;  };  c2e1v_output c2e1v_green(float2 position : position)  {    c2e1v_output out;    out.position = float4(position, 0, 1);    out.color    = float4(0, 1, 0, 1);  // rgba green    return out;  } 

2.1.6 semantics

a colon , special word, known semantic, follow position , color members of c2e1v_output structure. semantics are, in sense, glue binds cg program rest of graphics pipeline. semantics position , color indicate hardware resource respective member feeds when cg program returns output structure. indicate how variables preceding them connect rest of graphics pipeline.

the position semantic (in case, in output structure used cg vertex program) clip-space position transformed vertex. later graphics pipeline stages use output vector associated semantic post-transform, clip-space position of vertex primitive assembly, clipping, , rasterization. introduced clip space later in chapter, , more formally in chapter 4. now, can think of 2d vertex's clip-space position position within window.

the color semantic in context direct3d calls "diffuse vertex color" , opengl calls "primary vertex color." color interpolation triangle or other geometric primitive during rasterization depends on primitive's per-vertex colors.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -