Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 

 Home / 3D Theory & Graphics / Light direction for DOT3-Bumpmapping Account Manager
 
Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
 
Firlefanz

May 27, 2005, 03:49 AM

Hello,

I have created a universe, the sun is at 0/0/0, and 30 planets rotating around it.

Now I added some DOT3-Bumpmapping, but I am not sure about the correct direction.

So is the following code correct, when 0/0/0 is the sun which is the light source, and planet is the current planet? [code] m_vLight.x := planet3d.x; m_vLight.y := planet3d.y; m_vLight.z := planet3d.z; D3DXVec3Normalize(m_vLight, m_vLight); dwFactor := VectortoRGBA(m_vLight, 0.0); SetTexture(0, planet3d.bumptexture); SetRenderState(D3DRS_TEXTUREFACTOR, dwFactor); SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE); SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR); SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3); [/code] Thanks a lot, Firle

 
tokjunior

May 27, 2005, 04:48 AM

You'll need to transform the light-direction into texturespace (tangentspace) for each vertex, or the direction won't be correct no matter what you do.

 
Firlefanz

May 27, 2005, 05:30 AM

Hello tokjunior,

I am a D3D beginner, could you please tell me how to transform it?
The planets are just spheres (with one material), also is the sun.

Firle

 
Japigeman

May 27, 2005, 06:22 AM

You need to take the direction the surface is facing into account.
You need the direction of the lightsource (the sun) relative to the surface.

Or at least that's what I think he means.

You can see better with a picture:
http://img273.echo.cx/img273/9288/jaapexplains9px.png
See?

 
This thread contains 4 messages.
 
 
Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.