mirror of
https://github.com/3b1b/manim.git
synced 2025-09-01 00:48:45 +00:00
Consolidate functions associated with computing gl_Position
This commit is contained in:
parent
fa81d9f6ea
commit
a004c88e02
17 changed files with 28 additions and 81 deletions
|
@ -1,7 +1,5 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
uniform sampler2D Texture;
|
||||
|
||||
in vec3 point;
|
||||
|
@ -13,7 +11,6 @@ out float v_opacity;
|
|||
|
||||
// Analog of import for manim only
|
||||
#INSERT get_gl_Position.glsl
|
||||
#INSERT position_point_into_frame.glsl
|
||||
|
||||
void main(){
|
||||
v_im_coords = im_coords;
|
||||
|
|
|
@ -1,6 +0,0 @@
|
|||
uniform vec2 frame_shape;
|
||||
uniform vec2 pixel_shape;
|
||||
uniform vec3 camera_offset;
|
||||
uniform mat3 camera_rotation;
|
||||
uniform float is_fixed_in_frame;
|
||||
uniform float focal_distance;
|
|
@ -1,7 +1,9 @@
|
|||
// Assumes the following uniforms exist in the surrounding context:
|
||||
// uniform vec2 frame_shape;
|
||||
// uniform float focal_distance;
|
||||
// uniform float is_fixed_in_frame;
|
||||
uniform float is_fixed_in_frame;
|
||||
uniform vec3 camera_offset;
|
||||
uniform mat3 camera_rotation;
|
||||
uniform vec2 frame_shape;
|
||||
uniform vec2 pixel_shape; // Move this
|
||||
uniform float focal_distance;
|
||||
|
||||
const vec2 DEFAULT_FRAME_SHAPE = vec2(8.0 * 16.0 / 9.0, 8.0);
|
||||
|
||||
|
@ -18,4 +20,20 @@ vec4 get_gl_Position(vec3 point){
|
|||
// Flip and scale to prevent premature clipping
|
||||
result.z *= -0.1;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
vec3 rotate_point_into_frame(vec3 point){
|
||||
if(bool(is_fixed_in_frame)){
|
||||
return point;
|
||||
}
|
||||
return camera_rotation * point;
|
||||
}
|
||||
|
||||
|
||||
vec3 position_point_into_frame(vec3 point){
|
||||
if(bool(is_fixed_in_frame)){
|
||||
return point;
|
||||
}
|
||||
return rotate_point_into_frame(point - camera_offset);
|
||||
}
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
// Assumes the following uniforms exist in the surrounding context:
|
||||
// uniform float is_fixed_in_frame;
|
||||
// uniform vec3 camera_offset;
|
||||
// uniform mat3 camera_rotation;
|
||||
|
||||
vec3 rotate_point_into_frame(vec3 point){
|
||||
if(bool(is_fixed_in_frame)){
|
||||
return point;
|
||||
}
|
||||
return camera_rotation * point;
|
||||
}
|
||||
|
||||
|
||||
vec3 position_point_into_frame(vec3 point){
|
||||
if(bool(is_fixed_in_frame)){
|
||||
return point;
|
||||
}
|
||||
return rotate_point_into_frame(point - camera_offset);
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec3 point;
|
||||
out vec3 xyz_coords;
|
||||
|
||||
uniform float scale_factor;
|
||||
uniform vec3 offset;
|
||||
|
||||
#INSERT position_point_into_frame.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
|
||||
void main(){
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec3 point;
|
||||
out vec3 xyz_coords;
|
||||
|
||||
uniform float scale_factor;
|
||||
uniform vec3 offset;
|
||||
|
||||
#INSERT position_point_into_frame.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
|
||||
void main(){
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec4 color;
|
||||
in float fill_all; // Either 0 or 1
|
||||
in float uv_anti_alias_width;
|
||||
|
|
|
@ -5,11 +5,6 @@ layout (triangle_strip, max_vertices = 5) out;
|
|||
|
||||
uniform float anti_alias_width;
|
||||
|
||||
// Needed for get_gl_Position
|
||||
uniform vec2 frame_shape;
|
||||
uniform vec2 pixel_shape;
|
||||
uniform float focal_distance;
|
||||
uniform float is_fixed_in_frame;
|
||||
// Needed for finalize_color
|
||||
uniform vec3 light_source_position;
|
||||
uniform vec3 camera_position;
|
||||
|
@ -37,8 +32,8 @@ const float ANGLE_THRESHOLD = 1e-3;
|
|||
|
||||
|
||||
// Analog of import for manim only
|
||||
#INSERT get_xy_to_uv.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
#INSERT get_xy_to_uv.glsl
|
||||
#INSERT finalize_color.glsl
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec3 point;
|
||||
in float orientation;
|
||||
in vec4 color;
|
||||
|
@ -13,7 +11,7 @@ out vec4 v_color;
|
|||
out float v_vert_index;
|
||||
|
||||
// Analog of import for manim only
|
||||
#INSERT position_point_into_frame.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
|
||||
void main(){
|
||||
verts = position_point_into_frame(point);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec2 uv_coords;
|
||||
|
||||
in float uv_stroke_width;
|
||||
|
|
|
@ -3,15 +3,8 @@
|
|||
layout (triangles) in;
|
||||
layout (triangle_strip, max_vertices = 6) out;
|
||||
|
||||
// Needed for get_gl_Position
|
||||
uniform vec2 frame_shape;
|
||||
uniform vec2 pixel_shape;
|
||||
uniform float focal_distance;
|
||||
uniform float is_fixed_in_frame;
|
||||
|
||||
uniform float anti_alias_width;
|
||||
uniform float flat_stroke;
|
||||
uniform mat3 camera_rotation;
|
||||
|
||||
//Needed for lighting
|
||||
uniform vec3 light_source_position;
|
||||
|
@ -46,8 +39,8 @@ const float PI = 3.141592653;
|
|||
const float ANGLE_THRESHOLD = 1e-3;
|
||||
|
||||
|
||||
#INSERT get_xy_to_uv.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
#INSERT get_xy_to_uv.glsl
|
||||
#INSERT finalize_color.glsl
|
||||
|
||||
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec3 point;
|
||||
|
||||
in float joint_angle;
|
||||
|
@ -18,7 +16,7 @@ out float v_vert_index;
|
|||
|
||||
const float STROKE_WIDTH_CONVERSION = 0.01;
|
||||
|
||||
#INSERT position_point_into_frame.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
|
||||
void main(){
|
||||
verts = position_point_into_frame(point);
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec3 point;
|
||||
|
||||
// Analog of import for manim only
|
||||
#INSERT get_gl_Position.glsl
|
||||
#INSERT position_point_into_frame.glsl
|
||||
|
||||
void main(){
|
||||
gl_Position = get_gl_Position(position_point_into_frame(point));
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
uniform vec3 light_source_position;
|
||||
uniform vec3 camera_position;
|
||||
uniform float reflectiveness;
|
||||
|
@ -18,7 +16,6 @@ out vec3 xyz_coords;
|
|||
out vec3 v_normal;
|
||||
out vec4 v_color;
|
||||
|
||||
#INSERT position_point_into_frame.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
#INSERT get_rotated_surface_unit_normal_vector.glsl
|
||||
#INSERT finalize_color.glsl
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec3 point;
|
||||
in vec3 du_point;
|
||||
in vec3 dv_point;
|
||||
|
@ -13,7 +11,6 @@ out vec3 v_normal;
|
|||
out vec2 v_im_coords;
|
||||
out float v_opacity;
|
||||
|
||||
#INSERT position_point_into_frame.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
#INSERT get_rotated_surface_unit_normal_vector.glsl
|
||||
|
||||
|
|
|
@ -3,11 +3,6 @@
|
|||
layout (points) in;
|
||||
layout (triangle_strip, max_vertices = 4) out;
|
||||
|
||||
// Needed for get_gl_Position
|
||||
uniform vec2 frame_shape;
|
||||
uniform vec2 pixel_shape;
|
||||
uniform float focal_distance;
|
||||
uniform float is_fixed_in_frame;
|
||||
uniform float anti_alias_width;
|
||||
|
||||
in vec3 v_point[1];
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#version 330
|
||||
|
||||
#INSERT camera_uniform_declarations.glsl
|
||||
|
||||
in vec3 point;
|
||||
in float radius;
|
||||
in vec4 color;
|
||||
|
@ -10,7 +8,7 @@ out vec3 v_point;
|
|||
out float v_radius;
|
||||
out vec4 v_color;
|
||||
|
||||
#INSERT position_point_into_frame.glsl
|
||||
#INSERT get_gl_Position.glsl
|
||||
|
||||
void main(){
|
||||
v_point = position_point_into_frame(point);
|
||||
|
|
Loading…
Add table
Reference in a new issue