Sign in to follow this  
alex_r

EnvMap and MultTexture

Recommended Posts

Google --> "Reflective Bump Mapping"

I am guessing you are using Multitexturing to texture map a surface with multiple textures. Assuming you know how to calculate reflection vector using view and normal vector either per vertex of per pixel. Now use this reflection vector inside the pixel shader to look into the environment map.

To load an environment map use GL_TEXTURE_CUBE_MAP_ARB.

Share this post


Link to post
Share on other sites
Thanks for the answer...

This is with shader right?!
I see some samples just with shader in google, some in ATI and nVidia sites...

I can't like to use shaders now, I just can use the glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP); and glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);...

I'm using the vertex array to render my model, I made it to start the mult-textures:

// Metal texture
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, t_Metal);

// "Reflex" texture
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);

glBindTexture(GL_TEXTURE_2D, t_Reflex);

the problem is, where I place the glEnable(GL_TEXTURE_GEN_S); and glEnable(GL_TEXTURE_GEN_T); :-/

I made some test but the results is like I didn't start the GL_S and GL_T...

Share this post


Link to post
Share on other sites
when you call glActiveTexture( ... ), you actually need to call glClientActiveTexture( .... ) before it, and you also need to enable S and T coordinate generation; eg:


glClientActiveTexture( GL_TEXTURE0_ARB );
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, t_Metal );

// "Reflex" texture
glClientActiveTexture( GL_TEXTURE1_ARB );
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);

glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);

glBindTexture(GL_TEXTURE_2D, t_Reflex);
glEnable( GL_TEXTURE_GEN_S );
glEnable( GL_TEXTURE_GEN_T );
hope that helps..

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this