PDA

View Full Version : TANGENT BASIS CALCULATION DOES NOT WORK



brandoz
09-02-2005, 06:33 AM
Dear all,
I'm writing a GLSL shader for bumpmapping with the nornal maps.

1)The shader works ok when I use my own vertex and fragment shader source code in the Shader Designer by Typhoon Labs.
2)The shader doesn't work when I use it in a simple custom application, developed by me.

In the case 1) the TBN basis is computed by Shader Designer.
In the case 2) I compute the TBN by using functions found in the web.

I have tried 3 different functions found, without results, found at the URLs:

http://www.blacksmith-studios.dk/projects/downloads/bumpmapping_using_cg.php

http://www.terathon.com/code/tangent.html

http://www.ati.com/developer/samples/VertexBlendD3D.zip (source code .cpp file : tangentspace.cpp).

Does anyone have some suggestion?

Thank you very much.

Regards

Stefano

Zulfiqar Malik
09-02-2005, 07:22 AM
You did not mention what sort of problems you are having! I had a few problems regarding TBN matrix and then i fould an old post (very old) somewhere in the advanced coding forum, regarding the same topic. In one reply Eric Lengyl mentioned that most of the techniques found on the net (even those on nVidia and ATI site) are wrong and do not generate the correct TBN space in all cases. He then presented his technique that he had given in his book and he was kind enough to even provide source code for it. I used that and everything has worked fine every since (not to mention that it was also very efficient).

I could have posted that link over here but i didn't because you should get used to searching the forums especially for mundane topics such as this which have already been discussed to great lengths.

Zulfiqar Malik
09-02-2005, 07:25 AM
It was a very long thread, and dating back to around 2002, and in case you still can't find it then i have the page book marked on my office machine and i will give it to you, but that won't happen until monday :p .

brandoz
09-04-2005, 10:02 PM
Ok.
In effect my question in too many general.
In my example application I render a sphere and I can switch between 3 rendering modes (so that I can check the results):

1) Fixed pipeline mode.
2) With a shader for usual per-pixel lighting.
3) With a shader (and with the proper diffuse and normal map textures) for bumpmapping.

In the mode 1) and 2) the rendering's behaviour is the same, ok.
In the mode 3) I see that diffuse light contribution is as the light has a changed its position with respect the 1) and 2). The same is for the specular contribution.
And the code for the shader in the mode 2) and 3) is the same plus the TBN matrix for the mode 3).

I will check also the old forums.

Tank you,
Regards

Stefano

Zulfiqar Malik
09-05-2005, 01:57 AM
Here's the link :)

http://www.opengl.org/discussion_boards/ubb/Forum3/HTML/011349.html

Do read the entire post because the meaning of some symbols used in the code is given by Eric in a later post. I hope this helps you.

brandoz
09-05-2005, 10:12 PM
Thank you Malik,
the code of Eric works!
In effect,
I found that I have already used it few days ago but now I have found some error in another part of my application...

Regards

Stefano

Zengar
09-15-2005, 03:36 AM
Please don't use capital letters as topic name. It is considered to be very rude and should be actually closed at spot.