mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphicsdriver: Optimize shader by removing 'if'
This commit is contained in:
parent
1f46299870
commit
815ed8cda2
@ -203,9 +203,7 @@ float4 FragmentShaderImpl(
|
||||
constant float4& color_matrix_translation,
|
||||
constant float& scale) {
|
||||
float4 c = GetColorFromTexel<filter, address>().Do(v, texture, source_size, scale);
|
||||
if (0 < c.a) {
|
||||
c.rgb /= c.a;
|
||||
}
|
||||
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);
|
||||
|
@ -247,10 +247,9 @@ void main(void) {
|
||||
color = mix(mix(c0, c1, rate.x), mix(c2, c3, rate.x), rate.y);
|
||||
#endif
|
||||
|
||||
// Un-premultiply alpha
|
||||
if (0.0 < color.a) {
|
||||
color.rgb /= color.a;
|
||||
}
|
||||
// Un-premultiply alpha.
|
||||
// When the alpha is 0, 1.0 - sign(alpha) is 1.0, which means division does nothing.
|
||||
color.rgb /= color.a + (1.0 - sign(color.a));
|
||||
// Apply the color matrix or scale.
|
||||
color = (color_matrix_body * color) + color_matrix_translation;
|
||||
color *= varying_color_scale;
|
||||
|
Loading…
Reference in New Issue
Block a user