1
votes

I would like to know how to change only one color channel and keep the 2 others color channels to their initial values.

#version 410
layout(location = 0) out vec3 color_out;
precision highp float;


void main()
{
        float z = 0.3f;
        color_out = vec3(z, my actual value , my actual value)
}

How can I retrieve the actual value or change only one channel (the red one)?

I tried this code for drawing

glColorMask(true,true ,true, true);
glDrawArrays(GL_TRIANGLES, 0, totalconnectedtriangles_);
glColorMask(true,false,false,false);

This solution works but create really strange artifacts when I move the window. Does the fragment shader take place right after glDrawArrays (after my second color mask) or during glDrawArrays ?

1
Usually you pass the color through the vertex shader,so you can use the initial colorgreedsin
So I'm forced to use a vertext shader right ?Thomas Kostas

1 Answers

4
votes

glColorMask allows you to select per channel what is updated for your fragment. So you can decide to update only R by doing glColorMask(GL_TRUE, GL_FALSE, GL_FALSE, GL_FALSE);