Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

Weird Shader Syntax error

Discussion in 'Shaders' started by MarkBenitez, Mar 1, 2014.

  1. MarkBenitez

    MarkBenitez

    Joined:
    Oct 5, 2013
    Posts:
    44
    I dont know why i am getting errors since im pretty sure this is the correct syntax, please comment if you can give any help
    Here is the error:
    Code (csharp):
    1. Shader "DiffuseSimple"{
    2.     Properties{
    3.         _ColorTint("ColorTint", Color) = (1,1,1,1)
    4.     }
    5.     SubShader{
    6.         Tags{"RenderType" = "Opaque"}
    7.         CGPROGRAM
    8.             #progma surface surf Lambert
    9.             float4 _ColorTint;
    10.             struct Input{
    11.                 float4 color : COLOR;
    12.             }
    13.             void surf(Input IN, inout SurfaceOutput i){
    14.                 IN.color=_ColorTint;
    15.                 i.Albedo=IN.color;
    16.             }
    17.         ENDCG
    18.     }
    19. }
     

    Attached Files:

    Last edited: Mar 1, 2014
  2. cod

    cod

    Joined:
    Nov 26, 2011
    Posts:
    267
    line 8 "progma"? maybe "pragma" :D

    However what are u trying to do here? why do u need the IN.color variable while u could directly pass the _ColorTint to the Albedo output?
     
  3. MarkBenitez

    MarkBenitez

    Joined:
    Oct 5, 2013
    Posts:
    44
    When i change it i get this:
    http://gyazo.com/8785005377efb3e1e91e0880f6b0fd00.png

    This is how i currentlyy have it:
    Code (csharp):
    1. Shader "DiffuseSimple"{
    2.     Properties{
    3.         _ColorTint("ColorTint", Color) = (1,1,1,1)
    4.     }
    5.     SubShader{
    6.         Tags{"RenderType" = "Opaque"}
    7.                 Pass {
    8.         CGPROGRAM
    9.             #pragma surface surf Lambert
    10.             float4 _ColorTint;
    11.             struct Input{
    12.                 float4 color : COLOR;
    13.             }
    14.             void surf(Input IN, inout SurfaceOutput i){
    15.                 IN.color=_ColorTint;
    16.                 i.Albedo=IN.color;
    17.             }
    18.         ENDCG
    19.                 }
    20.     }
    21. }
     
  4. cod

    cod

    Joined:
    Nov 26, 2011
    Posts:
    267
    Remove "Pass {" at line 7 and "}" at line 19

    this should work
     
  5. MarkBenitez

    MarkBenitez

    Joined:
    Oct 5, 2013
    Posts:
    44
    yea this works:
    Code (csharp):
    1. Shader "DiffuseSimple"{
    2.     Properties{
    3.         _ColorTint("ColorTint", Color) = (1,1,1,1)
    4.     }
    5.     SubShader{
    6.         Tags{"RenderType" = "Opaque"}
    7.         CGPROGRAM
    8.             #pragma surface surf Lambert
    9.             float4 _ColorTint;
    10.             struct Input{
    11.                 float4 color : COLOR;
    12.             };
    13.             void surf(Input IN, inout SurfaceOutput i) {
    14.                 IN.color=_ColorTint;
    15.                 i.Albedo= IN.color;
    16.             }
    17.         ENDCG
    18.     }
    19. }
    thanks
     
  6. kerryenfinger

    kerryenfinger

    Joined:
    Jan 22, 2013
    Posts:
    14
    You needed a semicolon after the struct Input closing bracket.