1
\$\begingroup\$

I'm trying to make a Surface Shader that uses multiple passes, with two different blending functions for each one, but I get the following error I don't understand:

Parse error: syntax error, unexpected TOK_PASS, expecting TOK_SETTEXTURE or '}' at line 28

SubShader
{
    ZWrite Off
    Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "PreviewType"="Plane" }
    Pass
    {
        //transparency
        Blend SrcAlpha One
        CGPROGRAM
            #pragma surface surf Lambert 
            #pragma target 3.0
            struct Input
            {
                //
            };
            sampler2D //;
            void surf (Input IN, inout SurfaceOutput o)
            {
                //
            }
        }
     ENDCG
    }
    Pass
    {
         //alphabend
        Blend SrcAlpha OneMinusSrcAlpha
        CGPROGRAM
        #pragma surface surf Lambert
        #pragma target 3.0

         sampler2D//;
         fixed4 //;

         struct Input 
         {
          //;
         };
         void surf(Input IN, inout SurfaceOutput o)
         {
         //
         }
        ENDCG
    }
}
\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

Surface shaders wrapped in CGPROGRAM does not need to be surrounded by a Pass block. Simply separate the two passes between CGPROGRAM tags.

i.e.,

ZWrite Off
Tags { "QUEUE"="Transparent" "IGNOREPROJECTOR"="true" "RenderType"="Transparent" "PreviewType"="Plane" }
    //transparency
    Blend SrcAlpha One
    CGPROGRAM
    ...
    void surf (Input IN, inout SurfaceOutput o)
    {
        // Pass 1
    }
    ENDCG

    CGPROGRAM
    ...
    void surf(Input IN, inout SurfaceOutput o)
    {
        // Pass 2
    }
    ENDCG
...
\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .