I made bump mapping work, now I would like (true) reflective bump mapping.
More generally, I want to get the texel normal from the bump map, and use it to look into a cube map (for reflection, for diffuse or specular lighting, …). I assume I have no other choice that converting the normal from tangent space to object space, and I have no idea how this can be done. Are there any other solutions ?
For classic bump mapping, I computed in the vertex program the light vector in tangent space, for each vertex. Then it was interpolated at each texel (as usual with Gouraud shading or with a normalization cube map), giving me a bumped normal and a light vector in the same space. It was then easy to dot them together in the fragment program, along with other basic pixel operations.
How can I invert this process, so that I can get my bumped normal in object space ?
SeskaPeel.
if you are allready converting you lightvector from objectspace into tangentspace using a 3x3 matrix (built using interpolated vertexnormal,tangent & binormal), you can convert the normal stored in your normalmap from tangentspace back to objectspace, by simply multiplying this vector with the inverse of the 3x3 matrix.
to invert a 3x3 matrix you simply need to do an transpose (swap rows and colums of the matrix).
Yes, yes, of course. But how can I correctly interpolate, per texel, this itranspose matrix ? I can compute it per vertex, but then how do I pass it to the texel ?
SeskaPeel.
3 sets of texture coordinates + 3 normalisation cube maps.
[This message has been edited by knackered (edited 08282003).]
erg … well … I’ll drop the 3 normalization cube maps, and I’ll renormalize within the fragment program.
The 3 texture coordinate sets … I already use them (I use 3 of them). Is there a way to get 8 sets ? I intend to use 4 texture units, my video has 4 units, and no more, but can I have more than 4 tex coo sets on such card ?
SeskaPeel.
Simpler to test than to ask …
I actually have 8 texture coordinate sets.
I don’t really get how this can be useful, it should rather be generic streams from vertex to texel …
Anyway, what kind of cards have > 4 texture coo sets ? (NVidia FX and up, ATI Radeon … ?)
SeskaPeel.
Here are three pieces of information which may get you a much more efficient solution when applied correctly:

Instead of bringing the light vector into tangent space (where the normal lives), bring the normal vector into light (== object?) space. Same amount of operations either way, so far.

For vectors with no translation or scale (only rotation) you only need the upperleft 3x3 submatrix of your 4x4 matrix. A 4x3 matrix with translation will turn into a 3x3 by just dropping the translation elements.

The inverse of a rotation with no scale is its transpose. To multiply by a 3x3 matrix, you do 3 DP3 operations. To multiply by the transpose of that very same matrix, you do 3 MADD operations, which will mul/add the other way (columns instead of rows).