webgl: Clamp alpha in shaders (fix #6954)
This commit is contained in:
parent
121c2577b4
commit
edad1569fb
|
@ -23,7 +23,8 @@ void main() {
|
|||
if( color.a > 0.0 ) {
|
||||
color.rgb /= color.a;
|
||||
color = mult_color * color + add_color;
|
||||
color.rgb *= color.a;
|
||||
float alpha = saturate(color.a);
|
||||
color = vec4(color.rgb * alpha, alpha);
|
||||
}
|
||||
|
||||
gl_FragColor = color;
|
||||
|
|
|
@ -14,5 +14,5 @@ uniform vec4 add_color;
|
|||
varying vec4 frag_color;
|
||||
|
||||
void main() {
|
||||
gl_FragColor = vec4(frag_color.rgb * frag_color.a, frag_color.a);
|
||||
gl_FragColor = frag_color;
|
||||
}
|
||||
|
|
|
@ -17,5 +17,7 @@ varying vec4 frag_color;
|
|||
|
||||
void main() {
|
||||
frag_color = color * mult_color + add_color;
|
||||
float alpha = saturate(frag_color.a);
|
||||
frag_color = vec4(frag_color.rgb * alpha, alpha);
|
||||
gl_Position = view_matrix * world_matrix * vec4(position, 0.0, 1.0);
|
||||
}
|
||||
|
|
|
@ -79,22 +79,22 @@ void main() {
|
|||
float a;
|
||||
if( t <= u_ratios[0] ) {
|
||||
color = u_colors[0];
|
||||
} else if( t <= u_ratios[1] ) {
|
||||
} else if( t <= u_ratios[1] ) {
|
||||
a = (t - u_ratios[0]) / (u_ratios[1] - u_ratios[0]);
|
||||
color = mix(u_colors[0], u_colors[1], a);
|
||||
} else if( t <= u_ratios[2] ) {
|
||||
} else if( t <= u_ratios[2] ) {
|
||||
a = (t - u_ratios[1]) / (u_ratios[2] - u_ratios[1]);
|
||||
color = mix(u_colors[1], u_colors[2], a);
|
||||
} else if( t <= u_ratios[3] ) {
|
||||
} else if( t <= u_ratios[3] ) {
|
||||
a = (t - u_ratios[2]) / (u_ratios[3] - u_ratios[2]);
|
||||
color = mix(u_colors[2], u_colors[3], a);
|
||||
} else if( t <= u_ratios[4] ) {
|
||||
} else if( t <= u_ratios[4] ) {
|
||||
a = (t - u_ratios[3]) / (u_ratios[4] - u_ratios[3]);
|
||||
color = mix(u_colors[3], u_colors[4], a);
|
||||
} else if( t <= u_ratios[5] ) {
|
||||
} else if( t <= u_ratios[5] ) {
|
||||
a = (t - u_ratios[4]) / (u_ratios[5] - u_ratios[4]);
|
||||
color = mix(u_colors[4], u_colors[5], a);
|
||||
} else if( t <= u_ratios[6] ) {
|
||||
} else if( t <= u_ratios[6] ) {
|
||||
a = (t - u_ratios[5]) / (u_ratios[6] - u_ratios[5]);
|
||||
color = mix(u_colors[5], u_colors[6], a);
|
||||
} else if( t <= u_ratios[7] ) {
|
||||
|
@ -130,6 +130,7 @@ void main() {
|
|||
}
|
||||
|
||||
color = mult_color * color + add_color;
|
||||
gl_FragColor = vec4(color.rgb * color.a, color.a);
|
||||
float alpha = saturate(color.a);
|
||||
gl_FragColor = vec4(color.rgb * alpha, alpha);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue