繁体   English   中英

OpenGL采样器对象未更新绑定纹理

[英]OpenGL sampler object not updating bound texture

我目前正在将采样器对象绑定到纹理单元(具体来说是GL_TEXTURE12)

glBindSampler(12, sampler)

与纹理自己的设置相比,初始设置非常明显。 但是当我用以下方式更改采样器参数时

glSamplerParameteri(sampler, GL_TEXTURE_***_FILTER, filter);

绑定到纹理单元的纹理过滤器与以前一样,但从任何角度看都没有明显变化。

我已经尝试在参数更改后再次将采样器重新绑定到纹理单元,但是我敢肯定这不是必需的。

我可以进行哪些更改以使其正常工作?

因为我无法解释为什么这样说: “我已经尝试在更改参数后再次将纹理单元重新绑定到采样器,但是我很确定这不是必需的。” 在注释中没有意义,请考虑以下C伪代码。

/* Thin state wrapper */
struct SamplerObject {
  SamplerState sampler_state;
};

/* Subsumes SamplerObject */
struct TextureObject {
  ImageData*   image_data;
  ...
  SamplerState sampler_state;
};

/* Binding point: GL4.x gives you at least 80 of these (16 per-shader stage) */
struct TextureImageUnit {
  TextureObject* bound_texture; /* Default = NULL */
  SamplerObject* bound_sampler; /* Default = NULL */
} TextureUnits [16 * 5];


vec4 texture2D ( GLuint n,
                 vec2   tex_coords )
{
  /* By default, sampler state is sourced from the bound texture object */
  SamplerState* sampler_state = &TextureUnits [n]->bound_texture->sampler_state;

  /* If there is a sampler object bound to texture unit N, use its state instead
       of the sampler state built-in to the bound texture object. */
  if (TextureUnits [n]->bound_sampler != NULL)
    sampler_state = &TextureUnits [n]->bound_sampler->sampler_state;

  ...
}

我相信混淆的根源来自于以下事实:在GLSL中,用于标识要从哪个纹理图像单元采样(以及如何sampler[...] )的制服被称为sampler[...] 希望这可以消除一些混乱,所以我们都在同一页面上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM