mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/graphicsdriver/opengl, metal, directx: skip multiplying a scale when a color matrix is used
This commit is contained in:
parent
4203a3b68a
commit
b457dc3307
@ -221,8 +221,7 @@ float4 PSMain(PSInput input) : SV_TARGET {
|
|||||||
color = mul(color_matrix_body, color) + color_matrix_translation;
|
color = mul(color_matrix_body, color) + color_matrix_translation;
|
||||||
// Premultiply alpha
|
// Premultiply alpha
|
||||||
color.rgb *= color.a;
|
color.rgb *= color.a;
|
||||||
// Apply color scale.
|
// Do not apply the color scale as the scale should always be (1, 1, 1, 1) when a color matrix is used.
|
||||||
color *= input.color;
|
|
||||||
// Clamp the output.
|
// Clamp the output.
|
||||||
color.rgb = min(color.rgb, color.a);
|
color.rgb = min(color.rgb, color.a);
|
||||||
return color;
|
return color;
|
||||||
|
@ -197,7 +197,6 @@ struct FragmentShaderImpl {
|
|||||||
c.rgb /= c.a + (1.0 - sign(c.a));
|
c.rgb /= c.a + (1.0 - sign(c.a));
|
||||||
c = (color_matrix_body * c) + color_matrix_translation;
|
c = (color_matrix_body * c) + color_matrix_translation;
|
||||||
c.rgb *= c.a;
|
c.rgb *= c.a;
|
||||||
c *= v.color;
|
|
||||||
c.rgb = min(c.rgb, c.a);
|
c.rgb = min(c.rgb, c.a);
|
||||||
} else {
|
} else {
|
||||||
c *= v.color;
|
c *= v.color;
|
||||||
|
@ -237,14 +237,12 @@ void main(void) {
|
|||||||
color = (color_matrix_body * color) + color_matrix_translation;
|
color = (color_matrix_body * color) + color_matrix_translation;
|
||||||
// Premultiply alpha
|
// Premultiply alpha
|
||||||
color.rgb *= color.a;
|
color.rgb *= color.a;
|
||||||
// Apply color scale.
|
// Do not apply the color scale as the scale should always be (1, 1, 1, 1) when a color matrix is used.
|
||||||
color *= varying_color_scale;
|
|
||||||
// Clamp the output.
|
// Clamp the output.
|
||||||
color.rgb = min(color.rgb, color.a);
|
color.rgb = min(color.rgb, color.a);
|
||||||
# else
|
# else
|
||||||
// Apply color scale.
|
// Apply the color scale.
|
||||||
color *= varying_color_scale;
|
color *= varying_color_scale;
|
||||||
// No clamping needed as the color matrix shader is used then.
|
|
||||||
# endif // defined(USE_COLOR_MATRIX)
|
# endif // defined(USE_COLOR_MATRIX)
|
||||||
|
|
||||||
gl_FragColor = color;
|
gl_FragColor = color;
|
||||||
|
Loading…
Reference in New Issue
Block a user