texture stage in Dot3 bump mapping?

Started by
2 comments, last by Khanh 20 years, 5 months ago
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
Advertisement
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

Niko Suni

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
sorry for all stuff, I''ve just forgotten to set FVF to TEX2. Anyway, thank you.

K

This topic is closed to new replies.

Advertisement