PDA

View Full Version : Environment Mapping!?



MartinM
02-08-2000, 07:34 AM
Has anyone got an idea how to do Environment Mapping on Polygons?
Can it be obtained only by using OpenGL Extensions or is there any other way!

Thanks for your Help in advance!
Martin

dmy
02-08-2000, 07:53 AM
you can easily obtain environment mapping with the opengl sphere map.
however, it is not a real EM... much like chrome effects in old demos.

try this:

// activate sperical EM texture coord generation
// for this to work properly, you need to specify almost one normal per face
// since the sphere mapping algorythm need to know how your faces are oriented about the viewer (origin)
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_S,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);
glTexGeni(GL_T,GL_TEXTURE_GEN_MODE,GL_SPHERE_MAP);

// activate screen blending mode, don't light primitives
glDisable(GL_LIGHTING);
glEnable(GL_BLEND);
glBlendFunc(GL_ONE,GL_ONE);

// make texture ready
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_MO DULATE);
glBindTexture(GL_TEXTURE_2D,<texture id> );

// white
glColor3f(1,1,1);

<draw your primitives w/normals>

should be everything you need to start...

Nate
02-08-2000, 07:53 AM
I have an example of doing environment mapping with and without an OpenGL extension on my webpage. The examples are on my programming page, they are the first two programs at the top of the page.

Nate http://nate.scuzzy.net

MartinM
02-08-2000, 12:24 PM
Thanks a lot for your Help!!