What does this button in the material preview window do? (lighting and shader troubles)
This may be an easy one, but I've been stuck on it all night. What does this button on the material preview do? Bonus if you can help solve my deeper problems below.
You see, I've made a shader that takes dark things and makes them one color while taking bright things and making them another color. But the colors aren't showing up quite right. In that picture above, they're wrong and I know it has something to do with lighting. But when I click that button:
I get the right thing! The guy on the right is what I want it to look like all the time. What is changing and why would it do that?
Here's my shader:
Shader ".MyBoys/TexShadowShader"
{
Properties {
_LightColor ("Light Color", Color) = (1,1,1,1)
_DarkColor ("Dark Color", Color) = (0,0,0,1)
_MainTex ("Albedo (RGB)", 2D) = "white" {}
_ShadowThreshold ("Threshold", Range(0,1)) = 0.5
}
SubShader {
Tags { "RenderType"="Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Ramp fullforwardshadows noambient
half4 _LightColor, _DarkColor;
float _ShadowThreshold;
half4 LightingRamp (SurfaceOutput s, half3 lightDir, half atten) {
half NdotL = dot (s.Normal, lightDir);
half bn = s.Albedo * abs(atten) * NdotL * length(_LightColor0.rgb);
if(bn <= _ShadowThreshold)
return _DarkColor;
else
return _LightColor;
}
struct Input {
float2 uv_MainTex;
} ;
sampler2D _MainTex;
void surf (Input IN, inout SurfaceOutput o) {
o.Albedo = tex2D(_MainTex, IN.uv_MainTex).rgb;
}
ENDCG
}
FallBack "Diffuse"
}
Thanks!
screen-shot-2016-09-21-at-121621-am.png
(51.0 kB)
screen-shot-2016-09-21-at-121936-am.png
(85.3 kB)
Comment