Sign in to follow this  

Simple Dot3 Bumpmapping with dx9 ?

Recommended Posts

hi all i try to make a game and now my landscape works ok, and now i want to add some stuff to it.. and i want to use dot3 mapping, i remeber in old sdk times there was dot3 simple sample without vertex/pixel shader but i lost that code and cant remember .. it was very simple.. a texture was loaded..and the from that texture a second for the dot3 was created ..and only some render states and sun position that was all.. with shaders i got much problems and i am glatt that vs1.1 water now works perfect can anybody help me how can i add simple dot3 in dx9 without shaders use (creating dot3 bump texture from another, and what settings at renderstates) here some older pictures from my work , the trees at moment are only decals because i cant find any 3d lowpoly trees and i dont have a million dollar in my bed for speedtree license :) [img][/img] [img][/img] [img][/img] [img][/img] much greetings and thx for any help :)

Share this post

Link to post
Share on other sites
You can use D3DXComputeNormalMap to convert a greyscale heightmap into a normal map, which you can then use with D3DTOP_DOTPRODUCT3. The sample likely encoded the sun direction vector into TFACTOR like this.

unsigned char sunx, suny, sunz;
sunx = (sundirvector.x+1)*128;
suny = (sundirvector.y+1)*128;
sunz = (sundirvector.z+1)*128;
unsigned long tfactor;
tfactor = (((unsigned long )sunx)<<16) | (((unsigned long)suny)<<8) | sunz;
pDev->SetRenderState(D3DRS_TEXTUREFACTOR, tfactor);
pDev->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3);
pDev->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDev->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_TFACTOR);
pDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TFACTOR);
pDev->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_MODULATE);
pDev->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pDev->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT);
pDev->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pDev->SetTextureStageState(1, D3DTSS_ALPHAARG1, D3DTA_CURRENT);
pDev->SetTextureStageState(2, D3DTSS_COLOROP, D3DTOP_DISABLE);
pDev->SetTextureStageState(2, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
pDev->SetTexture(0, pNormalMap);
pDev->SetTexture(1, pDiffuseMap);

Share this post

Link to post
Share on other sites

I have been playing with your example, and have managed to get some interesting results. However I haven’t been able to get a nice blend between the diffuse and the bump map, rather I am getting mostly bump and not much texture.

Do you possibly have a more complete example?


Share this post

Link to post
Share on other sites
hmm.. i try everything but it dosnt work

the result ending up in an complete white 3d object,
i try everything from the old dx8 examples..but
the pieces of code there did fit together

is there any complete tutorial for dot3 that really works?

->loading texure
->create bumpmap/compute normalmap
->setting devices (and everything needed)
->draw dot3 bumped Mesh

much thx

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this