PDA

View Full Version : Nehe Bump mapping tutorial question.

dabeav
08-01-2002, 08:53 AM
In NeHe's bump mapping tutorial, he loads an inverse matrix, and I for the life of me cannot figure out why? What i do, is this, move my eyes, based on the negative tranlastion and rotation of the player, then i bump map my objects using the U,V vectors of the verts, and the light possitions. But I dont know if that Inverse matrix, is supposed to do something with the lights or not?...??

Nutty
08-01-2002, 09:13 AM
An Inverse modelview matrix, is used to transform things in worldspace to objectspace.

Typically lights are converted from world space to object space. i.e. local to the objects own coordinate system. You do this in bump-mapping, so you can calulate the surface to light vector, and it's in the same "space system" as the bump-map normals.

Typically you need to transform the object space surface->light vector into tangent (texture) space as well.

Look at the bottom demo here for more info on tangent space bump-mapping. http://opengl.nutty.org/nvidia/index.html

Nutty

dabeav
08-01-2002, 10:25 AM
Ok wait, im confussed. Say i have a room, with 5 objects. I move my eye view around them room. Does this change the values of the verts used to make up the room and objects? Or are they only changed when the objects them selves move?? And if they are changed when an observer moves, wouldnt that make it damn near impossible do drop a new object in the room. Because you wouldnt ever know what the "new" coord system was.

dorbie
08-01-2002, 11:00 AM
There things are relative. The values change if you consider them in eye space, but the values in world space remain the same. So, it really depends what space you store your lights in. If the objects are under their own model matrix then you have 3 spaces, eye->world->object, if not then for those objects with no model transformation object space equals world space.

The transformation from world to object space only applies to objects that are being animated in the world under their own matrix. That is of course IF your lights are stored in world space.

dabeav
08-01-2002, 11:10 AM
Ok.

So in my room, if i have 5 objects. If i move around the room, the room itself is in world space. But any objects in the room, say a "sit and spin" that is rotating, and a toy train that is moving about, are in there own 'object' space. Because they not only move when the 'space' moves, but also when they move independantly.

So these objects that move with out the observer moving, would need the lights to be converted into 'object space' because my lights are stationary within the scene, and move only realive to when the observer moves. Do i got it now??

So if i want to bump map those objects, with emboss mapping. I would move the entire scene. "THEN" move each individual piece to its respective location, and create an inverse matrix, of ONLY that move, and aply those changes to the bump map algorithm.

For example, the Observer walks 3 feet forward in the room, and at the same time the toy train moves 2 feet to the left. In 'world' space, the toy train moved 3 feet closer and 2 feet to the left, but in 'object' space it moved 2 feet to the left. So, we only aply an inverse matrix to the 2feet to the left, making it 2 feet to the right, in order to develop 'object' space for the lights. Right?????????

dorbie
08-01-2002, 11:26 AM
Yes you got it, BUT, when you say move the entire scene you're describing something in a way that doesn't actually happen. You move the light to the object as a preprocessing stage. Sure when you draw the object you multiply the matrix on the stack, that moves the scene as normal, but before this happens hopefully in software you've moved the light position to the object (using the inverse matrix) and then performed the tangent space calculations. These supply the texture peturbations for the subsequent rendering that uses standard OpenGL matrix operations.

[This message has been edited by dorbie (edited 08-01-2002).]