From: <sh...@pl...> - 2000-04-25 18:56:54
|
I posted this message a couple of weeks ago in comp.graphics.api.opengl, but only got one barely relevant response. So, if anyone here would like to give it a shot,l I'd be very grateful. _________________________________________ In a simulation that I'm developing, the ground is a very large polygon that's textured using a series of Mipmaps generated from a 64 X 64 rgb image using gluBuild2dMipmaps(). Both GL_WRAP_T and GL_WRAP_S are set to GL_REPEAT. The problem is that as the "eye" moves, the ground appears to be very shaky, almost as if looking down on a large tray with thousands of wriggling worms. The sequence of operations is as follows: First, I generate the texture with : /*__________________________________________________________*/ static void initex( void ) { GLboolean verdad; glDisable( GL_DITHER ); glTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL ); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_FASTEST ); glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glGenTextures( Ntex, TexObj ); /* Texture Object IDs */ /* Ground is TexObj[0] */ glBindTexture( GL_TEXTURE_2D, TexObj[0] ); verdad=LoadRGBMipmaps(ImageFile[0],GL_RGB); /* Load Mipmaps */ glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 5); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); } /*_____________________________________________________________*/ Then I bind the texture to the ground, broken up into a 100 sub-quads according to: /*_____________________________________________________________*/ Depth=50000.0; Npatches=10; TerraFirma = glGenLists(1); Patch=Depth/(GLfloat)Npatches; glNewList(TerraFirma, GL_COMPILE); glBindTexture( GL_TEXTURE_2D, TexObj[0] ); glEnable(GL_CLAMP_TO_EDGE); for(x=-Depth;x<Depth;x+=Patch){ for(z=-Depth;z<Depth;z+=Patch){ glBegin(GL_QUADS); glTexCoord2f( 0.0, 0.0 ); glVertex3f(x,0.0,z); glTexCoord2f( 1.0, 0.0 ); glVertex3f(x+Patch,0.0,z); glTexCoord2f( 1.0, 1.0 ); glVertex3f(x+Patch,0.0, z+Patch); glTexCoord2f( 0.0, 1.0 ); glVertex3f(x,0.0, z+Patch); glEnd();}} glEndList(); /*_____________________________________________________________*/ Finally, I render the ground with /*_____________________________________________________________*/ glPushMatrix(); glEnable(GL_TEXTURE_2D); glCallList(TerraFirma); glDisable(GL_TEXTURE_2D); glPopMatrix(); /*_____________________________________________________________*/ Yes, I'm aware that with the LINEAR_MIPMAP_LINEAR option, I can reduce the shimmering effect, but it slows down the simulation considerably. I've deleted what I believe to be the other non-pertinent lines of code. As I said above, the ground looks like its a very large tray of wriggling worms. If I use just one large polygon for the ground and bind the texture to it, the wriggling is marginally reduced, but the texture image is very coarse. I've also tried using 128 x 128, 256 x 256 and 512 x 512 rgb images for the ground texture, but that dosent really solve the problem. Any suggestions and fixes would be deeply appreciated and gratefully acknowledged in the (non-commercial) application that I'm trying to develop. thanks -Sharat --------------------------------------------------- Get free personalized email at http://www.iname.com |