mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
graphicsdriver: Simplify clamping color values
For negative values, OpenGL (and Metal) should take care of them so we don't have to care.
This commit is contained in:
parent
3d8a45a770
commit
742bbb4ccd
@ -206,13 +206,12 @@ float4 FragmentShaderImpl(
|
||||
c.rgb /= c.a + (1.0 - sign(c.a));
|
||||
c = (color_matrix_body * c) + color_matrix_translation;
|
||||
c *= v.color;
|
||||
c = clamp(c, 0.0, 1.0);
|
||||
c.rgb *= c.a;
|
||||
} else {
|
||||
float4 s = v.color;
|
||||
c *= float4(s.r, s.g, s.b, 1.0) * s.a;
|
||||
c = clamp(c, 0.0, c.a);
|
||||
}
|
||||
c = min(c, c.a);
|
||||
return c;
|
||||
}
|
||||
|
||||
|
@ -263,15 +263,15 @@ void main(void) {
|
||||
// Apply the color matrix or scale.
|
||||
color = (color_matrix_body * color) + color_matrix_translation;
|
||||
color *= varying_color_scale;
|
||||
color = clamp(color, 0.0, 1.0);
|
||||
// Premultiply alpha
|
||||
color.rgb *= color.a;
|
||||
#else
|
||||
vec4 s = varying_color_scale;
|
||||
color *= vec4(s.r, s.g, s.b, 1.0) * s.a;
|
||||
color = clamp(color, 0.0, color.a);
|
||||
#endif
|
||||
|
||||
color = min(color, color.a);
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
`
|
||||
|
Loading…
Reference in New Issue
Block a user