X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=shaderlib%2Fcooktorrance.glsl;h=2a03e2c51c049095ca23a23dbefbdc432e2d40e0;hb=55e3f2d494d939280a4ea48676fd17ca2342b457;hp=02d697b087c640572a2ed0ebad15fe655ff4f1d2;hpb=47fa42594ef79dfe8c95edeeda11e9a9492e35bf;p=libs%2Fgl.git diff --git a/shaderlib/cooktorrance.glsl b/shaderlib/cooktorrance.glsl index 02d697b0..2a03e2c5 100644 --- a/shaderlib/cooktorrance.glsl +++ b/shaderlib/cooktorrance.glsl @@ -127,8 +127,8 @@ vec3 cooktorrance_one_light_direct(vec3 normal, vec3 look, vec3 light, vec3 ligh vec3 k_spec = fresnel_schlick(halfway, light, base_color, metalness); vec3 k_diff = (1.0-k_spec)*(1.0-metalness); - float denom = max(4.0*max(dot(normal, -look), 0.0)*max(dot(normal, light), 0.0), 0.001); - return max(dot(normal, light), 0.0)*light_color*(k_diff*lambert_diffuse(base_color)+k_spec*ndist*geom/denom); + float spec_denom = max(4.0*max(dot(normal, -look), 0.0)*max(dot(normal, light), 0.0), 0.001); + return max(dot(normal, light), 0.0)*light_color*(k_diff*lambert_diffuse(base_color)+k_spec*ndist*geom/spec_denom); } vec3 cooktorrance_lighting(vec3 normal, vec3 look, vec3 base_color, float metalness, float roughness) @@ -140,7 +140,7 @@ vec3 cooktorrance_lighting(vec3 normal, vec3 look, vec3 base_color, float metaln light = normalize(eye_light_dir); float shadow = get_shadow_factor(0); - vec3 color = cooktorrance_one_light_direct(normal, look, light, light_sources[0].diffuse.rgb, base_color, metalness, roughness)*shadow; + vec3 color = cooktorrance_one_light_direct(normal, look, light, light_sources[0].color, base_color, metalness, roughness)*shadow; color *= get_occlusion_value();