Sign in to follow this  
fpsgamer

Bump Mapping a Mesh....

Recommended Posts

fpsgamer    856
I am currently working with terrain meshes and I want to implement bump mapping. I am confused how exactly I can calculate object space to tangent space matrix per vertex when the triangles that share it may have very different properties.

Share this post


Link to post
Share on other sites
soconne    105
I suppose you could use world space for bump mapping a terrain but it wouldn't be physically correct. Since the terrain is tilted at numerous points, the normal changes and does not point straight up, so the incoming value from the normal map would need to be transformed. But I guess it wouldn't be noticeable.

Share this post


Link to post
Share on other sites
Quote:
Original post by soconne
I suppose you could use world space for bump mapping a terrain but it wouldn't be physically correct. Since the terrain is tilted at numerous points, the normal changes and does not point straight up, so the incoming value from the normal map would need to be transformed. But I guess it wouldn't be noticeable.


What? The whole point of using world space normal maps would be that you wouldn't have to transform them, and you wouldn't have to keep track of tangent space. They would be ready to directly feed into a lighting equation...

Share this post


Link to post
Share on other sites
fpsgamer    856
Quote:
Original post by JasonBlochowiak
Is there really any reason to worry about tangent space for doing terrain rendering? Why not just do world space normal maps?


I tried this and was not able to get it to work. I used OpenGL's texture blending to do the normal mapping. I made sure to pass in the normalized untransformed (world space) vector from the vertex to the light source. However when I did this the bump mapping was only visible along the East and West edges of the terrain. The rest of the terrain remained entirely un-bump mapped.

I am not totally sure why this was happening, however I hope that performing a tangent space transformation will work.

Though I did find an answer to my original query. One source reccomends averaging all the T B and N vectors originating from a vertex, then using that to contruct the NTB matrix for the vertex ... which is fairly obvious so I wonder why I didn't think of it before :)

Howver if anyone who has gotten world space bump mapping working on terrain, I would love some pointers.

Share this post


Link to post
Share on other sites
Unless I'm mistaken, world space normals maps wont work for terrain in most cases, because normally you use tiled textures for terrain (unles you use mega textures). In that case, how can they be put into world space? It sems you have to use tangent space, and why not? Its easy to do..Just calculate the tangent for the terrain just like anything else.

However, if you use some kind of dynamic tesselation, then you may have problems, in that case you might use some kind of approximate tangent space..

Share this post


Link to post
Share on other sites
I'm not quite sure what went wrong in the implementation, but look: You end up doing your lighting in some space - I'm currently doing it in world space. That means that, somehow or another, your normals need to be in world space. You can store them in some other space and transform them, but in the case of the terrain, you already know where the terrain is, and how its oriented to the world, so doing the math to convert normals to world space is something that can be done offline. No need to carry the extra data for a binormal, no need to compute tangent space, nothing. It's entirely independant of whether you're using a tiled texture or a monolithic one.

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