ecere/gfx/drivers/OpenGL: Fixed two-sided lighting
[sdk] / ecere / src / gfx / drivers / gl3 / fixed.frag
index 5d11323..0a8b92c 100644 (file)
@@ -2,14 +2,18 @@
 
 uniform sampler2D diffuseTex;
 uniform bool texturingOn;
+uniform bool lightingOn;
 uniform mat4 texture_matrix;
+uniform bool matTwoSided;
 
 in vec2 fTexCoord;
 in vec4 fColor;
+in vec4 fColorBack;
 
 out vec4 fragColor;
 
 void main(void)
 {
-   fragColor = texturingOn ? fColor * texture(diffuseTex, (vec4(fTexCoord, 0, 1) * texture_matrix).xy) : fColor;
+   vec4 c = (matTwoSided && lightingOn && !gl_FrontFacing) ? fColorBack : fColor;
+   fragColor = texturingOn ? c * texture(diffuseTex, (vec4(fTexCoord, 0, 1) * texture_matrix).xy) : c;
 }