#### Archived

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

# Bump mapping: correct texture stage states

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

## Recommended Posts

i''m currently learning how to implement bump mapping, i''m iterested in both enviromental bm and dot3 bm, but i don''t want to use any shader for now. here''s my code for env bump (more or less the same as the sdk sample):
g_pD3DDevice->SetTextureStageState(0,D3DTSS_TEXCOORDINDEX,0);
g_pD3DDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
g_pD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_TEXTURE);
g_pD3DDevice->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_DIFFUSE);

g_pD3DDevice->SetTextureStageState(1,D3DTSS_TEXCOORDINDEX,0);
g_pD3DDevice->SetTextureStageState(1,D3DTSS_COLOROP,D3DTOP_BUMPENVMAP);
g_pD3DDevice->SetTextureStageState(1,D3DTSS_COLORARG1,D3DTA_TEXTURE);
g_pD3DDevice->SetTextureStageState(1,D3DTSS_COLORARG2,D3DTA_CURRENT);

g_pD3DDevice->SetTextureStageState(2,D3DTSS_COLOROP,D3DTOP_MODULATE2X);
g_pD3DDevice->SetTextureStageState(2,D3DTSS_COLORARG1,D3DTA_TEXTURE);
g_pD3DDevice->SetTextureStageState(2,D3DTSS_COLORARG2,D3DTA_CURRENT);
g_pD3DDevice->SetTextureStageState(2,D3DTSS_TEXCOORDINDEX,D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR);

g_pD3DDevice->SetTextureStageState(1,D3DTSS_BUMPENVMAT00,F2DW(1.0f));
g_pD3DDevice->SetTextureStageState(1,D3DTSS_BUMPENVMAT01,F2DW(0.0f));
g_pD3DDevice->SetTextureStageState(1,D3DTSS_BUMPENVMAT10,F2DW(0.0f));
g_pD3DDevice->SetTextureStageState(1,D3DTSS_BUMPENVMAT11,F2DW(1.0f));

g_pD3DDevice->SetTexture(0,&g_ModelTexture);
g_pD3DDevice->SetTexture(1,&g_ModelBump);
g_pD3DDevice->SetTexture(2,&g_EnvMap);
g_Model.Draw();

i''m getting pretty good results, but i think the env map covers too much the original texture.. and as you can see im modulating 2x in texture stage 2: the sdk sample used D3DTOP_ADD but if i use it everything is damn too bright. modulating looks much better. the question are: 1)how do you usually set enviromental bump mapping using fixed function pipeline? 2)how to get DOT3 bump mapping work? i tried using D3DTOP_DOTPRODUCT3 between texture and texture factor (encoding the light direction into it) but very strange results came out. 3)i generate normal maps using the nVidia''s photoshop plugin; i save them as 24 bit bmp''s, and i load them as D3DFMT_V16U16; is this correct? i mean im quite sure it''s not correct as 16+16=32 and the image is 24 bit/pixel, but hey, it works..

umh up

##### Share on other sites
quote:
Original post by Arcibald Wearlot
umh up

Do you have any screenshots?

I have been playign with this as well and noticed different behavior between ATI and nVidia cards (using fixed-function).. May I ask what hardware you are using?

I have been forced to (learn and) use Vertex shaders so that the results are common, which IS the case.. still learning though...

• 9
• 11
• 18
• 14
• 10