• Advertisement
Sign in to follow this  

bump mapping without shaders

This topic is 4412 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

All i wanna know is how to make bump mapping having the base texture and its bump map only... the direct3d9 sdk help tells it's need 3 textures (an environment map) and 3 texture stages... I don't understand why.

Share this post


Link to post
Share on other sites
Advertisement
You're liking looking at EMBM, which is meant for env mapping (Environment Map Bump Mapping).

Typically these days bump maps are done with DOT3. Depending on your app you might be able to get away with encoding a light vector into TFactor and using a the dot3 textureop with your bump texture. This will require an object space normal map, rather than the more common tangent space normal map. To use tangent space normal maps (which will allow reusing a normal map across more than 1 mesh, and can allow of things like bone animation) you'll need a vertex shader. This doesn't rule out any cards as vertex shaders can be emulated in software.

For the object space normal map method, you'll do something like this:

// calc light vector, convert from world space vector to object space
// encode into tfactor
lightvector = objectpos - lightsource;
normalize(lightvector);
worldtoobjmatrix = inverse(worldmatrix)
lightvectorinobjectspace = transformnormal(lightvector, worldtoobjmatrix);
dword tfactor = 0;
tfactor |= ((DWORD)(lightvectorinobjectspace.x * 127 + 128))<<16;
tfactor |= ((DWORD)(lightvectorinobjectspace.y * 127 + 128))<<8;
tfactor |= ((DWORD)(lightvectorinobjectspace.z * 127 + 128));
setrenderstate(d3drs_texturefactor, tfactor);

// setup for render
settexturestagestate(0, colorop, dot3)
settexturestagestate(0, colorarg1, texture)
settexturestagestate(0, colorarg2, tfactor)
settexturestagestate(1, colorop, modulate)
settexturestagestate(1, colorarg1, texture)
settexturestagestate(1, colorarg2, current)
settexturestagestate(0, alphaop, selectarg1)
settexturestagestate(0, alphaarg1, diffuse)
settexturestagestate(1, alphaop, selectarg1)
settexturestagestate(1, alphaarg1, diffuse)
settexturestagestate(2, colorop, disable)
settexturestagestate(2, alphaop, disable)
settexture(0,normalmap)
settexture(1,diffusemap)

Share this post


Link to post
Share on other sites
Alright, normal maps. I get it. But I'm making a 3ds max exporter plugin to direct3d, and I'm going to make multiple maps exporting now... I was looking at max's material maps, and I'm trying to implement its bump-mapping feature on directx. Max bump-mapping is simple: you choose a height map and a bump mapping "strength" percentage, and then the bump is applied. Searching on the web, I found that this kind of bump mapping is called embossing bump mapping (fix me if I'm wrong). Direct3D built-in bump mapping is another kind of bump mapping called Perturbed UV Bump Mapping: you must use a bump map and an environment map, build a 2x2 matrix, etc... what I want is a way to make max bump mapping work under direct3d, that is, implement a direct3d9 code that takes a height map and a "bump percentage" and makes the bump. Any idea???

PS: does anyone know a link / tutorial that explains in detail how perturbed UV bump mapping works and what are the environment map and the bump map it uses????

PS2: is it possible to create on the fly the environment map and the bump map from the height map??

Share this post


Link to post
Share on other sites
From what I understand, you're not looking on doing anything involving Environment Mapping, so you can pretty much skip anything involving Env. Maps as being irrelevant.

As to your question, for DOT3 bump mapping, you only need a "normal map", aka a "bump map", and an optional standard color texture. You would also need to set a light vector. As for bump strength, I'm pretty sure you can set that using a global variable.

I can't say anything about the exact visual effect of this method of bump mapping, compared to what MAX does (I'm not sure what MAX is doing internally), but the basics are pretty much the same. MAX is likely to have a much better visual quality, but then again, it always does :).

Heres a quick link to a tutorial on DOT3 bump mapping, which should hopefully get you started:

DOT3 Bump Mapping tutorial on Two-Kings.

Hope this helps.

Share this post


Link to post
Share on other sites
I don't want DOT3 bump mapping. I want to make a code that takes a height map and a bump strength and implements the bump.

Share this post


Link to post
Share on other sites
I was reading up on some DX resources at codesampler and Dot3 is the only 'fixed function' bump mapping that was listed on the DX9.0 page. DX8.1 had emboss bump mapping though. 9.0 probably dropped it. Of course go look at codesampler. You dont need an environment map either. The SDK always throws in a bunch extra. Shaders are the best way to go though anyway.

Share this post


Link to post
Share on other sites
I was reading about dot3 bump mapping... then I came to a doubt: I have a static mesh that can be translated, rotated, scaled (its world matrix can change, but its local vertices coordinates do not). Is it needed to change the normals in the normal map from texture space to world space????


PS: to claculate the vertex normals of a model I need to use the world coordinates of its vertices (with the world matrix applied) or the local coordinate of its vertices??

Share this post


Link to post
Share on other sites
That depends on what space your light vector is in. For accurate calculations, they both need to be in the same space. You could either move all normals to world space or move the light vector into object space (recommended).

Share this post


Link to post
Share on other sites
to transform the light vector to object space I need to use the vertex shader right?

PS: vertex normals in the fixed function lightning must be in world or local space coords??

[Edited by - ashade on January 19, 2006 7:26:07 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement