Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
Posted 04 February 2011 - 04:48 PM
Posted 04 February 2011 - 04:55 PM
Posted 04 February 2011 - 05:48 PM
Posted 04 February 2011 - 07:07 PM
Of course that workings with object-space normal maps is much easier . But... imagine you have a wall texture that appears notorously on many walls. For every "orientation" of a wall using that texture you would need one separate normal map. Having normal maps in tangent space and doind computations in that space is thus much more universal and much less memory consuming. You can imagine this using for example for characters. A character's texture will probably be used only on that particular character so having normal map in object-space in this case makes sense. Moreover, you avoid many problems associated with tangent-space computations, like sheared texture coordinates, non-orthogonal tangent basis and so on. So a good idea seems to be to have unique objects with object-space normal maps and "general" textures (like walls, decals, floors) in tangent-space. Note however that this requires from you to keep two slightly distinc shader paths for rendering one type of meshes and the other.
Object-space normal map: http://www.3dkingdoms.com/tut2.jpg
Posted 04 February 2011 - 07:48 PM
bitangent = determinant * cross(normal, tangent)Passing a normal, a tangent and a determinant takes 7 floats, whereas passing the whole basis takes 9 floats. 2 floats my is not much, but is a good step to start . Maybe someone has some better idea on how to save sending to much data to a vertex shader?
Posted 04 February 2011 - 07:55 PM
Posted 05 February 2011 - 10:03 AM
I my engine I send a normal and a tangent, leaving a bitangent to be computed with the cross product of the normal and the tangent. Certainly, we have two perpendicular vectors to normal and tangent and we must choose the proper one. The idea I use is to send a normal, a tangent, and a determinant of a matrix formed with (tangent, bitangent, normal). The determinant gives the handedness of the basis. So in my vertex shader I do something like:
bitangent = determinant * cross(normal, tangent)Passing a normal, a tangent and a determinant takes 7 floats, whereas passing the whole basis takes 9 floats. 2 floats my is not much, but is a good step to start . Maybe someone has some better idea on how to save sending to much data to a vertex shader?
Posted 05 February 2011 - 10:50 AM
I my engine I send a normal and a tangent, leaving a bitangent to be computed with the cross product of the normal and the tangent. Certainly, we have two perpendicular vectors to normal and tangent and we must choose the proper one. The idea I use is to send a normal, a tangent, and a determinant of a matrix formed with (tangent, bitangent, normal). The determinant gives the handedness of the basis. So in my vertex shader I do something like:
bitangent = determinant * cross(normal, tangent)Passing a normal, a tangent and a determinant takes 7 floats, whereas passing the whole basis takes 9 floats. 2 floats my is not much, but is a good step to start . Maybe someone has some better idea on how to save sending to much data to a vertex shader?
Personally I send normals, tangents, and bitangents to the vertex shader. I suppose I'd just rater compute all the stuff once per mesh and construct the tangent space matrix in the vertex shader instead of having it computer anything more. Not really sure if thats more efficient or not in the long run.
Posted 05 February 2011 - 11:24 AM
Posted 05 February 2011 - 12:30 PM
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.
GameDev.net™, the GameDev.net logo, and GDNet™ are trademarks of GameDev.net, LLC.