Revert "internal/graphicsdriver/opengl, metal, directx: skip multiplying a scale when a color matrix is used"

This reverts commit b457dc3307.

Reason: a color scale might be used with ColorM (DrawTriangles)
This commit is contained in:
Hajime Hoshi 2022-10-02 00:18:47 +09:00
parent 520c47f0e8
commit eb3c45c8af
3 changed files with 7 additions and 3 deletions

View File

@ -221,7 +221,8 @@ float4 PSMain(PSInput input) : SV_TARGET {
color = mul(color_matrix_body, color) + color_matrix_translation;
// Premultiply alpha
color.rgb *= color.a;
// Do not apply the color scale as the scale should always be (1, 1, 1, 1) when a color matrix is used.
// Apply color scale.
color *= input.color;
// Clamp the output.
color.rgb = min(color.rgb, color.a);
return color;

View File

@ -197,6 +197,7 @@ struct FragmentShaderImpl {
c.rgb /= c.a + (1.0 - sign(c.a));
c = (color_matrix_body * c) + color_matrix_translation;
c.rgb *= c.a;
c *= v.color;
c.rgb = min(c.rgb, c.a);
} else {
c *= v.color;

View File

@ -237,12 +237,14 @@ void main(void) {
color = (color_matrix_body * color) + color_matrix_translation;
// Premultiply alpha
color.rgb *= color.a;
// Do not apply the color scale as the scale should always be (1, 1, 1, 1) when a color matrix is used.
// Apply color scale.
color *= varying_color_scale;
// Clamp the output.
color.rgb = min(color.rgb, color.a);
# else
// Apply the color scale.
// Apply color scale.
color *= varying_color_scale;
// No clamping needed as the color matrix shader is used then.
# endif // defined(USE_COLOR_MATRIX)
gl_FragColor = color;