View Full Version : MD3 Bump mapping problem! PLZ Help!!!

09-02-2004, 03:04 AM
Hello people!
I am trying to use PPL bump Mapping with ARB_fragment_program in quake3 models(md3)
But I fail! I dont know what I am doing wrong... I use qview modelviewr source!
When I am trying to "put" bump mapping, yes it works. but not correct. I test the

normals(using an opengl simple light(per-vertex)) and it looks correct! This means that the

normals are calculated correct! The fragment program I use is correct besuase with this

program i render the world and i have no problem! Also the tagent and binormal calculation

function is correct because I also use it for rendering the world...
I try to trw the polygons model just like I draw the world! but it does not work correct@! yes

I see bump mapping but

1) it is not correct with currect light position. e.g.:the light is behind the model and is

is all dark and if the light goes infront of the model then all the model are bright!
2) not smooth at the edges of the polygons!

The normals is correct (beacause it looks correct when I use OpenGL per-vertex Lighting).
what I am doing wrong?

here is the code for the md3 model drawing:

here the vode for the tgent/binormal calculation function:

here is the fragment program i use for rendering:

thanks in advance

09-02-2004, 08:00 PM
I really wish I could see the vertex program, and I am not terribly familiar with ARB asm, I program in CG mostly... so I am going to give a few bump map pointers.

Now, I must say there are a lot of tutorials out there about how to bump map things, but many of these are piecemeal, they tell you all the aspects of bump mapping, except each in their own little source file... not helpful to the general populace.

OK, Now for my assisting you...
1) you have to have a "texture space matrix" which will convert object coords to texture space coordinates. Apparently you already have this.
2) you need to rotate the light vector and eye vector to texture space in your vertex program, or you need to rotate your normal (from the normal map) to your object's space... not really a good idea, since that's a per-fragment op.

Oh, and another thing, you really can't use "bump maps" directly, you must convert them to "normal maps" prior to using them in a vertex program. The difference being the bump map is a grayscale relief "heightmap" where the normal map has RGB -> XYZ vectors which describe the normal direction in texture space.

I hope I have helped. I also suggest you try reading the CG Tutorial, see if you can find it in the bookstore.