if(light_sources[i].type!=0)
{
IncomingLight incoming = get_incoming_light(i, world_vertex.xyz);
- float shadow = get_shadow_factor(i);
+ float shadow = get_shadow_factor(i, world_vertex);
color += cooktorrance_one_light_direct(normal, look, incoming.direction, base_color, metalness, roughness)*incoming.color*shadow;
}
if(light_sources[i].type!=0)
{
IncomingLight incoming = get_incoming_light(i, world_vertex.xyz);
- float shadow = get_shadow_factor(i);
+ float shadow = get_shadow_factor(i, world_vertex);
color += phong_one_light(incoming.direction, normal, look, surface_diffuse, surface_specular, shininess)*incoming.color*shadow;
}
layout(constant_id=auto) const bool use_shadow_map = false;
#pragma MSP stage(fragment)
-virtual float get_shadow_factor(int index)
+virtual float get_shadow_factor(int index, vec4 world_pos)
{
if(use_shadow_map)
{
if(shadows[index].enabled==0)
return 1.0;
- vec3 shadow_coord = (shadows[index].shd_world_matrix*world_vertex).xyz;
+ vec3 shadow_coord = (shadows[index].shd_world_matrix*world_pos).xyz;
if(shadow_coord.x<0 || shadow_coord.x>1 || shadow_coord.y<0 || shadow_coord.y>1)
return 1.0;