Is using GL_NEAREST_MIPMAP_* or GL_LINEAR_MIPMAP_*

2019-07-25 17:59发布

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)?

2条回答
孤傲高冷的网名
2楼-- · 2019-07-25 18:41

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).

查看更多
萌系小妹纸
3楼-- · 2019-07-25 19:06

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.

查看更多
登录 后发表回答