JOGL mipmaps and texture shimmering

非 Y 不嫁゛ 提交于 2019-12-13 05:42:28

问题


I've a wall and a brick texture in my OpenGL 2 scene that keeps shimmering and flashing no matter what I set. When I'm zoomed in close (and can see clearly the texture), then the flashing and shimmering stops. But when I'm zoomed out and moving around the scene, the flashing and shimmering is very pronounced. This is the texture code for the brick wall:

brickwall.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_S, GL2.GL_REPEAT);
brickwall.setTexParameteri(gl, GL2.GL_TEXTURE_WRAP_T, GL2.GL_REPEAT);
brickwall.setTexParameteri(gl, GL2.GL_TEXTURE_MAG_FILTER,GL2.GL_NEAREST);
brickwall.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER,GL2.GL_LINEAR);
gl.glGenerateMipmap(GL2.GL_TEXTURE_2D);

brickwall.enable(gl);
brickwall.bind(gl);
//...
brickwall.disable(gl);

From what I've googled, it seems that this is a problem that mipmapping solves. But my question is, how does one do this? Do I have to create, load and set parameters for all the various power of 2 sized images? Can anyone give me an example for loading and displaying a JOGL2 texture using mipmaps that won't flicker and shimmer zooming and moving about a scene?


回答1:


You are generating the mipmap chain with glGenerateMipmap, but you didn't set an appropiate MIN filter:

brickwall.setTexParameteri(gl, GL2.GL_TEXTURE_MIN_FILTER,GL2.GL_LINEAR_MIPMAP_LINEAR);

The *MIPMAP* filters use mipmaps, the other texture filters don't.



来源:https://stackoverflow.com/questions/5929254/jogl-mipmaps-and-texture-shimmering

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!