1

I am just trying to running this code from 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
        }
    }
}

This code is showing me an error on this line

vertOut vert(appdata_base v)

vert: function return value missing semantics

I am using unity 4.6

1 Answer 1

3

Semantics is missing for scrPos.

float4 scrPos : TEXCOORD0;
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.