【发布时间】:2021-01-04 04:02:10
【问题描述】:
我正在尝试渲染附加到帧缓冲区的单通道纹理,但它不起作用。我使用大小格式创建纹理:
glCreateTextures(GL_TEXTURE_2D, 1, &entityTexture);
glTextureStorage2D(entityTexture, 1, GL_R32F, viewport.size.x, viewport.size.y);
glTextureParameteri(entityTexture, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTextureParameteri(entityTexture, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
更新:然后我将它与其他一些附加到我的帧缓冲区:
std::array<GLenum, 4> colorAttachments = {
GL_COLOR_ATTACHMENT0,
GL_COLOR_ATTACHMENT1,
GL_COLOR_ATTACHMENT2,
GL_COLOR_ATTACHMENT3,
};
glNamedFramebufferDrawBuffers(GBuffer, static_cast<GLsizei>(colorAttachments.size()), colorAttachments.data());
在着色器内部我写在上面:
layout(location = 0) out vec4 gNormal;
layout(location = 1) out vec4 gColor;
layout(location = 2) out vec4 gMetallicRoughness;
layout(location = 3) out float gEntityID;
然后在片段着色器中写入一些随机测试值(绘制一堆网格):
gEntityID = 12.3;
当我签入 RenderDoc 时,图像变成黑色,值为 0。所有这些都检查 API 使用情况吗?
【问题讨论】: