Hi, I'm again hitting this topic and maybe someone of the shader coder can lead me into the right direction.
I want to bake normal maps in xnormal which show up in ogre as nice as in the xnormal viewer.
I would love to know how a typical and simple hlsl shader creates the tangent basis. And how xnormal does it compared to it.
The problem is I still don't really understand what is meant by "basis"
As far as I understand it you have
- the highpoly with normals for every spot on the surface
- the lowpoly with the same but a lot less vertices
- and the normal map which gives you a normal vector for every pixel, storing the information how to get from the lowpoly-surfacepixel-normal to the normal of the highpoly at this spot (more or less as we know this depends on the rays).
The tricky part is where the viewer or baker gets the tangents for a pixel/spot of the surface.
I want these formulas. I want the real vector math. As long as I don't have that I will for sure never really understand this.
cheers
Replies
http://area.autodesk.com/blogs/chris/how_the_3ds_max_scanline_renderer_computes_tangent_and_binormal_vectors_for_normal_mapping
and maya:
http://download.autodesk.com/us/maya/2010help/index.html?url=Appendix_A_Tangent_and_binormal_vectors.htm,topicNumber=d0e215045
And this may not be just a "shader" thing, but an exporter thing. IE: how your exporter saves out your mesh normals. It must save normals, bi-normals, etc, and all the same as the app you're generating in reads them.
and you are absolutely right.. the exporter we use does already save the tangents into the file and the shader just reads this value. :poly117:
I tried to find this a long while back and got stuck. I'm thinking I was looking before it was posted, but either way, hopefully more posts keeps this easier to find.
As far as xNormal's generation, my workflow in the past has been exporting OBJ's to xNormal to bake, and the normal maps appear correctly in both xNormals and Max. Also, maps baked out of xNormals appear identical (after tweaking settings) to those created in Max. This leads me to believe that they use the same Tangent Generation math. No proof one way or the other, just my experience.
Again, thanks for the find!