mirror of
https://github.com/3b1b/manim.git
synced 2025-08-19 13:01:00 +00:00
Fix anti-alias width bug on DotCloud
This commit is contained in:
parent
a47b95044d
commit
de5198196b
2 changed files with 7 additions and 3 deletions
|
@ -13,6 +13,7 @@ in vec4 color;
|
||||||
in float radius;
|
in float radius;
|
||||||
in vec2 center;
|
in vec2 center;
|
||||||
in vec2 point;
|
in vec2 point;
|
||||||
|
in float scaled_aaw;
|
||||||
|
|
||||||
out vec4 frag_color;
|
out vec4 frag_color;
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ void main() {
|
||||||
vec2 diff = point - center;
|
vec2 diff = point - center;
|
||||||
float dist = length(diff);
|
float dist = length(diff);
|
||||||
float signed_dist = dist - radius;
|
float signed_dist = dist - radius;
|
||||||
if (signed_dist > 0.5 * anti_alias_width){
|
if (signed_dist > 0.5 * scaled_aaw){
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
frag_color = color;
|
frag_color = color;
|
||||||
|
@ -43,5 +44,5 @@ void main() {
|
||||||
frag_color.a *= pow(1 - dist / radius, glow_factor);
|
frag_color.a *= pow(1 - dist / radius, glow_factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
frag_color.a *= smoothstep(0.5, -0.5, signed_dist / anti_alias_width);
|
frag_color.a *= smoothstep(0.5, -0.5, signed_dist / scaled_aaw);
|
||||||
}
|
}
|
|
@ -5,6 +5,7 @@ layout (triangle_strip, max_vertices = 4) out;
|
||||||
|
|
||||||
// Needed for get_gl_Position
|
// Needed for get_gl_Position
|
||||||
uniform vec2 frame_shape;
|
uniform vec2 frame_shape;
|
||||||
|
uniform vec2 pixel_shape;
|
||||||
uniform float focal_distance;
|
uniform float focal_distance;
|
||||||
uniform float is_fixed_in_frame;
|
uniform float is_fixed_in_frame;
|
||||||
uniform float anti_alias_width;
|
uniform float anti_alias_width;
|
||||||
|
@ -17,6 +18,7 @@ out vec4 color;
|
||||||
out float radius;
|
out float radius;
|
||||||
out vec2 center;
|
out vec2 center;
|
||||||
out vec2 point;
|
out vec2 point;
|
||||||
|
out float scaled_aaw;
|
||||||
|
|
||||||
#INSERT get_gl_Position.glsl
|
#INSERT get_gl_Position.glsl
|
||||||
|
|
||||||
|
@ -25,8 +27,9 @@ void main() {
|
||||||
radius = v_radius[0];
|
radius = v_radius[0];
|
||||||
center = v_point[0].xy;
|
center = v_point[0].xy;
|
||||||
|
|
||||||
|
scaled_aaw = (frame_shape.y / pixel_shape.y);
|
||||||
radius = v_radius[0] / max(1.0 - v_point[0].z / focal_distance / frame_shape.y, 0.0);
|
radius = v_radius[0] / max(1.0 - v_point[0].z / focal_distance / frame_shape.y, 0.0);
|
||||||
float rpa = radius + anti_alias_width;
|
float rpa = radius + scaled_aaw;
|
||||||
|
|
||||||
for(int i = 0; i < 4; i++){
|
for(int i = 0; i < 4; i++){
|
||||||
// To account for perspective
|
// To account for perspective
|
||||||
|
|
Loading…
Add table
Reference in a new issue