Search Unity

Custom Rim Glow issues

Discussion in 'Shaders' started by linguini21, Dec 3, 2015.

  1. linguini21

    linguini21

    Joined:
    Dec 3, 2015
    Posts:
    2
    I followed:
    tutorial. The end result was a pink ball with a shader error.

    The error is: Shader error in 'Custom/ItemGlow': expression left of ."viewDir" is not a struct or array at line 44 (on d3d9)

    The code im using is:

    Shader "Custom/ItemGlow" {
    Properties {
    _ColorTint("Color Tint", Color) = (1,1,1,1)
    _MainTex ("Albedo (RGB)", 2D) = "white" {}
    _BumpMap("Normal Map", 2D) = "bump" {}
    _RimColor("Rim Color", Color) = (1,1,1,1)
    _RimPower("Rim Power", Range(1.0, 6.0)) = 3.0
    }
    SubShader {
    Tags { "RenderType"="Opaque" }
    //LOD 200

    CGPROGRAM
    #pragma surface surf Standard fullforwardshadows

    // Use shader model 3.0 target, to get nicer looking lighting
    #pragma target 3.0

    //sampler2D _MainTex;

    struct Input {
    float4 color : Color;
    float2 uv_MainTex;
    float2 uv_BumpMap;
    float3 uv_viewDir;

    };

    float4 _ColorTint;
    sampler2D _MainTex;
    sampler2D _BumpMap;
    float4 _RimColor;
    float _RimPower;

    half _Glossiness;
    half _Metallic;
    fixed4 _Color;

    void surf (Input IN, inout SurfaceOutputStandard o) {
    IN.color = _ColorTint;
    o.Albedo = tex2D (_MainTex, IN.uv_MainTex).rbg * IN.color;
    o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));

    half rim = (1.0 - saturate(dot(normalize(IN.viewDir), o.Normal)) );
    o.Emission = _RimColor.rgb * pow(rim, _RimPower);
    }
    ENDCG
    }
    FallBack "Diffuse"
    }

    Is it just an outdated tutorial??? If so what do I need to change to make it work. Thanks in advanced.
     
  2. Phantomx

    Phantomx

    Joined:
    Oct 30, 2012
    Posts:
    202
    in your input struct you have float3 uv_viewDir; but it should be float3 viewDir;
    viewDir is a built in value provided by unity and it has to be written that way.
     
  3. linguini21

    linguini21

    Joined:
    Dec 3, 2015
    Posts:
    2
    That was it. Thank you very much. :D