Smoothing tangents for bumpmapping - Printable Version
+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: Smoothing tangents for bumpmapping (/thread-3097.html)
Smoothing tangents for bumpmapping - TomorrowPlusX - Aug 13, 2007 10:49 AM
So, a while back I asked about calculating tangents ( http://idevgames.com/forum/showthread.php?t=14099 ) -- the good news is that after giving up and working on physics for a while, I spent the weekend on bumpmapping and by god, it works now. And looks great!
Now, that being said, there's one issue. For my procedural geometry, I submit tangent vectors as I generate the model ( easy enough, when creating cylinders, spheres, etc ). To test that my tangents are all correct, I have a flat normalmap ( 128, 128, 255 ) and render that. It *should* look more or less exactly like straight up per-pixel lighting.
And, as you can see below, for my cylinder geometry it does:
Now, this holds true for all my ( simple ) procedural geometry, but when I load a model from disk, I generate tangents from texture coordinates. The tangents are -- as far as I can tell by eyeballing correct, since the bumpmapping looks correct -- but when I use the flat normalmap, I can see that the tangents are on the triangle plane, and don't respect vertex normals. So I get something like flat shading, rather than smooth shading.
Here's a pick of what I'm seeing with an OBJ model I made in wings:
Here's the same model rendered with a vanilla per-pixel shader, to show how it should look:
I've tried to swizzle the tangents after generation to track surface normals, but with no luck.
Basically, above I'm checking if the vertex normal differs from the face normal, and if it does, I'm rotating the tangent about their cross product by the number of degrees they differ.
In my mind, this should rotate the tangents from the triangle face to the vertex normal's orientation. But it doesn't result in any visible difference.
Admittedly, this is a minor issue. When I apply a colormap alongside the normalmap you can't really see the flat shading, but I know it's there, and that bothers me.
Smoothing tangents for bumpmapping - TomorrowPlusX - Aug 13, 2007 10:54 AM
My "math" to fix the autotangents was backwards.
Why is it that after posting here, I figure these things out?