Jump to content

  • Log In with Google      Sign In   
  • Create Account

How to add 2nd Texture only on shadow side of an object? (Earth w/ city lights)


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 andyS91   Members   -  Reputation: 105

Like
0Likes
Like

Posted 04 May 2012 - 07:37 AM

Is there a way to add a texture to an object so that you can only see it on the shadow side of the object (some kind of inverse lightning)? I've got a sphere with a earth texture on it and a light (sun) rotating around the earth. The lighted side looks fine but the shadow side is just black (or gray shadowed depending on material settings). What i want is to add a 2. texture with earth at night (city lights and so on) which should only be visible on the shadow side and not on the daylight side. I've searched for hours and tried different lightning and blending options but nothing worked. The night texture is either visible everywhere or no where. Any suggestions how to solve this?
Thank you in advance!

p.s. I'm using DirectX9

Sponsor:

#2 Waterlimon   Crossbones+   -  Reputation: 2575

Like
0Likes
Like

Posted 04 May 2012 - 07:46 AM

You could probably do that with a shader but not sure if you can do it without them.

o3o


#3 kauna   Crossbones+   -  Reputation: 2570

Like
0Likes
Like

Posted 04 May 2012 - 07:51 AM

Definetely it is possible.

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.

Something like:

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.

Cheers!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS