blending two textures via lambert(lighting)?

Hi, sorry if that has been asked before…

i’m trying to create a simple shader which blends 2 textures, controlled by lights (like a lerp (tex1, tex2, lambert)… is something like that possible? would somebody please point me in the right direction?

thanks!

–stephan

Something like…

fixed4 tex1 = tex2d(_Texture1, i.uv);
fixed4 tex2 = tex2d(_Texture2, i.uv);

// Using half Lambert here because otherwise it runs from the -1 to 1 range and the blend will stop at the terminator and become tex2 on the entire hemisphere pointing away from the light.
// This compresses it to the 0 to 1 range so you get a complete blend from the brightest to the darkest points.
float halfLambert = dot(i.lightDir, i.normal) * 0.5 + 0.5;

fixed4 c = lerp(tex2, tex1, halfLambert);
return c;

thanks a lot! sorry for my late reply, but i’m still struggling to get this working (even as simple as it is :wink: ) - there are obviously some parts of realtime shaders i simply don’t grasp (yet)… someday hopefully :wink:

The code is a fragment shader, it goes in frag. Make sure i is passed in (change input). Shader requires 2 textues with those names.