diff options
author | Weiyi Wang <wwylele@gmail.com> | 2017-08-12 00:23:45 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-08-12 00:23:45 +0200 |
commit | 7cd8a659490c556434a4a576fa596d0d7fd2d4a0 (patch) | |
tree | 9955e26a761321affbd8fcb8cca562ffde87467a | |
parent | Merge pull request #2869 from j-selby/docker-build (diff) | |
parent | gl_shader_gen: don't call SampleTexture when bump map is not used (diff) | |
download | yuzu-7cd8a659490c556434a4a576fa596d0d7fd2d4a0.tar yuzu-7cd8a659490c556434a4a576fa596d0d7fd2d4a0.tar.gz yuzu-7cd8a659490c556434a4a576fa596d0d7fd2d4a0.tar.bz2 yuzu-7cd8a659490c556434a4a576fa596d0d7fd2d4a0.tar.lz yuzu-7cd8a659490c556434a4a576fa596d0d7fd2d4a0.tar.xz yuzu-7cd8a659490c556434a4a576fa596d0d7fd2d4a0.tar.zst yuzu-7cd8a659490c556434a4a576fa596d0d7fd2d4a0.zip |
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 9 |
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) { "float geo_factor = 1.0;\n"; // Compute fragment normals and tangents - const std::string pertubation = - "2.0 * (" + SampleTexture(config, lighting.bump_selector) + ").rgb - 1.0"; + auto Perturbation = [&]() { + return "2.0 * (" + SampleTexture(config, lighting.bump_selector) + ").rgb - 1.0"; + }; if (lighting.bump_mode == LightingRegs::LightingBumpMode::NormalMap) { // Bump mapping is enabled using a normal map - out += "vec3 surface_normal = " + pertubation + ";\n"; + out += "vec3 surface_normal = " + Perturbation() + ";\n"; // Recompute Z-component of perturbation if 'renorm' is enabled, this provides a higher // precision result @@ -543,7 +544,7 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) { out += "vec3 surface_tangent = vec3(1.0, 0.0, 0.0);\n"; } else if (lighting.bump_mode == LightingRegs::LightingBumpMode::TangentMap) { // Bump mapping is enabled using a tangent map - out += "vec3 surface_tangent = " + pertubation + ";\n"; + out += "vec3 surface_tangent = " + Perturbation() + ";\n"; // Mathematically, recomputing Z-component of the tangent vector won't affect the relevant // computation below, which is also confirmed on 3DS. So we don't bother recomputing here // even if 'renorm' is enabled. |