Archived

This topic is now archived and is closed to further replies.

texture stage in Dot3 bump mapping?

This topic is 5143 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hi all, I can see that the DotProduct3 bump example in SDK has only 1 normal map texture "Dot" Light Vector (contained in TFACTOR). My questions are: 1) if I want to blend with 1 base texture more, how to do that? Is that: (normal map(stage 0) "Dot" TFACTOR) "modulate" base texture(stage1) ? 2)Light vector here means direction vertor from pixel to light position? Thanks in advance, Khanh

Share this post


Link to post
Share on other sites
Both of your assumptions are correct.
You might want to use a vertex shader to transform the light vector to texture space (tangent space) if you intend to use dp3 on a real model (ie. not a single plane).
This is what tangent and binormal, derivatives across texture space u and v, are for.

-Nik

Share this post


Link to post
Share on other sites
hi Nik02 and all,

So I tried to modify the DotProduct3 sample to blend with 1 more base texture, but it results strangely out of my expectation. Could anyone tell me what I was wrong?

//load texture
D3DUtil_CreateTexture( m_pd3dDevice, _T("Earth.bmp"),
&m_pFileBasedMap,D3DFMT_A8R8G8B8 ) ) );
D3DUtil_CreateTexture( m_pd3dDevice, _T("EarthBump.bmp"),
&m_m_pFileBasedNormalMap,D3DFMT_A8R8G8B8 ) ) );

//render
DWORD dwFactor = VectortoRGBA( &m_vLight, 0.0f );
SetRenderState( D3DRS_TEXTUREFACTOR, dwFactor );
SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3 );
SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR );
SetTextureStageState( 1, D3DTSS_COLORARG1, D3DTA_TEXTURE );
SetTextureStageState( 1, D3DTSS_COLOROP, D3DTOP_ADD );
SetTextureStageState( 1, D3DTSS_COLORARG2, D3DTA_CURRENT );

SetTexture( 0, m_pFileBasedNormalMap );
SetTexture( 1, m_pFileBasedMap );

FYI, my VGA card is GEForce FX5200.

Many thanks,
Khanh

Share this post


Link to post
Share on other sites