- float shadow = get_shadow_factor(0);
- vec3 color = cooktorrance_one_light_direct(normal, look, light, light_sources[0].color, base_color, metalness, roughness)*shadow;
+ return k_diff*irradiance*base_color+k_spec*reflection;
+ }
+ else
+ return (k_diff*base_color+k_spec)*ambient_color.rgb;
+}
+
+vec3 cooktorrance_lighting(vec3 normal, vec3 look, vec3 base_color, float metalness, float roughness)
+{
+ vec3 color = vec3(0.0);
+ for(int i=0; i<max_lights; ++i)
+ if(light_sources[i].type!=0)
+ {
+ IncomingLight incoming = get_incoming_light(i, world_vertex.xyz);
+ float shadow = get_shadow_factor(i, world_vertex);
+ color += cooktorrance_one_light_direct(normal, look, incoming.direction, base_color, metalness, roughness)*incoming.color*shadow;
+ }
+
+ color += cooktorrance_environment(normal, look, base_color, metalness, roughness);