How to add 2nd Texture only on shadow side of an object? (Earth w/ city lights),
Members - Reputation: 105
Posted 04 May 2012 - 07:37 AM
Thank you in advance!
p.s. I'm using DirectX9
Crossbones+ - Reputation: 2918
Posted 04 May 2012 - 07:51 AM
The easiest way is to use a vertex/pixel shader and calculate the blending for the second texture there.
Ie. for each vertex calculate the blending factor by surface normal and sun direction. You may reverse your sun direction so that vertices on the dark side get positive values and on the light side negative values. Then simply saturate the value and use that as a blending modifier for the second texture which you may then add to the base color.
float4 Color = basetexture * saturate(dot(normal, LightDirection)); float4 DarkSideColor = darksidetexture * saturate(dot(normal, -LightDirection)); FinalColor = Color + DarkSideColor;
You may also do this with a fixel function pipeline. Just blend additively and invert your light direction and redraw the mesh with dark side texture.