From 68a99fd38b22d6555d24eb0d701870b8de0eb5f5 Mon Sep 17 00:00:00 2001 From: Deve Date: Sat, 11 Feb 2017 23:56:44 +0100 Subject: [PATCH] Fixed sRGB for GLES renderer. It's a bit ugly solution because we should handle it properly in one place and not add another sRGB correction... But it's already working solution and it doesn't affect the OpenGL renderer, so we can use it until better fix will be done. Now the GLES renderer looks almost the same as the original OpenGL 3.x one :) --- data/shaders/object_pass2.frag | 4 ++++ data/shaders/utils/getLightFactor.frag | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/data/shaders/object_pass2.frag b/data/shaders/object_pass2.frag index c7da60205..838570ead 100644 --- a/data/shaders/object_pass2.frag +++ b/data/shaders/object_pass2.frag @@ -40,7 +40,11 @@ void main(void) col = vec4(new_color.r, new_color.g, new_color.b, col.a); } +#ifdef GL_ES + col.xyz *= color.xyz; +#else col.xyz *= pow(color.xyz, vec3(2.2)); +#endif float specmap = texture(SpecMap, uv).g; float emitmap = texture(SpecMap, uv).b; FragColor = vec4(getLightFactor(col.xyz, vec3(1.), specmap, emitmap), 1.); diff --git a/data/shaders/utils/getLightFactor.frag b/data/shaders/utils/getLightFactor.frag index af0feed66..4fb754069 100644 --- a/data/shaders/utils/getLightFactor.frag +++ b/data/shaders/utils/getLightFactor.frag @@ -14,6 +14,10 @@ vec3 getLightFactor(vec3 diffuseMatColor, vec3 specularMatColor, float specMapVa vec3 DiffuseComponent = texture(DiffuseMap, tc).xyz; vec3 SpecularComponent = texture(SpecularMap, tc).xyz; float ao = texture(SSAO, tc).x; +#ifdef GL_ES + DiffuseComponent = pow(DiffuseComponent, vec3(1. / 2.2)); + SpecularComponent = pow(SpecularComponent, vec3(1. / 2.2)); +#endif vec3 tmp = diffuseMatColor * DiffuseComponent * (1. - specMapValue) + specularMatColor * SpecularComponent * specMapValue; vec3 emitCol = diffuseMatColor.xyz * diffuseMatColor.xyz * diffuseMatColor.xyz * 15.; return tmp * ao + (emitMapValue * emitCol);