PDA

View Full Version : Issue with glDrawBuffers when setting one of the entries to GL_NONE



RealtimeSlave
05-22-2016, 01:19 PM
Hello,

consider this simplified fragment shader

#version 150 core

out vec4 Color0;
out vec4 Color1;
out vec4 Color2;

void main(void)
{
Color0 = vec4(0.0, 0.0, 0.0, 0.3);
Color1 = vec4(0.0, 0.0, 0.0, 0.5);
Color2 = vec4(0.0, 0.0, 0.0, 0.8);
}

During shader linking the color outputs are mapped to draw buffer indices like this:

glBindFragDataLocation(Handle, 0, "Color0");
glBindFragDataLocation(Handle, 1, "Color1");
glBindFragDataLocation(Handle, 2, "Color2");

The FBO has 3 color attachments:
GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1 and GL_COLOR_ATTACHMENT2.

Before rendering with this fragment shader, glDrawBuffers is called like this:

GLenum buffers[3] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 };
glDrawBuffers(3, buffers);

=> The output is as expected, each of the 3 buffers receives the proper alpha value (also the RGB terms are the proper ones, so it is not about only the alpha part here).


But now the problem:

When I call glDrawBuffers like this (because I don't want to render to 2nd color buffer):

GLenum buffers[3] = { GL_COLOR_ATTACHMENT0, GL_NONE, GL_COLOR_ATTACHMENT2 };
glDrawBuffers(3, buffers);

=> Then nothing is rendered to the 3rd color buffer! How is that possible? Where is my mistake?

Help is really appreciated!

RealtimeSlave
06-12-2016, 08:40 AM
I cannot reproduce this issue with an NVidia card (GTX 1080), so probably this is really a driver bug?!

Firestar99
06-14-2016, 11:57 AM
I way just experimenting because of my fail understanding of glDrawBuffers and just checked your issue too.
It seems to work on my NVidia Quadro 4200M (a really crappy Notebook card in comparasion with your 1080 :))