* Shadow fadeout exponent hardcoded for now, should be user configurable. * optimization - skip shadows outside visible range
This commit is contained in:
parent
1d2743302f
commit
0b12ebba11
@ -5456,9 +5456,16 @@ void RasterizerGLES2::_setup_light(uint16_t p_light) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
light_data[VL_LIGHT_ATTENUATION][0]=l->vars[VS::LIGHT_PARAM_ENERGY];
|
light_data[VL_LIGHT_ATTENUATION][0] = l->vars[VS::LIGHT_PARAM_ENERGY];
|
||||||
light_data[VL_LIGHT_ATTENUATION][1]=l->vars[VS::LIGHT_PARAM_RADIUS];
|
|
||||||
light_data[VL_LIGHT_ATTENUATION][2]=l->vars[VS::LIGHT_PARAM_ATTENUATION];
|
if (l->type == VS::LIGHT_DIRECTIONAL) {
|
||||||
|
light_data[VL_LIGHT_ATTENUATION][1] = l->directional_shadow_param[VS::LIGHT_DIRECTIONAL_SHADOW_PARAM_MAX_DISTANCE];
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
light_data[VL_LIGHT_ATTENUATION][1] = l->vars[VS::LIGHT_PARAM_RADIUS];
|
||||||
|
}
|
||||||
|
|
||||||
|
light_data[VL_LIGHT_ATTENUATION][2] = l->vars[VS::LIGHT_PARAM_ATTENUATION];
|
||||||
|
|
||||||
light_data[VL_LIGHT_SPOT_ATTENUATION][0]=Math::cos(Math::deg2rad(l->vars[VS::LIGHT_PARAM_SPOT_ANGLE]));
|
light_data[VL_LIGHT_SPOT_ATTENUATION][0]=Math::cos(Math::deg2rad(l->vars[VS::LIGHT_PARAM_SPOT_ANGLE]));
|
||||||
light_data[VL_LIGHT_SPOT_ATTENUATION][1]=l->vars[VS::LIGHT_PARAM_SPOT_ATTENUATION];
|
light_data[VL_LIGHT_SPOT_ATTENUATION][1]=l->vars[VS::LIGHT_PARAM_SPOT_ATTENUATION];
|
||||||
|
@ -980,6 +980,12 @@ FRAGMENT_SHADER_CODE
|
|||||||
#ifdef LIGHT_USE_SHADOW
|
#ifdef LIGHT_USE_SHADOW
|
||||||
#ifdef LIGHT_TYPE_DIRECTIONAL
|
#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
|
#ifdef LIGHT_USE_PSSM
|
||||||
|
|
||||||
|
|
||||||
@ -1105,6 +1111,12 @@ FRAGMENT_SHADER_CODE
|
|||||||
|
|
||||||
shadow_attenuation=SAMPLE_SHADOW_TEX(shadow_coord.xy,shadow_coord.z);
|
shadow_attenuation=SAMPLE_SHADOW_TEX(shadow_coord.xy,shadow_coord.z);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
shadow_attenuation=mix(shadow_attenuation,1.0,shadow_fade);
|
||||||
|
}else{
|
||||||
|
shadow_attenuation=1.0;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef LIGHT_TYPE_OMNI
|
#ifdef LIGHT_TYPE_OMNI
|
||||||
|
Loading…
Reference in New Issue
Block a user