What is the difference between Semantic POSITION and SV_POSITION both
All I hava a vertex and fragment shader:
struct a2v
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float4 texcoord : TEXCOORD0;
};
struct v2f
{
float4 sv_pos : SV_POSITION;
fixed3 color : COLOR0;
};
/*Unity Report Error over here!!*/
v2f vert(a2v v) : **SV_POSITION**
{
v2f o;
o.sv_pos = mul(UNITY_MATRIX_MVP, v.vertex);
o.color = v.normal * 0.5 + fixed3(0.5, 0.5, 0.5);
return o;
}
fixed4 frag(v2f i) : SV_Target
{
fixed3 c = i.color;
c *= _Color.rgb;
return fixed4(c, 1.0);
}
if I Complie with DX11 Unity will report the error: Shader error in 'Custom/Shader2': invalid output semantic 'SV_POSITION': Legal indices are in [0,0] at line 41 (on d3d11)
and the shader doesn't work well!
but when i change the graphic API to DX9, The Shader can work immediately
I can't explain the cause of this I do know is SV_POSITION can use after DX10
I want to know how to resolve the problem and the difference between SV_POSITION and POSITION
Very greatful!!!
You shouldn't need to define the vertex function with a semantic, just remove the ": SV_POSITION" from that line.
Your answer
Follow this Question
Related Questions
Getting Color Generated from Shader to Script to Shader 0 Answers
_WorldSpacePosLight0 suddenly changes when change camera position or direction 0 Answers
_Time in Image Effects 0 Answers
How can I add Alpha to texture animation shader...? Actually i am noob.. Here is the shader . 0 Answers
Inverse Stencil Shader 0 Answers