Actually, my question is in header. I use "modern opengl" approach with shaders and buffers and I wonder is it exist any way to get different colors on two sides of one quad.
Desired result (back and front sides)
GLSL provides the built-in gl_FrontFacing
variable that determines if the fragment is a front-facing fragment or a back-facing fragment (is true
if front facing) e.g. if it is a fragment of the front side of the quad or a fragment of the back side of the quad.
Within the fragment shader you can then check for this variable and set the corresponding colors per face direction:
if(gl_FrontFacing)
{
outColor = color1;
}
else // Fragment is back facing fragment
{
outColor = color2;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With