vert:函数返回值缺少语义

时间:2015-06-04 10:16:59

标签: unity3d shader

我只是想从unity site

运行此代码
Shader  "UnityExample/Vertex and Fragment/3-Behind Bars" {
    SubShader{
            Pass{
            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag

            #include "UnityCG.cginc"

            struct vertOut{
                float4 pos: SV_POSITION;
                float4 scrPos;
            };

            vertOut vert(appdata_base v){
                vertOut o;
                o.pos = mul(UNITY_MATRIX_MVP, v.vertex);
                o.scrPos = ComputeScreenPos(o.pos);
                return o;
            }

            fixed4 frag(vertOut i) : SV_Target{
                float2 wcoord  = (i.scrPos.xy/i.scrPos.w);
                fixed4 color;

                if(fmod(20.0 * wcoord.x,2.0)<1.0){
                    color = fixed4(wcoord.xy,0.0,1.0);
                } else{
                    color = fixed4(0.3,0.3,0.3,1.0);
                }
                return color;
            }
            ENDCG
        }
    }
}

此代码在此行显示错误

vertOut vert(appdata_base v)

vert:函数返回值缺少语义

我正在使用团结4.6

1 个答案:

答案 0 :(得分:3)

scrPos 缺少语义。

float4 scrPos : TEXCOORD0;