Opengl坏过滤器?

时间:2015-08-06 18:09:47

标签: c opengl glsl

我目前正在尝试在Linux操作系统上的C和Opengl 3中实现延迟着色。我无法弄清楚导致此渲染问题的原因: image of a red 3D tank shape with with 'glitchy' looking grey, dashed lines running across it. The image has a black background and the tank shape is sitting on a blue field.

我有一个具有以下纹理的fbo:漫反射,普通,深度,光。前三个是自我解释的,轻质地是灯光相互融合的地方。然后将这种浅色纹理与漫反射纹理结合到默认的帧缓冲区上。

我怀疑这是一个过滤问题,所以这是我的轻质纹理附件设置:

glBindTexture(GL_TEXTURE_2D, fbo->textures[FBO_LIGHT_TEXTURE]);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_FLOAT, 0);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

这实际上是一个过滤问题还是其他问题?

1 个答案:

答案 0 :(得分:0)

Wow this was a really weird bug. This was caused by my depth buffer. Basically, my light sources were somehow messing up my depth buffer. I fixed this by using glDepthMask(GL_FALSE); before rendering the lights and glDepthMask(GL_TRUE); after I was done.