Confused about per-pixel lighting and tangent space

Started by
1 comment, last by TheDmD 17 years, 5 months ago
Hello, Per pixel lighting is simple and popular technique. Unfortunately I'm no lucky. I have done many test and even more shaders. Results always were other than I expect. There are any 'standard' approach do deal with? I always had problems with generating tangent space matrix for vertices. Actually, I don't know this correct or not. I can check that one vector is prependicular to second but results still do not satisfy me. I think, the mesh has some 'internal' bugs, because is looks absoluely different in 3D Studio and in my viewer. I have tried write 3DS file reader to avoid whole model system but I'm stuck in tangent space generation again! So I have a few questions: 1) How to propertly calculate tangent space form simple mesh (ie. triangles)? 2) From where can I know that results are correct? 3) Is it depdendent of RH camera? 4) Effect depends form hadrware (aka. results are this same on nVIDIA and ATI)? 5) Where is the difference between D3D and OpenGL? I hear about different UV mappings, but there is something more? Lighting depends form tangent stuff, so it cannot be correct until problem is not solved. I think, my shaders are correct. Thanks for are replies. TheDmD
Advertisement
AFAIK you don't need tangent space to compute lighting at all. I'm quite confident that I wrote a shader once that did that without using tangent space. You would like to use tangent space for some effects like normal mapping (a way to perform bump mapping).
this is a link to a 3ds loader I wrote a while ago that computes tangents, normals and and bitangents. I never updated the documentation of the lib, but the sources is quite simple and short (only one cpp file, IIRC).
Hope this helps.
Actually I need tangent space exacly for normal maps. :)

Thanks for source. I will use it to compare results. After that I will post some more informations.

This topic is closed to new replies.

Advertisement