diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2019-12-21 23:40:15 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-21 23:40:15 +0100 |
commit | e21872f4b9798c14b2840f205eff7aa931f02c0d (patch) | |
tree | 8d47fbb0dc3c7a2c51a63813e33dc4c9d8381174 | |
parent | ecdfeec513695e53ca59ff22756c7fbbf2ca8514 (diff) | |
parent | d47374385c0f21c3e76adb75c2954eb8da8178e1 (diff) |
Merge pull request #34527 from MadEqua/fix-gles3-light-cutoff
Fix GLES3 light cutoff.
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index f16f798ac5..63b2938551 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -1258,7 +1258,12 @@ void light_process_omni(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi vec3 light_rel_vec = omni_lights[idx].light_pos_inv_radius.xyz - vertex; float light_length = length(light_rel_vec); float normalized_distance = light_length * omni_lights[idx].light_pos_inv_radius.w; - float omni_attenuation = pow(max(1.0 - normalized_distance, 0.0), omni_lights[idx].light_direction_attenuation.w); + float omni_attenuation; + if (normalized_distance < 1.0) { + omni_attenuation = pow(normalized_distance, omni_lights[idx].light_direction_attenuation.w); + } else { + omni_attenuation = 0.0; + } vec3 light_attenuation = vec3(omni_attenuation); #if !defined(SHADOWS_DISABLED) @@ -1317,7 +1322,12 @@ void light_process_spot(int idx, vec3 vertex, vec3 eye_vec, vec3 normal, vec3 bi vec3 light_rel_vec = spot_lights[idx].light_pos_inv_radius.xyz - vertex; float light_length = length(light_rel_vec); float normalized_distance = light_length * spot_lights[idx].light_pos_inv_radius.w; - float spot_attenuation = pow(max(1.0 - normalized_distance, 0.001), spot_lights[idx].light_direction_attenuation.w); + float spot_attenuation; + if (normalized_distance < 1.0) { + spot_attenuation = pow(1.0 - normalized_distance, spot_lights[idx].light_direction_attenuation.w); + } else { + spot_attenuation = 0.0; + } vec3 spot_dir = spot_lights[idx].light_direction_attenuation.xyz; float spot_cutoff = spot_lights[idx].light_params.y; float scos = max(dot(-normalize(light_rel_vec), spot_dir), spot_cutoff); |