- Home /
Question by
carlmyerflor · Sep 29, 2014 at 09:43 AM ·
shadershader programmingambient lightambient
How to make a custom shader affected by Ambient Light
I made my own shader since I wanted to us 2 textures in which I'll lerp between them. However, the ambient light does not affect them. May I know what I'm missing here?
Shader "Custom/CrossMaterial" {
Properties
{
_Blend ( "Blend", Range ( 0, 1 ) ) = 0.0
_Color ( "Main Color", Color ) = ( 1, 1, 1, 1 )
_MainTex ( "Texture 1", 2D ) = "white" {}
_Texture2 ( "Texture 2", 2D ) = ""
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 300
Pass
{
SetTexture[_MainTex]
SetTexture[_Texture2]
{
ConstantColor ( 0, 0, 0, [_Blend] )
Combine texture Lerp( constant ) previous
}
}
CGPROGRAM
#pragma surface surf Lambert
sampler2D _MainTex;
sampler2D _Texture2;
fixed4 _Color;
float _Blend;
struct Input
{
float2 uv_MainTex;
float2 uv_Texture2;
};
void surf ( Input IN, inout SurfaceOutput o )
{
fixed4 t1 = tex2D( _MainTex, IN.uv_MainTex ) * _Color;
fixed4 t2 = tex2D ( _Texture2, IN.uv_Texture2 ) * _Color;
o.Albedo = lerp( t1, t2, _Blend );
}
ENDCG
}
FallBack "Diffuse"
}
Comment
Hey, I don't know if you got this sorted but I was having similar issues. In my case I had a mish-mash of some mesh renderers trying to use light probes and some not. Those set to use light probes didn't pick-up ambient light correctly. I think my light probes were also bust due to additive scene loading.