Jake
2004.11.01, 07:31 PM
After creating a fast terrain engine that dynamically makes a 10000 triangle level of detail terrain out of a 1024x1024 16 bit height map, I have had some problems texturing it. I eventually came to this tutorial http://www.cs.auckland.ac.nz/~jvan006/multitex/multitex.html that uses dot3 and 2 texture units for 4 detail textures (one per channel) mixed over a RGB lightmap.
Here is how it SHOULD work
1. glColor3f is used to get the weights of each detail texture (R,G,B)
2. glColor3f dot3 detail texture = Texture Unit 0
3. Texture Unit 0 * Texture Unit 1 (lightmap) = Final value
Here is how mine is working
1. X,Y Pixel value of texture zero is used to get the weights of each detail texture (R,G,B)
2.X,Y Pixel value of texture zero dot3 detail texture = Texture Unit 0
3. Texture Unit 0 * Texture Unit 1 (lightmap) = Final value
So basically my problem is that the X,Y Pixel value of texture zero is being used instead of glColor3f. Can someone tell me whats wrong with this code?
glActiveTexture(GL_TEXTURE0);
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, gv->texture[tdetail] );
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glActiveTexture(GL_TEXTURE1);
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, gv->texture[theightmap] );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_ONE_MINUS_SRC_COLOR);
Thanks!
Here is how it SHOULD work
1. glColor3f is used to get the weights of each detail texture (R,G,B)
2. glColor3f dot3 detail texture = Texture Unit 0
3. Texture Unit 0 * Texture Unit 1 (lightmap) = Final value
Here is how mine is working
1. X,Y Pixel value of texture zero is used to get the weights of each detail texture (R,G,B)
2.X,Y Pixel value of texture zero dot3 detail texture = Texture Unit 0
3. Texture Unit 0 * Texture Unit 1 (lightmap) = Final value
So basically my problem is that the X,Y Pixel value of texture zero is being used instead of glColor3f. Can someone tell me whats wrong with this code?
glActiveTexture(GL_TEXTURE0);
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, gv->texture[tdetail] );
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_DOT3_RGB);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_PRIMARY_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_SRC_COLOR);
glActiveTexture(GL_TEXTURE1);
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, gv->texture[theightmap] );
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_MODULATE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_TEXTURE1);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND0_RGB, GL_SRC_COLOR);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE0);
glTexEnvi(GL_TEXTURE_ENV, GL_OPERAND1_RGB, GL_ONE_MINUS_SRC_COLOR);
Thanks!