Original Post
Hi, I'm almost done with a game I'm writing. It is networked via my own custom library, has complex lighting effects, and has real physics. It occurred to me that the floor has nasty artifacts over it, but unfortunately, I'm stuck on mipmapping it. On the left, you can see the the game as it currently is, and the game after I added mipmapping:
Obviously, there are some problems here. The floor's overall color seems to have changed dramatically, and of course there are the red/green/blue artifacts near the camera. Here is the relevant texture code for mipmapping: How should I fix these problems? Thanks, Geometrian
Obviously, there are some problems here. The floor's overall color seems to have changed dramatically, and of course there are the red/green/blue artifacts near the camera. Here is the relevant texture code for mipmapping:
def Texture(surface,filters):
#surface is a pygame.Surface; in the case of the floor, filters = ["mipmap","wrap"]
texture = glGenTextures(1)
Data = pygame.image.tostring(surface,"RGBA",1)
glBindTexture(GL_TEXTURE_2D,texture)
glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,surface.get_width(),surface.get_height(),0,GL_RGBA,GL_UNSIGNED_BYTE,Data)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
if filters == None:
return texture
for f in filters:
if f == "filter":
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
elif f == "wrap":
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT)
elif f == "mipmap":
glTexEnvf( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE )
gluBuild2DMipmaps(GL_TEXTURE_2D,3,surface.get_width(),surface.get_height(),GL_RGB,GL_UNSIGNED_BYTE,Data)
if "filter" in filters:
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
else:
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST)
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST)
return texture