summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp
index bb192affd..ae67aab05 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp
@@ -525,11 +525,12 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
525 "float geo_factor = 1.0;\n"; 525 "float geo_factor = 1.0;\n";
526 526
527 // Compute fragment normals and tangents 527 // Compute fragment normals and tangents
528 const std::string pertubation = 528 auto Perturbation = [&]() {
529 "2.0 * (" + SampleTexture(config, lighting.bump_selector) + ").rgb - 1.0"; 529 return "2.0 * (" + SampleTexture(config, lighting.bump_selector) + ").rgb - 1.0";
530 };
530 if (lighting.bump_mode == LightingRegs::LightingBumpMode::NormalMap) { 531 if (lighting.bump_mode == LightingRegs::LightingBumpMode::NormalMap) {
531 // Bump mapping is enabled using a normal map 532 // Bump mapping is enabled using a normal map
532 out += "vec3 surface_normal = " + pertubation + ";\n"; 533 out += "vec3 surface_normal = " + Perturbation() + ";\n";
533 534
534 // Recompute Z-component of perturbation if 'renorm' is enabled, this provides a higher 535 // Recompute Z-component of perturbation if 'renorm' is enabled, this provides a higher
535 // precision result 536 // precision result
@@ -543,7 +544,7 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) {
543 out += "vec3 surface_tangent = vec3(1.0, 0.0, 0.0);\n"; 544 out += "vec3 surface_tangent = vec3(1.0, 0.0, 0.0);\n";
544 } else if (lighting.bump_mode == LightingRegs::LightingBumpMode::TangentMap) { 545 } else if (lighting.bump_mode == LightingRegs::LightingBumpMode::TangentMap) {
545 // Bump mapping is enabled using a tangent map 546 // Bump mapping is enabled using a tangent map
546 out += "vec3 surface_tangent = " + pertubation + ";\n"; 547 out += "vec3 surface_tangent = " + Perturbation() + ";\n";
547 // Mathematically, recomputing Z-component of the tangent vector won't affect the relevant 548 // Mathematically, recomputing Z-component of the tangent vector won't affect the relevant
548 // computation below, which is also confirmed on 3DS. So we don't bother recomputing here 549 // computation below, which is also confirmed on 3DS. So we don't bother recomputing here
549 // even if 'renorm' is enabled. 550 // even if 'renorm' is enabled.