Hi, im having my first go at trying to do normal maps using shaders.
So ive done some shaders form tuts, i have per pixel lighting working and i now want to have a go at normal mapping. I have my normal map loaded in ready to go.
Ive found plenty of normal map shader tuts, but they all seem to just “receive” tangents from opengl and i literally dont have a clue what tangents are? Well i know an hours worth of reading from today, but i really dont know…
- What they are?
- Why i need them?
- And how i calculate them (actual code, not therory)
Lamens terms i guess!
Really hope you can help.
Thanks
Andy
Hi, thanks, so from looking at that code? It loops threw all the triangles and seems to put all the tangents in a array? Is this all required to simply show a single normal map on a quad?
If it is then thats fine ill try to continue. Justs seems hard work at the momement.
Ive read from the above links, that if the pimative or object is made form quads and not triangles then a different calculation is needed? Is that so? What happenes if you have mixed objects in a scene?
Thanks
Andy
Technically thats right. But the algorithm targets arbitrary meshdata. For a quad its not pretty hard to provide the tangents by hand (for the sake of testing).
Since a quad can be seen as two adjacent triangles there should be no real problem in this case. Normally you would generate the tangents (or just one of them, plus the vertexnormal… In this case you could retrieve the remaining axis by taking the cross product of the given two vectors in your shader) for each vertex, and pass the data as vertexattributes to the shader. Since you would do that for all objects which require the data it’s no matter how many objects reside in your scene.