diff options
| author | 2016-12-25 20:55:24 +0100 | |
|---|---|---|
| committer | 2016-12-25 21:37:26 +0100 | |
| commit | 88f409aec9a490138012cde35789d1f21f20818f (patch) | |
| tree | c78b28cdb8a1fa00ef094b63c26f8574c00c71c2 /src | |
| parent | Merge pull request #2366 from MerryMage/MemoryReadCode (diff) | |
| download | yuzu-88f409aec9a490138012cde35789d1f21f20818f.tar.gz yuzu-88f409aec9a490138012cde35789d1f21f20818f.tar.xz yuzu-88f409aec9a490138012cde35789d1f21f20818f.zip | |
Offset lighting LUT samples correctly
Diffstat (limited to 'src')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_shader_gen.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 8f278722d..d485ddacf 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp | |||
| @@ -423,15 +423,12 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) { | |||
| 423 | // LUT index is in the range of (0.0, 1.0) | 423 | // LUT index is in the range of (0.0, 1.0) |
| 424 | index = lighting.light[light_num].two_sided_diffuse ? "abs(" + index + ")" | 424 | index = lighting.light[light_num].two_sided_diffuse ? "abs(" + index + ")" |
| 425 | : "max(" + index + ", 0.f)"; | 425 | : "max(" + index + ", 0.f)"; |
| 426 | return "(FLOAT_255 * clamp(" + index + ", 0.0, 1.0))"; | ||
| 427 | } else { | 426 | } else { |
| 428 | // LUT index is in the range of (-1.0, 1.0) | 427 | // LUT index is in the range of (-1.0, 1.0) |
| 429 | index = "clamp(" + index + ", -1.0, 1.0)"; | 428 | index = "((" + index + " < 0) ? " + index + " + 2.0 : " + index + ") / 2.0"; |
| 430 | return "(FLOAT_255 * ((" + index + " < 0) ? " + index + " + 2.0 : " + index + | ||
| 431 | ") / 2.0)"; | ||
| 432 | } | 429 | } |
| 433 | 430 | ||
| 434 | return std::string(); | 431 | return "(OFFSET_256 + SCALE_256 * clamp(" + index + ", 0.0, 1.0))"; |
| 435 | }; | 432 | }; |
| 436 | 433 | ||
| 437 | // Gets the lighting lookup table value given the specified sampler and index | 434 | // Gets the lighting lookup table value given the specified sampler and index |
| @@ -462,7 +459,7 @@ static void WriteLighting(std::string& out, const PicaShaderConfig& config) { | |||
| 462 | if (light_config.dist_atten_enable) { | 459 | if (light_config.dist_atten_enable) { |
| 463 | std::string index = "(" + light_src + ".dist_atten_scale * length(-view - " + | 460 | std::string index = "(" + light_src + ".dist_atten_scale * length(-view - " + |
| 464 | light_src + ".position) + " + light_src + ".dist_atten_bias)"; | 461 | light_src + ".position) + " + light_src + ".dist_atten_bias)"; |
| 465 | index = "((clamp(" + index + ", 0.0, FLOAT_255)))"; | 462 | index = "(OFFSET_256 + SCALE_256 * clamp(" + index + ", 0.0, 1.0))"; |
| 466 | const unsigned lut_num = | 463 | const unsigned lut_num = |
| 467 | ((unsigned)Regs::LightingSampler::DistanceAttenuation + light_config.num); | 464 | ((unsigned)Regs::LightingSampler::DistanceAttenuation + light_config.num); |
| 468 | dist_atten = GetLutValue((Regs::LightingSampler)lut_num, index); | 465 | dist_atten = GetLutValue((Regs::LightingSampler)lut_num, index); |
| @@ -581,7 +578,10 @@ std::string GenerateFragmentShader(const PicaShaderConfig& config) { | |||
| 581 | #define NUM_TEV_STAGES 6 | 578 | #define NUM_TEV_STAGES 6 |
| 582 | #define NUM_LIGHTS 8 | 579 | #define NUM_LIGHTS 8 |
| 583 | #define LIGHTING_LUT_SIZE 256 | 580 | #define LIGHTING_LUT_SIZE 256 |
| 584 | #define FLOAT_255 (255.0 / 256.0) | 581 | |
| 582 | // Texture coordinate offsets and scales | ||
| 583 | #define OFFSET_256 (0.5 / 256.0) | ||
| 584 | #define SCALE_256 (255.0 / 256.0) | ||
| 585 | 585 | ||
| 586 | in vec4 primary_color; | 586 | in vec4 primary_color; |
| 587 | in vec2 texcoord[3]; | 587 | in vec2 texcoord[3]; |