Search Unity

Parse Error in simple MultiPass shader

Discussion in 'Shaders' started by kojima100, Feb 6, 2016.

  1. kojima100

    kojima100

    Joined:
    Feb 6, 2016
    Posts:
    1
    Hello in the following shader program I have written Unity complains about a syntax error on line 82. I however can see no such error. Could any of you more experienced folk point it out to me. This is in Unity 4.6.4f.
    Thanks in advance.

    Code (CSharp):
    1. Shader "Custom/Player_Shader"
    2. {
    3.     Properties
    4.     {
    5.         _AlbedoTex ("Albedo (RGBA)", 2D) = "white" {}
    6.         _NormalTex ("Normal (Bump)", 2D) = "bump" {}
    7.         _EmissionTex ("Emission (RGBA)", 2D) = "black" {}
    8.         _MetallicTex ("Metallic Smoothness (RGBA)", 2D) = "black" {}
    9.         _ZFailColor ("ZFail Color (RGBA)", Color) = (1, 1, 1, 0.7)
    10.     }
    11.     Category
    12.     {
    13.         Cull Back
    14.         SubShader
    15.         {
    16.             Tags { "RenderType"="Geometry" }
    17.             LOD 200
    18.  
    19.             Pass
    20.             {
    21.                 Stencil
    22.                 {
    23.                     ref 2
    24.                     comp notequal
    25.                     pass replace
    26.                 }
    27.  
    28.                 ZTest Greater
    29.                 ZWrite Off
    30.                 Blend SrcAlpha OneMinusSrcAlpha
    31.  
    32.                 CGPROGRAM
    33.                 #pragma vertex vert
    34.                 #pragma fragment frag
    35.  
    36.                 #include "UnityCG.cginc"
    37.  
    38.                 uniform half4 _ZFailColor;
    39.  
    40.                 struct VertexIn
    41.                 {
    42.                     float4 Position : POSITION;
    43.                 };
    44.  
    45.                 struct VertexOut
    46.                 {
    47.                     float4 TransformedPosition : SV_POSITION;
    48.                 };
    49.        
    50.                 VertexOut vert(VertexIn input)
    51.                 {
    52.                     VertexOut output;
    53.                     output.TransformedPosition = mul(UNITY_MATRIX_MVP, input.Position);
    54.                     return output;
    55.                 }
    56.  
    57.                 half4 frag(VertexOut output) : COLOR
    58.                 {
    59.                     return _ZFailColor;
    60.                 }
    61.                 ENDCG
    62.             }
    63.  
    64.             Pass
    65.             {
    66.                 Stencil
    67.                 {
    68.                     ref 2
    69.                     comp always
    70.                     pass replace
    71.                 }
    72.  
    73.                 ZTest Less
    74.                 ZWrite On
    75.  
    76.                 CGPROGRAM
    77.                 #pragma surface surf Lambert
    78.  
    79.                 sampler2D _AlbedoTex;
    80.                 sampler2D _NormalTex;
    81.                 sampler2D _EmissionTex;
    82.                 sampler2D _MetallicTex;
    83.  
    84.                 struct Input
    85.                 {
    86.                     float2 uv_AlbedoTex;
    87.                     float2 uv_NormalTex;
    88.                     float2 uv_EmissionTex;
    89.                     float2 uv_MetallicTex;
    90.                 };
    91.  
    92.                 void surf (Input IN, inout SurfaceOutput o)
    93.                 {
    94.                     half4 c = tex2D(_AlbedoTex, IN.uv_AlbedoTex);
    95.                     o.Albedo = c.rgb;
    96.                     o.Alpha = c.a;
    97.  
    98.                     o.Normal = UnpackNormal(tex2D(_NormalTex, IN.uv_NormalTex));
    99.  
    100.                     o.Emission = tex2D(_EmissionTex, IN.uv_EmissionTex).rgb;
    101.  
    102.                     half4 SpecColor = tex2D(_MetallicTex, IN.uv_MetallicTex);
    103.                
    104.                     o.Specular = SpecColor.a;
    105.                     o.Gloss = SpecColor.r;
    106.                 }
    107.                 ENDCG
    108.             }
    109.         }
    110.     }
    111. }
    112.  
     
  2. thefranke

    thefranke

    Unity Technologies

    Joined:
    Jun 20, 2015
    Posts:
    153