gpt4 book ai didi

c - OpenGL 采样器对象不更新绑定(bind)纹理

转载 作者:行者123 更新时间:2023-11-30 15:40:59 25 4
gpt4 key购买 nike

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

glBindSampler(12,采样器)

与纹理本身的设置相比,初始设置非常明显。但是当我用

更改采样器参数时

glSamplerParameteri(采样器, GL_TEXTURE_***_FILTER, 过滤器);

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

我尝试在参数更改后再次将采样器重新绑定(bind)到纹理单元,但我很确定这不是必需的。

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

最佳答案

因为我无法解释为什么这个语句:“我尝试在参数更改后再次将纹理单元重新绑定(bind)到采样器,但我很确定这不是必需的。” 注释中没有任何意义,请考虑以下 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[...]。希望这能消除一些困惑,以便我们达成共识。

关于c - OpenGL 采样器对象不更新绑定(bind)纹理,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20723709/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com