mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
45 lines
No EOL
1 KiB
GLSL
45 lines
No EOL
1 KiB
GLSL
#version 330
|
|
|
|
layout (points) in;
|
|
layout (triangle_strip, max_vertices = 4) out;
|
|
|
|
uniform float anti_alias_width;
|
|
uniform float pixel_size;
|
|
uniform vec3 camera_position;
|
|
|
|
in vec3 v_point[1];
|
|
in float v_radius[1];
|
|
in vec4 v_color[1];
|
|
|
|
out vec4 color;
|
|
out float radius;
|
|
out vec2 center;
|
|
out vec2 point;
|
|
out float scaled_aaw;
|
|
|
|
#INSERT get_gl_Position.glsl
|
|
|
|
void main() {
|
|
color = v_color[0];
|
|
radius = v_radius[0];
|
|
center = v_point[0].xy;
|
|
|
|
scaled_aaw = anti_alias_width * pixel_size;
|
|
radius = v_radius[0] / max(1.0 - v_point[0].z / focal_distance / frame_shape.y, 0.0);
|
|
float rpa = radius + scaled_aaw;
|
|
|
|
vec3 to_cam = camera_position - v_point[0];
|
|
|
|
for(int i = 0; i < 4; i++){
|
|
// To account for perspective
|
|
|
|
int x_index = 2 * (i % 2) - 1;
|
|
int y_index = 2 * (i / 2) - 1;
|
|
vec3 corner = v_point[0] + vec3(x_index * rpa, y_index * rpa, 0.0);
|
|
|
|
gl_Position = get_gl_Position(corner);
|
|
point = corner.xy;
|
|
EmitVertex();
|
|
}
|
|
EndPrimitive();
|
|
} |