From fcc141a32738996143bce430dd73c85050e33a0a Mon Sep 17 00:00:00 2001 From: Dwayne Slater Date: Wed, 29 Nov 2017 16:49:04 -0500 Subject: [PATCH] Maintain the PICA's 8 bits of color precision when using the interpolated primary color This matches the software renderer by using round. The actual hardware rounds the results up instead of flooring. --- src/video_core/renderer_opengl/gl_shader_gen.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/video_core/renderer_opengl/gl_shader_gen.cpp b/src/video_core/renderer_opengl/gl_shader_gen.cpp index 531247d2a..9a61c0cfc 100644 --- a/src/video_core/renderer_opengl/gl_shader_gen.cpp +++ b/src/video_core/renderer_opengl/gl_shader_gen.cpp @@ -234,7 +234,7 @@ static void AppendSource(std::string& out, const PicaShaderConfig& config, using Source = TevStageConfig::Source; switch (source) { case Source::PrimaryColor: - out += "primary_color"; + out += "rounded_primary_color"; break; case Source::PrimaryFragmentColor: out += "primary_fragment_color"; @@ -1100,8 +1100,11 @@ float LookupLightingLUTSigned(int lut_index, float pos) { if (config.state.proctex.enable) AppendProcTexSampler(out, config); + // We round the interpolated primary color to the nearest 1/255th + // This maintains the PICA's 8 bits of precision out += R"( void main() { +vec4 rounded_primary_color = round(primary_color * 255.0) / 255.0; vec4 primary_fragment_color = vec4(0.0); vec4 secondary_fragment_color = vec4(0.0); )";