summaryrefslogtreecommitdiff
path: root/drivers/gles2/shaders
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-09-23 18:23:58 +0200
committerRémi Verschelde <rverschelde@gmail.com>2018-09-23 18:26:57 +0200
commit60312915dc9c52d8dbf2b5cd6d28a9fcde92840e (patch)
treef0e3b0e37009ef686a0031a8d756cca793587f4a /drivers/gles2/shaders
parent75e44badba566748300eb8473b56af542effa8f3 (diff)
Fix build after 65fd37c1, using Math_PI
Also fix style in shaders.
Diffstat (limited to 'drivers/gles2/shaders')
-rw-r--r--drivers/gles2/shaders/scene.glsl67
1 files changed, 21 insertions, 46 deletions
diff --git a/drivers/gles2/shaders/scene.glsl b/drivers/gles2/shaders/scene.glsl
index fa8063b3dd..da4c3a84f1 100644
--- a/drivers/gles2/shaders/scene.glsl
+++ b/drivers/gles2/shaders/scene.glsl
@@ -135,7 +135,6 @@ uniform highp sampler2D light_directional_shadow; // texunit:-3
uniform highp vec4 light_split_offsets;
#endif
-
uniform highp mat4 light_shadow_matrix;
varying highp vec4 shadow_coord;
@@ -155,7 +154,6 @@ varying highp vec4 shadow_coord4;
#endif
-
#if defined(USE_VERTEX_LIGHTING) && defined(USE_LIGHTING)
varying highp vec3 diffuse_interp;
@@ -206,7 +204,6 @@ void light_compute(
float NdotV = dot(N, V);
float cNdotV = max(NdotV, 0.0);
-
#if defined(DIFFUSE_OREN_NAYAR)
vec3 diffuse_brdf_NL;
#else
@@ -214,7 +211,7 @@ void light_compute(
#endif
#if defined(DIFFUSE_LAMBERT_WRAP)
- // energy conserving lambert wrap shader
+ // energy conserving lambert wrap shader
diffuse_brdf_NL = max(0.0, (NdotL + roughness) / ((1.0 + roughness) * (1.0 + roughness)));
#elif defined(DIFFUSE_OREN_NAYAR)
@@ -233,7 +230,7 @@ void light_compute(
diffuse_brdf_NL = cNdotL * (A + vec3(B) * s / t) * (1.0 / M_PI);
}
#else
- // lambert by default for everything else
+ // lambert by default for everything else
diffuse_brdf_NL = cNdotL * (1.0 / M_PI);
#endif
@@ -241,8 +238,6 @@ void light_compute(
diffuse_interp += light_color * diffuse_brdf_NL * attenuation;
-
-
if (roughness > 0.0) {
// D
@@ -254,17 +249,15 @@ void light_compute(
float cNdotH = max(dot(N, H), 0.0);
float cVdotH = max(dot(V, H), 0.0);
float cLdotH = max(dot(L, H), 0.0);
- float shininess = exp2( 15.0 * (1.0 - roughness) + 1.0 ) * 0.25;
- float blinn = pow( cNdotH, shininess );
+ float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
+ float blinn = pow(cNdotH, shininess);
blinn *= (shininess + 8.0) / (8.0 * 3.141592654);
- specular_brdf_NL = ( blinn ) / max( 4.0 * cNdotV * cNdotL, 0.75 );
+ specular_brdf_NL = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75);
#endif
SRGB_APPROX(specular_brdf_NL)
specular_interp += specular_brdf_NL * light_color * attenuation;
-
}
-
}
#endif
@@ -364,7 +357,6 @@ void main() {
mat4 modelview = camera_matrix * world_matrix;
float roughness = 1.0;
-
#define world_transform world_matrix
{
@@ -434,7 +426,6 @@ VERTEX_SHADER_CODE
#endif //depth
-
//vertex lighting
#if defined(USE_VERTEX_LIGHTING) && defined(USE_LIGHTING)
//vertex shaded version of lighting (more limited)
@@ -450,7 +441,7 @@ VERTEX_SHADER_CODE
float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation.w);
vec3 attenuation = vec3(omni_attenuation);
- light_att=vec3(omni_attenuation);
+ light_att = vec3(omni_attenuation);
L = normalize(light_vec);
@@ -485,14 +476,14 @@ VERTEX_SHADER_CODE
diffuse_interp = vec3(0.0);
specular_interp = vec3(0.0);
- light_compute(normal_interp,L,-normalize(vertex_interp),light_color.rgb,light_att,roughness);
+ light_compute(normal_interp, L, -normalize(vertex_interp), light_color.rgb, light_att, roughness);
#endif
//shadows (for both vertex and fragment)
#if defined(USE_SHADOW) && defined(USE_LIGHTING)
- vec4 vi4 = vec4(vertex_interp,1.0);
+ vec4 vi4 = vec4(vertex_interp, 1.0);
shadow_coord = light_shadow_matrix * vi4;
#if defined(LIGHT_USE_PSSM2) || defined(LIGHT_USE_PSSM4)
@@ -616,7 +607,6 @@ uniform highp sampler2D light_directional_shadow; // texunit:-3
uniform highp vec4 light_split_offsets;
#endif
-
varying highp vec4 shadow_coord;
#if defined(LIGHT_USE_PSSM2) || defined(LIGHT_USE_PSSM4)
@@ -684,7 +674,6 @@ varying highp float dp_clip;
#ifdef USE_LIGHTING
-
// This returns the G_GGX function divided by 2 cos_theta_m, where in practice cos_theta_m is either N.L or N.V.
// We're dividing this factor off because the overall term we'll end up looks like
// (see, for example, the first unnumbered equation in B. Burley, "Physically Based Shading at Disney", SIGGRAPH 2012):
@@ -890,21 +879,19 @@ LIGHT_SHADER_CODE
float cNdotH = max(dot(N, H), 0.0);
float cVdotH = max(dot(V, H), 0.0);
float cLdotH = max(dot(L, H), 0.0);
- float shininess = exp2( 15.0 * (1.0 - roughness) + 1.0 ) * 0.25;
- float blinn = pow( cNdotH, shininess );
+ float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
+ float blinn = pow(cNdotH, shininess);
blinn *= (shininess + 8.0) / (8.0 * 3.141592654);
- specular_brdf_NL = ( blinn ) / max( 4.0 * cNdotV * cNdotL, 0.75 );
+ specular_brdf_NL = (blinn) / max(4.0 * cNdotV * cNdotL, 0.75);
#elif defined(SPECULAR_PHONG)
vec3 R = normalize(-reflect(L, N));
float cRdotV = max(0.0, dot(R, V));
- float shininess = exp2( 15.0 * (1.0 - roughness) + 1.0 ) * 0.25;
- float phong = pow( cRdotV, shininess );
+ float shininess = exp2(15.0 * (1.0 - roughness) + 1.0) * 0.25;
+ float phong = pow(cRdotV, shininess);
phong *= (shininess + 8.0) / (8.0 * 3.141592654);
- specular_brdf_NL = ( phong ) / max( 4.0 * cNdotV * cNdotL, 0.75 );
-
-
+ specular_brdf_NL = (phong) / max(4.0 * cNdotV * cNdotL, 0.75);
#elif defined(SPECULAR_TOON)
@@ -954,7 +941,6 @@ LIGHT_SHADER_CODE
SRGB_APPROX(specular_brdf_NL)
specular_light += specular_brdf_NL * light_color * specular_blob_intensity * attenuation;
-
#if defined(LIGHT_USE_CLEARCOAT)
if (clearcoat_gloss > 0.0) {
#if !defined(SPECULAR_SCHLICK_GGX) && !defined(SPECULAR_BLINN)
@@ -976,9 +962,7 @@ LIGHT_SHADER_CODE
#endif
}
-
#endif //defined(USE_LIGHT_SHADER_CODE)
-
}
#endif
@@ -986,14 +970,13 @@ LIGHT_SHADER_CODE
#ifdef USE_SHADOW
-#define SAMPLE_SHADOW_TEXEL(p_shadow,p_pos,p_depth) step(p_depth,texture2D(p_shadow,p_pos).r)
+#define SAMPLE_SHADOW_TEXEL(p_shadow, p_pos, p_depth) step(p_depth, texture2D(p_shadow, p_pos).r)
float sample_shadow(
highp sampler2D shadow,
highp vec2 pos,
highp float depth) {
-
#ifdef SHADOW_MODE_PCF_13
float avg = SAMPLE_SHADOW_TEXEL(shadow, pos, depth);
@@ -1027,7 +1010,6 @@ float sample_shadow(
return SAMPLE_SHADOW_TEXEL(shadow, pos, depth);
#endif
-
}
#endif
@@ -1151,7 +1133,7 @@ FRAGMENT_SHADER_CODE
#ifndef USE_VERTEX_LIGHTING
vec3 L;
#endif
- vec3 light_att=vec3(1.0);
+ vec3 light_att = vec3(1.0);
#ifdef LIGHT_MODE_OMNI
@@ -1163,7 +1145,7 @@ FRAGMENT_SHADER_CODE
float omni_attenuation = pow(1.0 - normalized_distance, light_attenuation.w);
- light_att=vec3(omni_attenuation);
+ light_att = vec3(omni_attenuation);
L = normalize(light_vec);
#endif
@@ -1193,8 +1175,7 @@ FRAGMENT_SHADER_CODE
float shadow = sample_shadow(light_shadow_atlas, splane.xy, splane.z);
- light_att*=shadow;
-
+ light_att *= shadow;
}
#endif
@@ -1318,12 +1299,10 @@ FRAGMENT_SHADER_CODE
}
#endif //use shadow
-
#endif
#ifdef LIGHT_MODE_SPOT
-
light_att = vec3(1.0);
#ifndef USE_VERTEX_LIGHTING
@@ -1358,18 +1337,16 @@ FRAGMENT_SHADER_CODE
}
#endif
-
-
#endif
#ifdef USE_VERTEX_LIGHTING
-//vertex lighting
+ //vertex lighting
specular_light += specular_interp * specular * light_att;
diffuse_light += diffuse_interp * albedo * light_att;
#else
-//fragment lighting
+ //fragment lighting
light_compute(
normal,
L,
@@ -1394,7 +1371,7 @@ FRAGMENT_SHADER_CODE
#endif //vertex lighting
#endif //USE_LIGHTING
-//compute and merge
+ //compute and merge
#ifndef RENDER_DEPTH
@@ -1435,7 +1412,5 @@ FRAGMENT_SHADER_CODE
#endif //unshaded
-
#endif // not RENDER_DEPTH
-
}