3b1b-manim/manimlib/shaders/true_dot/frag.glsl

36 lines
756 B
Text
Raw Normal View History

2021-01-04 13:26:58 -08:00
#version 330
uniform float glow_factor;
2023-01-18 15:36:00 -08:00
uniform mat4 perspective;
2021-01-04 13:26:58 -08:00
in vec4 color;
2023-01-12 19:44:10 -08:00
in float scaled_aaw;
2023-02-16 16:47:59 -08:00
in vec3 point;
in vec3 to_cam;
in vec3 center;
in float radius;
in vec2 uv_coords;
2021-01-04 13:26:58 -08:00
out vec4 frag_color;
2023-01-18 15:36:00 -08:00
// This include a delaration of uniform vec3 shading
#INSERT finalize_color.glsl
2021-01-04 13:26:58 -08:00
void main() {
2023-02-16 16:47:59 -08:00
float r = length(uv_coords.xy);
if(r > 1.0) discard;
2023-01-18 15:36:00 -08:00
frag_color = color;
2023-01-18 15:36:00 -08:00
if(glow_factor > 0){
2023-01-18 15:36:00 -08:00
frag_color.a *= pow(1 - r, glow_factor);
}
if(shading != vec3(0.0)){
2023-02-16 16:47:59 -08:00
vec3 point_3d = point + radius * sqrt(1 - r * r) * to_cam;
vec3 normal = normalize(point_3d - center);
frag_color = finalize_color(frag_color, point_3d, normal);
}
2023-01-18 15:36:00 -08:00
frag_color.a *= smoothstep(1.0, 1.0 - scaled_aaw, r);
2021-01-04 13:26:58 -08:00
}