PDA

View Full Version : Environment Reflection



Coluna
02-25-2003, 07:52 PM
How can I configure two texture units, one with the object's texture, and the other with the environment map , to display properly? I tried a lot o combinations but I didnt get the correct effect

jwatte
02-25-2003, 08:42 PM
reflection is additive; color maps typically are modulating. Thus, you want texture environment 0 to modulate the base color texture, and texture environment 1 to add the result of the environment map.

ScottManDeath
02-25-2003, 11:50 PM
Hi

I do it the following way.(not that lighting is used and that texture unit 0 is set to modulate) I interpolate between lit base texture and the env map by the texture environemnts constat alpha value;



glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_CUBE_MAP,cube_id);

glTexGenf(GL_S,GL_TEXTURE_GEN_MODE,GL_REFLECTION_M AP);
glTexGenf(GL_T,GL_TEXTURE_GEN_MODE,GL_REFLECTION_M AP);
glTexGenf(GL_R,GL_TEXTURE_GEN_MODE,GL_REFLECTION_M AP);

glEnable(GL_TEXTURE_CUBE_MAP);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);


glMatrixMode(GL_TEXTURE);
glPushMatrix();

matrix4f m;
m.set_value(live_srotation);
m=m.inverse();

glMultMatrixf(m.m);



glMatrixMode(GL_MODELVIEW);


glTexEnvi (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE);

GLfloat env_color1[4] = {0.0f,00.0f,0.0f,live_env_factor};

glTexEnvfv(GL_TEXTURE_ENV,GL_TEXTURE_ENV_COLOR,env _color1);
glTexEnvi (GL_TEXTURE_ENV,GL_TEXTURE_ENV_MODE,GL_COMBINE);

// RGB combiner setup
glTexEnvi (GL_TEXTURE_ENV,GL_COMBINE_RGB,GL_INTERPOLATE);

// arg 0
glTexEnvi (GL_TEXTURE_ENV,GL_SOURCE0_RGB,GL_PREVIOUS);
glTexEnvi (GL_TEXTURE_ENV,GL_OPERAND0_RGB,GL_SRC_COLOR);
// arg 1
glTexEnvi (GL_TEXTURE_ENV,GL_SOURCE1_RGB,GL_TEXTURE);
glTexEnvi (GL_TEXTURE_ENV,GL_OPERAND1_RGB,GL_SRC_COLOR);
// arg 2
glTexEnvi (GL_TEXTURE_ENV,GL_SOURCE2_RGB,GL_CONSTANT);
glTexEnvi (GL_TEXTURE_ENV,GL_OPERAND2_RGB,GL_ONE_MINUS_SRC_A LPHA);
glActiveTexture(GL_TEXTURE0);


Bye
ScottManDeath