Search Unity

expression left of ."worldRefl" is not a struct or array at line 41 (on d3d9)

Discussion in 'Shaders' started by ksam2, Jan 3, 2015.

  1. ksam2

    ksam2

    Joined:
    Apr 28, 2012
    Posts:
    1,079
    Hi again, thread's title is the error I get from the below code

    Code (CSharp):
    1.     Shader "My_Shaders/FirstShader" {
    2.        Properties {
    3.          _Color ("Main Color", Color) = (1,1,1,0.5) // Tint
    4.          _MainTex ("Texture", 2D) = "white" {}
    5.          _BumpMap ("Bumpmap", 2D) = "bump" {}
    6.          _RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
    7.          _RimPower ("Rim Power", Range(0.5,8.0)) = 3.0
    8.          _Detail ("Detail", 2D) = "gray" {}
    9.          _Cube ("Cubemap", CUBE) = "" {}
    10.        }
    11.    
    12.        Subshader {
    13.          Tags { "RenderType" = "Opaque" }
    14.    
    15.          CGPROGRAM
    16.          #pragma surface surf Lambert
    17.    
    18.          struct Input {
    19.            float4 color : COLOR; // Vertex Color
    20.            float2 uv_MainTex;
    21.            float2 uv_BumpMap;
    22.             float3 viewDir;
    23.             float2 uv_Detail;
    24.              INTERNAL_DATA
    25.          };
    26.    
    27.          float4 _Color; // Tint
    28.          sampler2D _MainTex;
    29.          sampler2D _BumpMap;
    30.          float4 _RimColor;
    31.       float _RimPower;
    32.       sampler2D _Detail;
    33.       samplerCUBE _Cube;
    34.    
    35.          void surf (Input IN, inout SurfaceOutput o) {
    36.            o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rgb * IN.color.rgb * _Color; // Texture * Vertex Color * Tint
    37.            o.Normal = UnpackNormal (tex2D (_BumpMap, IN.uv_BumpMap));
    38.            half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
    39.            o.Emission = _RimColor.rgb * pow (rim, _RimPower);
    40.             o.Albedo *= tex2D (_Detail, IN.uv_Detail).rgb * 2;
    41.             o.Emission = texCUBE (_Cube, WorldReflectionVector (IN, o.Normal)).rgb;
    42.          }
    43.          ENDCG
    44.    
    45.        }
    46.        Fallback "Diffuse"
    47.     }
    48.  
    I get an error that says
    Shader error in 'My_Shaders/FirstShader': expression left of ."worldRefl" is not a struct or array at line 41 (on d3d9)
     
    Last edited: Jan 3, 2015
  2. warrior1988

    warrior1988

    Joined:
    Mar 4, 2015
    Posts:
    1
    how did u resolve this ? can you please give me the soluion? i am currently stuck in same problem
     
  3. blizzy

    blizzy

    Joined:
    Apr 27, 2014
    Posts:
    775
    So, we don't even know what the problem is. Sweet.
     
  4. Aurore

    Aurore

    Director of Real-Time Learning

    Joined:
    Aug 1, 2012
    Posts:
    3,106
    I've reverted the post, please leave your problems and post your solutions to help other users!
     
  5. mholub

    mholub

    Joined:
    Oct 3, 2012
    Posts:
    123
    So the solution is to add float3 worldRefl into Input structure

    Code (csharp):
    1.  
    2. struct Input {
    3.            float4 color : COLOR; // Vertex Color
    4.            float2 uv_MainTex;
    5.            float2 uv_BumpMap;
    6.            float3 viewDir;
    7.            float2 uv_Detail;
    8.            float3 worldRefl;
    9.            INTERNAL_DATA
    10. };
    11.  
    It is described here: http://docs.unity3d.com/Manual/SL-SurfaceShaders.html
     
  6. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    ^^^^^^^^^^^^
    I was going to say that too, I can clearly see that the variable's missing!