Original Post
Hi all. I thought my terrain generation was going well until I added volumetric fog. I have progressed to procedural texturing and multi-texturing and the results were quite good, but when I added fog a number of annomalies showed up in my rendering. Here is a shot of the terrain with and without fog:
I really didnt see these problems with the terrain without fog, but now I have started zooming in and scrutinize the terrain, it looks as if there might be a problem, but I wonder if it's actually something to do with the way I configure the fog. eg. Per vertex fog works only cw, but I am rendering ccw - or something like that. Any ideas? btw. I am following examples in the Trent Polack book for the techniques. Here is my render routine: [Edited by - Fahrenheit451 on January 7, 2006 10:24:15 AM]
I really didnt see these problems with the terrain without fog, but now I have started zooming in and scrutinize the terrain, it looks as if there might be a problem, but I wonder if it's actually something to do with the way I configure the fog. eg. Per vertex fog works only cw, but I am rendering ccw - or something like that. Any ideas? btw. I am following examples in the Trent Polack book for the techniques. Here is my render routine:
// draw terrain mesh
// multi texturing
//bind the primary color texture to the first texture unit
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, m_texture.GetID() );
//bind the appropriate detail color texture to the second texture unit
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, detail.GetID() );
float a,b,c,d;
for ( int row = 0; row < (terrain.size-1); row++ ) {
// draw triangle strip
glBegin(GL_TRIANGLE_STRIP);
for ( int col = 0; col < terrain.size; col++ ) {
// caclulate texture coordinates
a = (float)row/terrain.size;
b = (float)col/terrain.size;
c = (float)(row+1)/terrain.size;
d = (float)(col+1)/terrain.size;
// set normal
glNormal3f(terrain.CNormal[row][col].x,terrain.CNormal[row][col].y,terrain.CNormal[row][col].z);
if ( terrain.volumetricFog ) {
// Set the fog coordinate for this vertex
SetFogCoord(terrain.vfogHeight, terrain.CPoint[row][col].y);
}
if ( terrain.textureMode ) {
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, a, b );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, a*terrain.detailRepeat, b*terrain.detailRepeat );
}
glVertex3f(terrain.CPoint[row][col].x*terrain.scale,terrain.CPoint[row][col].y*terrain.scale,terrain.CPoint[row][col].z*terrain.scale);
if ( !terrain.PPNormal )
glNormal3f(terrain.CNormal[row+1][col].x,terrain.CNormal[row+1][col].y,terrain.CNormal[row+1][col].z);
if ( terrain.volumetricFog ) {
// Set the fog coordinate for this vertex
SetFogCoord(terrain.vfogHeight, terrain.CPoint[row][col].y);
}
if ( terrain.textureMode ) {
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, c, b );
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, c*terrain.detailRepeat, b*terrain.detailRepeat );
}
glVertex3f(terrain.CPoint[row+1][col].x*terrain.scale,terrain.CPoint[row+1][col].y*terrain.scale,terrain.CPoint[row+1][col].z*terrain.scale);
}
glEnd();
}
//unbind the texture occupying the second texture unit
glActiveTextureARB( GL_TEXTURE1_ARB );
glDisable( GL_TEXTURE_2D );
//unbind the texture occupying the first texture unit
glActiveTextureARB( GL_TEXTURE0_ARB );
glDisable( GL_TEXTURE_2D );