Is using GL_NEAREST_MIPMAP_* or GL_LINEAR_MIPMAP_* for GL_TEXTURE_MIN_FILTER considered erroneous if MIP maps have not been generated?

和自甴很熟 提交于 2019-12-11 10:43:08

问题


I have a feeling this is one of those situations that will depend on the driver implementation since this scenario is not described in the OpenGL specification. However, I'm hoping that someone will know if using GL_(LINEAR/NEAREST)_ MIPMAP_* without generating MIP maps would be treated the same as using GL_(LINEAR/NEAREST)?


回答1:


Define "without any active MIP textures"? I'm not sure how you would, since there's no such thing as a "mip texture" (a texture contains mipmaps, but mipmaps are not textures).

If you mean that you did not create a full mipmap pyramid, then it depends on how you set up your GL_TEXTURE_BASE/MAX_LEVELs. If you properly used these to tell OpenGL you only had one mipmap level, then you'll be fine. If you used glTexStorage to create your texture's storage, and you only told it to create one mipmap, again you'll be fine.

But if none of those apply, then OpenGL defaults to the least useful thing (per its usual idiocy): it sets the GL_TEXTURE_MAX_LEVEL level to 1000. Which means it's going to expect you to have defined mipmaps.

According to (desktop) OpenGL, a texture with mipmap filtering where the BASE/MAX_LEVELs refer to mipmaps that are not defined is not "texture complete". OpenGL defines that the value you get for a texture access against a non-complete texture is (0, 0, 0, 1).

In short, set your BASE/MAX_LEVEL properly and you won't have to worry. ALWAYS DO THIS.




回答2:


In my experience, all the non-generated mipmap levels will default to black.

So if you have a texture displayed at 1:1 resolution, and progressively zoom out, it will fade to black as soon as the 1rst mipmap is used.

I think this is the behaviour at least on NVIDIA and AMD; I never tried on powervr (since you're mentioning opengl-es).



来源:https://stackoverflow.com/questions/12767917/is-using-gl-nearest-mipmap-or-gl-linear-mipmap-for-gl-texture-min-filter-con

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