Standard shader: Fix some precision issues in GLES;
@@ -152,6 +152,12 @@ const char* lovrStandardVertexShader = ""
const char* lovrStandardFragmentShader = ""
"#define PI 3.14159265358979 \n"
+"#ifdef GL_ES \n"
+"#define EPS 1e-2 \n"
+"#else \n"
+"#define EPS 1e-5 \n"
+"#endif \n"
+
"in vec3 vVertexPositionWorld; \n"
"in vec3 vCameraPositionWorld; \n"
"#ifdef FLAG_normalTexture \n"
@@ -189,7 +195,7 @@ const char* lovrStandardFragmentShader = ""
" vec3 L = normalize(-lovrLightDirection); \n"
" vec3 H = normalize(V + L); \n"
" vec3 R = normalize(reflect(-V, N)); \n"
-" float NoV = abs(dot(N, V)) + 1e-2; \n"
+" float NoV = abs(dot(N, V)) + EPS; \n"
" float NoL = clamp(dot(N, L), 0., 1.); \n"
" float NoH = clamp(dot(N, H), 0., 1.); \n"
" float VoH = clamp(dot(V, H), 0., 1.); \n"
@@ -241,7 +247,7 @@ const char* lovrStandardFragmentShader = ""
" float alpha2 = alpha * alpha; \n"
" float GGXV = NoL * sqrt(alpha2 + (1. - alpha2) * (NoV * NoV)); \n"
" float GGXL = NoV * sqrt(alpha2 + (1. - alpha2) * (NoL * NoL)); \n"
-" return .5 / max(GGXV + GGXL, 1e-5); \n"
+" return .5 / max(GGXV + GGXL, EPS); \n"
"} \n"
"vec3 F_Schlick(vec3 F0, float VoH) { \n"
