diff options
Diffstat (limited to 'drivers/gles2/shaders/material.glsl')
-rw-r--r-- | drivers/gles2/shaders/material.glsl | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/drivers/gles2/shaders/material.glsl b/drivers/gles2/shaders/material.glsl index 477a451f2f..e5be25757d 100644 --- a/drivers/gles2/shaders/material.glsl +++ b/drivers/gles2/shaders/material.glsl @@ -980,6 +980,12 @@ FRAGMENT_SHADER_CODE #ifdef LIGHT_USE_SHADOW #ifdef LIGHT_TYPE_DIRECTIONAL + float shadow_fade_exponent=5.0; //hardcoded for now + float shadow_fade=pow(length(vertex_interp)/light_attenuation.g,shadow_fade_exponent); + +// optimization - skip shadows outside visible range + if(shadow_fade<1.0){ + #ifdef LIGHT_USE_PSSM @@ -1105,6 +1111,12 @@ FRAGMENT_SHADER_CODE shadow_attenuation=SAMPLE_SHADOW_TEX(shadow_coord.xy,shadow_coord.z); #endif + + shadow_attenuation=mix(shadow_attenuation,1.0,shadow_fade); + }else{ + shadow_attenuation=1.0; + }; + #endif #ifdef LIGHT_TYPE_OMNI |