In a GLSL fragment shader, how to access to texel at a specific mipmap level?

假装没事ソ 提交于 2019-12-01 05:14:28
gvec4 textureLod (gsampler1D sampler, float P, float lod)
gvec4 textureLod (gsampler2D sampler, vec2 P, float lod)
gvec4 textureLod (gsampler3D sampler, vec3 P, float lod)
gvec4 textureLod (gsamplerCube sampler, vec3 P, float lod)
float textureLod (sampler1DShadow sampler, vec3 P, float lod)
float textureLod (sampler2DShadow sampler, vec3 P, float lod)
gvec4 textureLod (gsampler1DArray sampler, vec2 P, float lod)
gvec4 textureLod (gsampler2DArray sampler, vec3 P, float lod)
float textureLod (sampler1DArrayShadow sampler, vec3 P, float lod)

Did you try one of those built-in? Also lod has to be a float type. What errors/warning is reporting GLSL compiler?

The GLSL 1.20 specification (section 8.7) states that fragment shaders cannot choose their own mipmap level (and that the texture*Lod function are only available in vertex shaders). If anything, you may be able to use the bias parameter to the non-Lod variants to change the mipmap level, but it can only change it relative to what that the card has already calculated for you.

I don't know if latter versions of GLSL may have changed that.

Digi

try:

glGenerateMipmapEXT(GL_TEXTURE_2D);

after you bind the texture. (And before doing the rendering of course)

The glTexParameteri-GL_GENERATE_MIPMAP is deprecated I think... MfG Digi

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