mirror of
https://github.com/3b1b/manim.git
synced 2025-08-05 16:49:03 +00:00
Separate out the point_to_gl_Position function, which needs to be updated later
This commit is contained in:
parent
50c7dd7d48
commit
3f0cc56665
4 changed files with 28 additions and 18 deletions
11
manimlib/shaders/point_to_gl_position.glsl
Normal file
11
manimlib/shaders/point_to_gl_position.glsl
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
// Assumes theese uniforms exist in the surrounding context
|
||||||
|
// uniform float scale;
|
||||||
|
// uniform float aspect_ratio;
|
||||||
|
// uniform float frame_center;
|
||||||
|
|
||||||
|
vec4 point_to_gl_Position(vec3 p){
|
||||||
|
vec3 result = p / scale;
|
||||||
|
result.x /= aspect_ratio;
|
||||||
|
result -= frame_center;
|
||||||
|
gl_Position = vec4(result, 1.0);
|
||||||
|
}
|
|
@ -36,6 +36,7 @@ const float SQRT5 = 2.236068;
|
||||||
// so to share functionality between this and others, the caller
|
// so to share functionality between this and others, the caller
|
||||||
// replaces this line with the contents of named file
|
// replaces this line with the contents of named file
|
||||||
#INSERT quadratic_bezier_geometry_functions.glsl
|
#INSERT quadratic_bezier_geometry_functions.glsl
|
||||||
|
#INSERT set_gl_Position.glsl
|
||||||
|
|
||||||
|
|
||||||
mat3 get_xy_to_wz(vec2 b0, vec2 b1, vec2 b2){
|
mat3 get_xy_to_wz(vec2 b0, vec2 b1, vec2 b2){
|
||||||
|
@ -60,18 +61,11 @@ mat3 get_xy_to_wz(vec2 b0, vec2 b1, vec2 b2){
|
||||||
return transform * shift;
|
return transform * shift;
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_gl_Position(vec2 p){
|
|
||||||
vec2 result = p / scale;
|
|
||||||
result.x /= aspect_ratio;
|
|
||||||
result -= frame_center.xy;
|
|
||||||
gl_Position = vec4(result, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void emit_simple_triangle(){
|
void emit_simple_triangle(){
|
||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
color = v_color[i];
|
color = v_color[i];
|
||||||
set_gl_Position(bp[i]);
|
set_gl_Position(vec3(bp[i], 0));
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
}
|
}
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
|
@ -129,7 +123,7 @@ void emit_pentagon(vec2 bp0, vec2 bp1, vec2 bp2, float orientation){
|
||||||
if(i < 2) color = v_color[0];
|
if(i < 2) color = v_color[0];
|
||||||
else if(i == 2) color = v_color[1];
|
else if(i == 2) color = v_color[1];
|
||||||
else color = v_color[2];
|
else color = v_color[2];
|
||||||
set_gl_Position(corner);
|
set_gl_Position(vec3(corner, 0));
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
}
|
}
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
|
|
|
@ -43,6 +43,7 @@ const float MITER_JOINT = 3;
|
||||||
// so to share functionality between this and others, the caller
|
// so to share functionality between this and others, the caller
|
||||||
// replaces this line with the contents of named file
|
// replaces this line with the contents of named file
|
||||||
#INSERT quadratic_bezier_geometry_functions.glsl
|
#INSERT quadratic_bezier_geometry_functions.glsl
|
||||||
|
#INSERT set_gl_Position.glsl
|
||||||
|
|
||||||
|
|
||||||
float angle_between_vectors(vec2 v1, vec2 v2){
|
float angle_between_vectors(vec2 v1, vec2 v2){
|
||||||
|
@ -264,14 +265,6 @@ void set_previous_and_next(vec2 controls[3], int degree){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void set_gl_Position(vec2 p){
|
|
||||||
vec2 result = p / scale;
|
|
||||||
result.x /= aspect_ratio;
|
|
||||||
result -= frame_center.xy;
|
|
||||||
gl_Position = vec4(result, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
vec2 controls[3];
|
vec2 controls[3];
|
||||||
int degree = get_reduced_control_points(bp[0], bp[1], bp[2], controls);
|
int degree = get_reduced_control_points(bp[0], bp[1], bp[2], controls);
|
||||||
|
@ -311,7 +304,7 @@ void main() {
|
||||||
uv_stroke_width = stroke_widths[i] / scale_factor;
|
uv_stroke_width = stroke_widths[i] / scale_factor;
|
||||||
color = stroke_colors[i];
|
color = stroke_colors[i];
|
||||||
|
|
||||||
set_gl_Position(corner);
|
set_gl_Position(vec3(corner, 0));
|
||||||
EmitVertex();
|
EmitVertex();
|
||||||
}
|
}
|
||||||
EndPrimitive();
|
EndPrimitive();
|
||||||
|
|
12
manimlib/shaders/set_gl_Position.glsl
Normal file
12
manimlib/shaders/set_gl_Position.glsl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
// Assumes theese uniforms exist in the surrounding context
|
||||||
|
// uniform float scale;
|
||||||
|
// uniform float aspect_ratio;
|
||||||
|
// uniform float frame_center;
|
||||||
|
|
||||||
|
void set_gl_Position(vec3 point){
|
||||||
|
// TODO, orient in 3d based on certain rotation matrices
|
||||||
|
point /= scale;
|
||||||
|
point.x /= aspect_ratio;
|
||||||
|
point -= frame_center;
|
||||||
|
gl_Position = vec4(point, 1.0);
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue