summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar bunnei2015-11-18 21:14:50 -0500
committerGravatar bunnei2016-02-05 17:17:32 -0500
commitbdc72d090458ab8af288304463ea75e975f1327d (patch)
treec2b16e1c2ffaeee3a00037cdc153ebb4b785e13f
parentgl_shader_gen: View vector needs to be normalized when computing half angle v... (diff)
downloadyuzu-bdc72d090458ab8af288304463ea75e975f1327d.tar.gz
yuzu-bdc72d090458ab8af288304463ea75e975f1327d.tar.xz
yuzu-bdc72d090458ab8af288304463ea75e975f1327d.zip
gl_shader_gen: Fix bug with lighting where clamp highlights was only applied to last light.
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index 73de94457..7821170db 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -369,6 +369,7 @@ vec4 secondary_fragment_color = vec4(0.0);
369 out += "vec3 fragment_position = -view;\n"; 369 out += "vec3 fragment_position = -view;\n";
370 out += "vec3 light_vector = vec3(0.0);\n"; 370 out += "vec3 light_vector = vec3(0.0);\n";
371 out += "vec3 half_angle_vector = vec3(0.0);\n"; 371 out += "vec3 half_angle_vector = vec3(0.0);\n";
372 out += "float clamp_highlights = 1.0;\n";
372 out += "float dist_atten = 1.0;\n"; 373 out += "float dist_atten = 1.0;\n";
373 374
374 // Gets the index into the specified lookup table for specular lighting 375 // Gets the index into the specified lookup table for specular lighting
@@ -446,17 +447,16 @@ vec4 secondary_fragment_color = vec4(0.0);
446 const unsigned lut_num = (unsigned)Regs::LightingSampler::Distribution0; 447 const unsigned lut_num = (unsigned)Regs::LightingSampler::Distribution0;
447 std::string lut_lookup = "texture(lut[" + std::to_string(lut_num / 4) + "], " + clamped_lut_index + ")[" + std::to_string(lut_num & 3) + "]"; 448 std::string lut_lookup = "texture(lut[" + std::to_string(lut_num / 4) + "], " + clamped_lut_index + ")[" + std::to_string(lut_num & 3) + "]";
448 449
449 out += "specular_sum += (" + lut_lookup + " * light_src[" + std::to_string(num) + "].specular_0 * dist_atten);\n"; 450 if (config.clamp_highlights) {
450 } 451 out += "clamp_highlights = (dot(light_vector, normal) <= 0.0) ? 0.0 : 1.0;\n";
452 }
451 453
452 out += "float clamp_highlights = 1.0;\n"; 454 out += "specular_sum += clamp_highlights * " + lut_lookup + " * light_src[" + std::to_string(num) + "].specular_0 * dist_atten;\n";
453 if (config.clamp_highlights) {
454 out += "if (dot(light_vector, normal) <= 0.0) clamp_highlights = 0.0;\n";
455 } 455 }
456 456
457 out += "diffuse_sum += lighting_global_ambient;\n"; 457 out += "diffuse_sum += lighting_global_ambient;\n";
458 out += "primary_fragment_color = vec4(clamp(diffuse_sum, vec3(0.0), vec3(1.0)), 1.0);\n"; 458 out += "primary_fragment_color = vec4(clamp(diffuse_sum, vec3(0.0), vec3(1.0)), 1.0);\n";
459 out += "secondary_fragment_color = vec4(clamp(clamp_highlights * specular_sum, vec3(0.0), vec3(1.0)), 1.0);\n"; 459 out += "secondary_fragment_color = vec4(clamp(specular_sum, vec3(0.0), vec3(1.0)), 1.0);\n";
460 } 460 }
461 461
462 // Do not do any sort of processing if it's obvious we're not going to pass the alpha test 462 // Do not do any sort of processing if it's obvious we're not going to pass the alpha test