diff options
| author | 2015-11-16 20:56:28 -0500 | |
|---|---|---|
| committer | 2016-02-05 17:17:31 -0500 | |
| commit | 603b619cbe81ba1fc4dda83dfd88d99e53c95270 (patch) | |
| tree | 020f89f4060b5bf819aaca9c9ea3d190d080dfab /src | |
| parent | renderer_opengl: Use textures for fragment shader LUTs instead of UBOs. (diff) | |
| download | yuzu-603b619cbe81ba1fc4dda83dfd88d99e53c95270.tar.gz yuzu-603b619cbe81ba1fc4dda83dfd88d99e53c95270.tar.xz yuzu-603b619cbe81ba1fc4dda83dfd88d99e53c95270.zip | |
gl_shader_gen: View vector needs to be normalized when computing half angle vector.
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index cb570c4d2..73de94457 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -368,19 +368,19 @@ vec4 secondary_fragment_color = vec4(0.0); | |||
| 368 | out += "vec3 specular_sum = vec3(0.0);\n"; | 368 | out += "vec3 specular_sum = vec3(0.0);\n"; |
| 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 += "float dist_atten = 1.0;\n"; | 372 | out += "float dist_atten = 1.0;\n"; |
| 372 | 373 | ||
| 373 | // Gets the index into the specified lookup table for specular lighting | 374 | // Gets the index into the specified lookup table for specular lighting |
| 374 | auto GetLutIndex = [&](unsigned light_num, Regs::LightingLutInput input, bool abs) { | 375 | auto GetLutIndex = [&](unsigned light_num, Regs::LightingLutInput input, bool abs) { |
| 375 | const std::string half_angle = "normalize(view + light_vector)"; | ||
| 376 | std::string index; | 376 | std::string index; |
| 377 | switch (input) { | 377 | switch (input) { |
| 378 | case Regs::LightingLutInput::NH: | 378 | case Regs::LightingLutInput::NH: |
| 379 | index = "dot(normal, " + half_angle + ")"; | 379 | index = "dot(normal, half_angle_vector)"; |
| 380 | break; | 380 | break; |
| 381 | 381 | ||
| 382 | case Regs::LightingLutInput::VH: | 382 | case Regs::LightingLutInput::VH: |
| 383 | index = std::string("dot(view, " + half_angle + ")"); | 383 | index = std::string("dot(view, half_angle_vector)"); |
| 384 | break; | 384 | break; |
| 385 | 385 | ||
| 386 | case Regs::LightingLutInput::NV: | 386 | case Regs::LightingLutInput::NV: |
| @@ -441,6 +441,7 @@ vec4 secondary_fragment_color = vec4(0.0); | |||
| 441 | out += "diffuse_sum += ((light_src[" + std::to_string(num) + "].diffuse * " + dot_product + ") + light_src[" + std::to_string(num) + "].ambient) * dist_atten;\n"; | 441 | out += "diffuse_sum += ((light_src[" + std::to_string(num) + "].diffuse * " + dot_product + ") + light_src[" + std::to_string(num) + "].ambient) * dist_atten;\n"; |
| 442 | 442 | ||
| 443 | // Compute secondary fragment color (specular lighting) function | 443 | // Compute secondary fragment color (specular lighting) function |
| 444 | out += "half_angle_vector = normalize(normalize(view) + light_vector);\n"; | ||
| 444 | std::string clamped_lut_index = GetLutIndex(num, config.lighting_lut.d0_type, config.lighting_lut.d0_abs); | 445 | std::string clamped_lut_index = GetLutIndex(num, config.lighting_lut.d0_type, config.lighting_lut.d0_abs); |
| 445 | const unsigned lut_num = (unsigned)Regs::LightingSampler::Distribution0; | 446 | const unsigned lut_num = (unsigned)Regs::LightingSampler::Distribution0; |
| 446 | std::string lut_lookup = "texture(lut[" + std::to_string(lut_num / 4) + "], " + clamped_lut_index + ")[" + std::to_string(lut_num & 3) + "]"; | 447 | std::string lut_lookup = "texture(lut[" + std::to_string(lut_num / 4) + "], " + clamped_lut_index + ")[" + std::to_string(lut_num & 3) + "]"; |