diff options
author | bunnei <bunneidev@gmail.com> | 2015-11-20 04:42:06 +0100 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2016-02-05 23:19:16 +0100 |
commit | 0e67c21c9e5bb0e213d3b13bdd7592ff2a44a31c (patch) | |
tree | 413a8a8e30ff8a1d231b6abda32b02b54fd8f5f7 /src/video_core/renderer_opengl/gl_shader_gen.cpp | |
parent | gl_shader_gen: Add support for D0 LUT scaling. (diff) | |
download | yuzu-0e67c21c9e5bb0e213d3b13bdd7592ff2a44a31c.tar yuzu-0e67c21c9e5bb0e213d3b13bdd7592ff2a44a31c.tar.gz yuzu-0e67c21c9e5bb0e213d3b13bdd7592ff2a44a31c.tar.bz2 yuzu-0e67c21c9e5bb0e213d3b13bdd7592ff2a44a31c.tar.lz yuzu-0e67c21c9e5bb0e213d3b13bdd7592ff2a44a31c.tar.xz yuzu-0e67c21c9e5bb0e213d3b13bdd7592ff2a44a31c.tar.zst yuzu-0e67c21c9e5bb0e213d3b13bdd7592ff2a44a31c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 17 |
1 files changed, 14 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 9044a3813..4f8b675bf 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -408,15 +408,26 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) { // If enabled, clamp specular component if lighting result is negative std::string clamp_highlights = config.lighting.clamp_highlights ? "(dot(light_vector, normal) <= 0.0 ? 0.0 : 1.0)" : "1.0"; - // Lookup specular "distribution 0" LUT value + // Specular 0 component std::string d0_lut_value = "1.0"; - if (config.lighting.lut_d0.enable) { + if (config.lighting.lut_d0.enable && Pica::Regs::IsLightingSamplerSupported(config.lighting.config, Pica::Regs::LightingSampler::Distribution0)) { + // Lookup specular "distribution 0" LUT value std::string d0_lut_index = GetLutIndex(light_config.num, config.lighting.lut_d0.type, config.lighting.lut_d0.abs_input); d0_lut_value = "(" + std::to_string(config.lighting.lut_d0.scale) + " * " + GetLutValue(Regs::LightingSampler::Distribution0, d0_lut_index) + ")"; } + std::string specular_0 = "(" + d0_lut_value + " * " + light_src + ".specular_0)"; + + // Specular 1 component + std::string d1_lut_value = "1.0"; + if (config.lighting.lut_d1.enable && Pica::Regs::IsLightingSamplerSupported(config.lighting.config, Pica::Regs::LightingSampler::Distribution1)) { + // Lookup specular "distribution 1" LUT value + std::string d1_lut_index = GetLutIndex(light_config.num, config.lighting.lut_d1.type, config.lighting.lut_d1.abs_input); + d1_lut_value = "(" + std::to_string(config.lighting.lut_d1.scale) + " * " + GetLutValue(Regs::LightingSampler::Distribution1, d1_lut_index) + ")"; + } + std::string specular_1 = "(" + d1_lut_value + " * " + light_src + ".specular_1)"; // Compute secondary fragment color (specular lighting) function - out += "specular_sum += " + clamp_highlights + " * " + d0_lut_value + " * " + light_src + ".specular_0 * " + dist_atten + ";\n"; + out += "specular_sum += (" + specular_0 + " + " + specular_1 + ") * " + clamp_highlights + " * " + dist_atten + ";\n"; } // Sum final lighting result |