Sign in to follow this  
Jaded

Efficient Bump Mapping - Cube Mapping & DOT3

Recommended Posts

I finally got my normalization cube map in order for my bump mapping calculations, but now I have a question concerning an efficient way to implement a bump mapping system. I am using the GL_ARB_texture_env_dot3, GL_ARB_texture_env_combine, and GL_ARB_texture_cube_map extensions to achieve bump mapping (normalization cube map dotted with normal maps). I was planning to encode the per-vertex normals into the color of the triangle and use that to dot with the normalization cube map. However, I can't seem to find a way that would allow me to use the triangle's color in the dotting operation. I would use GL_SRC_COLOR, but since DOT3 requires GL_SOURCEn_RGB you cannot make use of GL_SRC_COLOR (I'm not quite sure what GL_PRIMARY_COLOR is supposed to do, but it doesn't seem to work like you would expect GL_SRC_COLOR to). This left me with only one choice -- using a texture. I was reading the extension specification for the GL_ARB_texture_env_combine extension and it said that using GL_PREVIOUS as the param of glTexEnv when pname is GL_SOURCE0_RGB (and when GL_COMBINE is used) would reference only the previous texture object (i.e. if GL_PREVIOUS was specified for texture object 2, then it would refer to texture object 1). It says if the current texture object is 0 then if defaults to GL_PRIMARY_COLOR. I'm getting a myriad of odd results from some rather extensive testing. With all of this in mind, here are my two questions: 1) Is there a way to use the GL_ARB_texture_env_dot3 extension and DOT3 a normalization cube with the COLOR of a vertex (remember, the specification said I couldn't use GL_SRC_COLOR and GL_PRIMARY_COLOR has awkward results)? 2) If no such way exists, would storing each vertex normal in a texel of an image (the texture object directly preceding the normalization cube map, which is referenced by GL_PREVIOUS) and providing indices into that texture map be an efficient method (this prevents me from having to constantly load normal maps into the texture object preceding the cube map, except when I don't want smooth shading)? If you think of any alternative methods or advice, please share. All help will be highly appreciated.

Share this post


Link to post
Share on other sites
whats with the current wave of posts about bumpmapping at the moment?

>>I was planning to encode the per-vertex normals into the color of the triangle and use that to dot with the normalization cube map<<

this aint really gonna help u with standard bumpmapping, check out the pdf's at nvidia developer site

>> I can't seem to find a way that would allow me to use the triangle's color in the dotting operation.<<
PRIMARY color is the surrent color, eg set with glColor3f(..)

thus to do dot3 bumpmapping u just need to do

glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE );
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB_EXT, GL_DOT3_RGB );
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB_EXT, GL_PRIMARY_COLOR );
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB_EXT, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB_EXT, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB_EXT, GL_SRC_COLOR);

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