Jump to content
  • Advertisement
Sign in to follow this  
sepul

DOT3 problem ...

This topic is 4815 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, I'm trying to implement DOT3 bump mapping only on STATIC geometry. so what I need to do is to is transform normals from the texture space to world space, is that right ? how can I do that ? thanks

Share this post


Link to post
Share on other sites
Advertisement
Most tools that generate normal maps can leave the normals in object space. Are you sure your program doesn't do that?

ATI makes a tool called Normal Mapper that works really well. The front end seems broken, but if you can get around having to use the command line, it's pretty nice.

It works something like this:
NormalMapper.exe w normal_mesh_file high_mesh_file 512 512 normal_map.tga
The w represents world space normals.

Share this post


Link to post
Share on other sites
Is there a reason you are doing object space bump mapping and not tangent space? There are a bunch of great tutorials on tangent space.

Books - Programming Vertex and Pixel Shaders by Wolfgang Engel

Links -
http://www.codesampler.com/dx9src.htm
http://www.shadertech.com/articles/
http://www.ultimategameprogramming.com/

Hope maybe something in there will help

Share this post


Link to post
Share on other sites
what I decided to do was to implement bump mapping only for static objects, so I won't be complicating stuff, and tangent space calculations, shader code,.. needed.
and I don't create hi-res and low-res meshes, I just wanted a simple bump mapping effect on objects

what I do is create a normal map from object's height map (D3DXComputeNormalMap), get a light vector from the scene and set it to texture factor, and do the DOT3 texture blend. but some polys in the scene gets totally black, so I realized I must do some kind of transformation from texture space to world space. but I just don't know how to do that .

do I have to stick with dynamic bump mapping method (calculating tangent space vectors, shaders, etc) or is there any easier way to implement static bumps ?

Share this post


Link to post
Share on other sites
Quote:
Original post by sepul
and I don't create hi-res and low-res meshes, I just wanted a simple bump mapping effect on objects

Umm, only the low res version is used in your game. The tool creates a normal map for the low res to make it look like the high res. Once the tool creates a normal map, the high res version is no longer needed.

I believe you should keep more of an open mind. A shader is not needed to apply normal maps onto non-static objects. Skin meshes maybe, but not simple rotated and translated stuff. The only extra step is to multiply your light direction with the inverted world matrix of the object. Beyound that, everything is identical. You encode the light direction into diffuse (or specular) and render the sucker.

Share this post


Link to post
Share on other sites
Quote:
Umm, only the low res version is used in your game. The tool creates a normal map for the low res to make it look like the high res. Once the tool creates a normal map, the high res version is no longer needed.


I know that, what I meant was, I don't use this method, for example I just put a texture on a brick wall(simple quad), and set it's height map as "bump map", then convert the height map to normal map to get a bumpy brick wall effect.

Quote:
A shader is not needed to apply normal maps onto non-static objects. Skin meshes maybe, but not simple rotated and translated stuff.

shaders are not a must, but if you don't use vertex shaders, it will kill performance, because you have to lock each vertex buffer, roll through vertices, and transform the light by inverse tangent matrix and set it to diffuse, that kinda stuff can be done in vertex shader so fast, and so slow on cpu !

besides vertex shader, in order to do tangent space, I have make a lot of changes t the engine, add biNormals, tangent vectors, etc, keep in mind that I only need bump mapping on static objects for now, I've read a simple article about this on :
http://www.riaz.de/tutorials/d3d14/d3d14.html
which said :
Quote:
That means if you rotate the object the normals remain unchanged. There are two ways of solving this problem. The first way is to transform the normals to world space, but this is only useful for static objects. The second way is to transform the light vector into texture space.


I just wanted to know how can the first way (transform the normals to world space) should be done ?

btw, I've done the thing that "kest" said (The only extra step is to multiply your light direction with the inverted world matrix of the object), It didn't change anything, cuz the polygons are in world space already, but I still get some totally black polygons.

Share this post


Link to post
Share on other sites
Quote:
Original post by sepul
I know that, what I meant was, I don't use this method, for example I just put a texture on a brick wall(simple quad), and set it's height map as "bump map", then convert the height map to normal map to get a bumpy brick wall effect.

Okay, well, you still need to make sure the height map is converted into an object-space normal map. If that's not possible, you might have to find another method.

Quote:
shaders are not a must, but if you don't use vertex shaders, it will kill performance, because you have to lock each vertex buffer, roll through vertices, and transform the light by inverse tangent matrix and set it to diffuse, that kinda stuff can be done in vertex shader so fast, and so slow on cpu !

I thought we were working in object space? If your normal map is in object space, you can rotate your objects without any problems. That's no different than the light rotating around the object. You just need to adjust your light direction to be relative to the object.

What I'm saying is that you can add a normal map to an object that rotates, scales, and moves around, and not use a vertex shader, and not lock the vertex buffer. You just need a value to send to the dot product 3 stage. And not a value that comes from vertices. For example, you could use the T-Factor value.

Quote:
btw, I've done the thing that "kest" said (The only extra step is to multiply your light direction with the inverted world matrix of the object), It didn't change anything, cuz the polygons are in world space already, but I still get some totally black polygons.

What texture stages are you using, "sepul"? [wink]

Share this post


Link to post
Share on other sites
thanks for the info kest,
but the problem is the normal map I'm using, cuz like I said, I don't create a hi-res mesh and build normal map out of it, I just use a height map and convert it to normal map, so I don't think the normal map is in object space, it's in texture space.

right now, I'm using multi-pass multitexturing, the first pass is rendered normally, on the second pass I set the TFACTOR, and render the bumped polys with these states :

_device->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );

_device->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ZERO );
_device->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_SRCCOLOR );

_device->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_DOTPRODUCT3 );
_device->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
_device->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_TFACTOR );

Share this post


Link to post
Share on other sites
Hey, that's pretty clever. So the destination color blends through using the dot product value. In case you didn't know, the dot product value also gets stored in the alpha channel ( so you could also use SetRenderState( D3DRS_DESTBLEND, D3DBLEND_SRCALPHA ). This means you could actually blend something as the source instead of black. Not that you would need to.

I can't help much with the height map and normal map D3DX generation methods. I've never used those. But if they can't be configured to output object-space normal maps, your only choices are to either find another method to generate the normal maps or program the tangent space code (and infuse your vertices with all that extra gunk).

What type of mesh are you working with? Is it a flat surface? I'm not understanding how a normal map generated from a mesh can actually improve the quality of that same mesh. If the heights are already there in the mesh, what is the purpose of the normal map?

Share this post


Link to post
Share on other sites
I'm using bump mapping for the walls, floors, etc. for example brick walls have a height map, I make a normal map for them.
if you put a normal brick texture, it will look bad, but if you do bump mapping on it, it will look like a bumpy brick wall, and the bumps will change when the light changes. so it has better lighting and quality. with no need to create a hi-res mesh, or build normal map for it, just make a height map, and it will all be done.

anyway I guess I have to stick with the tangent space stuff, its more common method, and later I can add object space normal mapping to my animated meshes and other stuff too.

thanks for your help

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!