PDA

View Full Version : cubemapping, reflections, radiosity...



gunslinger
12-16-2003, 12:16 AM
hi all forum folks,
I have been a newbie in opengl stuff for more than an year, now i am feeling kinda it is time to face some serious stuff.
My first question is: where i may find some good book teaching the adv uses of opengl? Stuff like doing your own lighting, computing radiosity algorithms and so on.
Next there are a few questions i am facing right now: what is exactly a cubemap? I have a nice tutorial, but unfortunately i am not understanding it very much. For example in the rendering loop there is something like:

*compute cube map*
glClear(GL_DEPTH_BUFFER_BIT);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

//some scene rotations
//no big deal here
glRotate(..);
glRotate(..);


//render world
RenderSkyBox();

glTranslatef(*camera position*);

//enable cube mapping
glEnable(GL_TEXTURE_CUBE_MAP_ARB);

//enable the texture
g_cubemap->bind();

//enable cube mapping
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);

>ok, first big question:
>what happens when i switch to
>TEXTURE matrix? Am i rendering
>the scene on a special texture
>that i will use to make the
>reflection map? I just used
>modelview for all my (short)
>opengl career, so i am a bit lost. http://www.opengl.org/discussion_boards/ubb/eek.gif
glMatrixMode(GL_TEXTURE);
glPushMatrix();

//here is the viewport corrected. NOTE that
//we are in TEXTURE matrix mode
glRotate(-yangle...);
glRotate(-xangle...);

//rendere the sphere
>ok now where am i rendering this sphere?
>I thought i was just putting all the sphere
>stuff in a sort of texture buffer, but it
>actually renders it in the middle of my
>scene... puzzling
gluSphere(shere,6.0f,64,64);

//restore texture matrix
glPopMatrix();
glMatrixMode(GL_MODELVIEW);

glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);

//render the objects

*render 2 cubes and a sphere...


that is the chunk i am having some trouble to undersand. I hope i am not too much off theme for an advanced forum, but actually i do need to start somewhere after all, no?
Thank you to all who'll help me
The Gunslinger

Relic
12-16-2003, 12:48 AM
The texture matrices (there's one per texture unit) are the same 4x4 matrices you know from modelview and projection, The only difference is, they are applied to the txcoords on that unit before the texture lookup is done. Their default is the identity matrix, means all texcoords commands go through unchanged.
For example, if you have a single textured quad try to load the texture matrix with a glRotate(45, 0, 0, 1) and watch your texture being rotated.
With a full 4x4 you can do all sorts of texcoords and other manipulations, like projective texturing, bumpmap support, animation (scrolling), etc.

The texture matrix has nothing to do with where geometry is rendered, only how texcoords are transformed before lookup.

[This message has been edited by Relic (edited 12-16-2003).]