3 struct ShadowParameters
14 ShadowParameters shadows[max_lights];
15 mat4 shd_world_matrix[max_lights];
18 uniform sampler2DShadow shadow_map;
20 layout(constant_id=auto) const bool use_shadow_map = false;
22 #pragma MSP stage(fragment)
23 virtual float get_shadow_factor(int index, vec4 world_pos)
27 int type = shadows[index].type;
31 shadow_coord = (shd_world_matrix[shadows[index].matrix_index]*world_pos).xyz;
32 shadow_coord.z -= shadows[index].bias;
37 if(shadow_coord.x<0 || shadow_coord.x>1 || shadow_coord.y<0 || shadow_coord.y>1)
40 vec4 region = shadows[index].region;
41 float shadow_sample = texture(shadow_map, vec3(shadow_coord.xy*region.zw+region.xy, shadow_coord.z));
42 return mix(1.0, shadow_sample, shadows[index].darkness);