本文介绍了在GLSL片段着色器中,如何在特定的mipmap级别访问texel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用OpenGL通过一个顶点着色器和一个片段着色器的组合进行一些GPGPU计算.我需要对图像进行不同比例的计算.我想使用mipmap,因为它们的生成可以是自动的并且可以通过硬件加速.但是我无法访问片段着色器中的mipmap纹理.

I am using OpenGL to do some GPGPU computations through the combination of one vertex shader and one fragment shader. I need to do computations on a image at different scale. I would like to use mipmaps since their generation can be automatic and hardware accelerated. However I can't manage to get access to the mipmap textures in the fragment shader.

我启用了自动生成Mipmap的功能: glTexParameteri(GL_TEXTURE_2D,GL_GENERATE_MIPMAP,GL_TRUE);

I enabled automatic mipmap generation: glTexParameteri(GL_TEXTURE_2D, GL_GENERATE_MIPMAP, GL_TRUE);

我尝试在着色器中使用texture2DLod时没有运气,它只是一直保持正常的纹理.我还尝试在主程序中使用glTextureParameteri(GL_BASE_LEVEL,X),它没有任何改变.

I tried using texture2DLod in the shader with no luck, it simply kept giving the normal texture. I also tried using glTextureParameteri(GL_BASE_LEVEL, X) in the main program and it did not change anything.

你会怎么做?

我正在使用Linux.我的显卡是相当老的Nvidia Quadro. 这里是我的glxinfo输出,其中包含所有受支持的扩展.

I am using Linux. My graphic card is a Nvidia Quadro quite old. Here is my glxinfo output with all the supported extensions.

推荐答案

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)

您尝试过其中一种内置功能吗?另外,lod必须是浮点类型.正在报告GLSL编译器哪些错误/警告?

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

这篇关于在GLSL片段着色器中,如何在特定的mipmap级别访问texel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-12 15:26