Jump to content
  • Advertisement
Sign in to follow this  
tokaplan

Bump mapping via D3DTOP_DOTPRODUCT3

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

Here is a prezo I did on exactly this topic in 2002 at gdc.

http://developer.nvidia.com/object/gdc_practicalperpixel.html

Share this post


Link to post
Share on other sites
Advertisement
I start to wonder if this whole dot product technique can be used for complicated 3D models. It works very well for a plain, but imagine you're trying to wrap this very normal map around the cylinder. Obviously, this won't work, because you'll have different dot product result for different "sides" of the cylinder because of the wrapping. Isn't it so?

Share this post


Link to post
Share on other sites
normalmapping (this dot3-thingy) is ussually used for characters or other complicated modells so it should work for a cylinder,too. I don't know what kind of normalmap(there are Worldspace,ObjectSpace and angentSpace normalmaps) the usual hardware (w/o shaders) uses and you need tangent space normals for wrapping the normalmaps around modells but i think it uses tangentspace normalmaps. Someone correct me if i'm wrong.

regards,
m4gnus

Share this post


Link to post
Share on other sites
That's why you have to transform your light vector to tangent space. To do this, you first need to compute tangent and binormal vectors for all of your model's vertices. Then, you use the following matrix to transform the light vectors:


Tx Ty Tz
Bx By Bz
Nx Ny Nz

Where T is tangent vector, B is binormal and N is vertex normal. I'm sure you can find plenty of resources online about calculating tangents and binormals.

Edit: m4gnus beat me.
Edit v2.0: I just noticed that D3DX has a function for calculating tangents, binormals and normals, D3DXComputeTangentFrameEx(). If you're using ID3DXMesh, this should simplify things quite a lot.

Share this post


Link to post
Share on other sites
I think I understand what you mean.

But then I have to transform the light vector for each vertex of the mesh. This implies using vertex shaders, doesn't it? So what you're saying is that I can't avoid using them, can I?

Share this post


Link to post
Share on other sites
tokaplan, you're right : I don't think you can avoid using vertex shaders to do what you want to achieve on a non-planar surface : you would need to transform your light vector into tangent space for each triangle and set it with the appropriated render state for each triangle. For planes (walls, floor), it works correctly because the tangent space is the same for all the surface. That's a limitation of bump mapping, and that's why normal mapping exists to, well, map normals on an arbitrary surface (but then you need vertex & pixel shaders). Also, for your problem of "lighting too dark", the usual way is to modulate the diffuse color w/ the dot product and you usually add some ambient value, it can be done easily for a constant color, but you might be limited by the FF pipeline to do anything more complicated though.

Share this post


Link to post
Share on other sites
Since the problem is that the light vector is in the model space, and the normal (from the normal map texture) is in the vertex space, why can't I transform normal instead of transforming the light? I can transform every normal and form a new normal map texture. In this way no shaders are needed.

Share this post


Link to post
Share on other sites
The problem is, you would have to transform every single normal (ie. texel from your normal map) to world space. But you don't need to, because you can transform the light vector to tangent space instead - but you can only draw planar surfaces accurately then. Moreover, you can't do transformations just using texture stage states.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!