[SOLVED] Trying to get my _Reflectiveness variable to work

Hi, I’ve pretty much zero knowledge on shaders, but I managed to cobble together a couple I found online.

The shader is working well until after I tried changing this:

o.Emission = texCUBE (_Cube, IN.worldRefl).rgb * 0.5;

to this:

o.Emission = texCUBE (_Cube, IN.worldRefl).rgb * _Reflectiveness;

The _Reflectiveness is always zero regardless of the amount I set on the material itself. What did I do wrong?

Full shader code below:

Shader "Custom/Mobile/Vertex Color Unlit Water" {
Properties {
    _SColor ("Color", Color) = (1,1,1,1)
    _MainTex ("Texture", 2D) = "white" {}
    _Cube ("Cubemap", Cube) = "" {}
    _Reflectiveness ("Reflection Amount", Range(0,1.0)) = 0.5
}

Category {
    Tags { "Queue"="Geometry" }
    Lighting Off
    BindChannels {
        Bind "Color", color
        Bind "Vertex", vertex
        Bind "TexCoord", texcoord
    }
  
    // ---- Dual texture cards
    SubShader {
        Tags { "RenderType" = "Opaque" }
        CGPROGRAM
        #pragma surface surf Lambert
        struct Input {
            float3 worldRefl;
        };
        samplerCUBE _Cube;
        float3 _Reflectiveness;
        void surf (Input IN, inout SurfaceOutput o) {
        o.Emission = texCUBE (_Cube, IN.worldRefl).rgb * _Reflectiveness;
        }
        ENDCG
      
        Pass {
            Blend One One
            SetTexture [_MainTex] {
                matrix [_OffsetTex]
                combine texture * primary
            }
            SetTexture [_MainTex] {
                constantColor [_SColor]
                combine previous lerp (previous) constant DOUBLE
            }
        }
    }
  
    // ---- Single texture cards (does not do vertex colors)
    SubShader {
        Pass {
            SetTexture [_MainTex] {
            matrix [_OffsetTex]
                constantColor [_SColor]
                combine texture lerp(texture) constant DOUBLE
            }
        }
    }
}
}

Thanks!

Maybe because you’re trying to access it as a float3, while it is a float?

1 Like

Not sure why I didn’t spot that! Thanks, it’s working fine now