mirror of
https://github.com/3b1b/manim.git
synced 2025-11-14 18:07:49 +00:00
Treat joint_type as a uniform
This commit is contained in:
parent
bab809b9a6
commit
be904774dd
3 changed files with 2 additions and 17 deletions
|
|
@ -74,7 +74,6 @@ class VMobject(Mobject):
|
||||||
('unit_normal', np.float32, (3,)),
|
('unit_normal', np.float32, (3,)),
|
||||||
("stroke_width", np.float32, (1,)),
|
("stroke_width", np.float32, (1,)),
|
||||||
("color", np.float32, (4,)),
|
("color", np.float32, (4,)),
|
||||||
("joint_type", np.float32, (1,)),
|
|
||||||
("gloss", np.float32, (1,)),
|
("gloss", np.float32, (1,)),
|
||||||
("shadow", np.float32, (1,)),
|
("shadow", np.float32, (1,)),
|
||||||
]
|
]
|
||||||
|
|
@ -877,17 +876,9 @@ class VMobject(Mobject):
|
||||||
"bevel": 2,
|
"bevel": 2,
|
||||||
"miter": 3,
|
"miter": 3,
|
||||||
}
|
}
|
||||||
# return {"joint_type": joint_type_to_code[self.joint_type]}
|
return {"joint_type": joint_type_to_code[self.joint_type]}
|
||||||
return {} # TODO
|
|
||||||
|
|
||||||
def get_stroke_shader_data(self):
|
def get_stroke_shader_data(self):
|
||||||
joint_type_to_code = {
|
|
||||||
"auto": 0,
|
|
||||||
"round": 1,
|
|
||||||
"bevel": 2,
|
|
||||||
"miter": 3,
|
|
||||||
}
|
|
||||||
|
|
||||||
rgbas = self.get_stroke_rgbas()
|
rgbas = self.get_stroke_rgbas()
|
||||||
if len(rgbas) > 1:
|
if len(rgbas) > 1:
|
||||||
rgbas = self.stretched_style_array_matching_points(rgbas)
|
rgbas = self.stretched_style_array_matching_points(rgbas)
|
||||||
|
|
@ -908,7 +899,6 @@ class VMobject(Mobject):
|
||||||
data["unit_normal"] = self.get_unit_normal_vector()
|
data["unit_normal"] = self.get_unit_normal_vector()
|
||||||
data["stroke_width"][:, 0] = stroke_width
|
data["stroke_width"][:, 0] = stroke_width
|
||||||
data["color"] = rgbas
|
data["color"] = rgbas
|
||||||
data["joint_type"] = joint_type_to_code[self.joint_type]
|
|
||||||
data["gloss"] = self.gloss
|
data["gloss"] = self.gloss
|
||||||
data["shadow"] = self.shadow
|
data["shadow"] = self.shadow
|
||||||
return data
|
return data
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,7 @@ uniform float aspect_ratio;
|
||||||
uniform float focal_distance;
|
uniform float focal_distance;
|
||||||
uniform float anti_alias_width;
|
uniform float anti_alias_width;
|
||||||
uniform vec3 light_source_position;
|
uniform vec3 light_source_position;
|
||||||
|
uniform float joint_type;
|
||||||
|
|
||||||
in vec3 bp[3];
|
in vec3 bp[3];
|
||||||
in vec3 prev_bp[3];
|
in vec3 prev_bp[3];
|
||||||
|
|
@ -16,7 +17,6 @@ in vec3 v_global_unit_normal[3];
|
||||||
|
|
||||||
in vec4 v_color[3];
|
in vec4 v_color[3];
|
||||||
in float v_stroke_width[3];
|
in float v_stroke_width[3];
|
||||||
in float v_joint_type[3];
|
|
||||||
in float v_gloss[3];
|
in float v_gloss[3];
|
||||||
in float v_shadow[3];
|
in float v_shadow[3];
|
||||||
|
|
||||||
|
|
@ -95,7 +95,6 @@ void create_joint(float angle, vec3 unit_tan, float buff, float should_bevel,
|
||||||
vec3 static_c0, out vec3 changing_c0,
|
vec3 static_c0, out vec3 changing_c0,
|
||||||
vec3 static_c1, out vec3 changing_c1){
|
vec3 static_c1, out vec3 changing_c1){
|
||||||
float shift;
|
float shift;
|
||||||
float joint_type = v_joint_type[0];
|
|
||||||
bool miter = (
|
bool miter = (
|
||||||
(joint_type == AUTO_JOINT && abs(angle) > 2.8 && should_bevel == 1) ||
|
(joint_type == AUTO_JOINT && abs(angle) > 2.8 && should_bevel == 1) ||
|
||||||
(joint_type == MITER_JOINT)
|
(joint_type == MITER_JOINT)
|
||||||
|
|
@ -172,7 +171,6 @@ void set_adjascent_info(vec3 c0, vec3 tangent,
|
||||||
out float bevel,
|
out float bevel,
|
||||||
out float angle
|
out float angle
|
||||||
){
|
){
|
||||||
float joint_type = v_joint_type[0];
|
|
||||||
vec3 new_adj[3];
|
vec3 new_adj[3];
|
||||||
float adj_degree = get_reduced_control_points(adj, new_adj);
|
float adj_degree = get_reduced_control_points(adj, new_adj);
|
||||||
// Check if adj_degree is zero?
|
// Check if adj_degree is zero?
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ in vec3 unit_normal;
|
||||||
|
|
||||||
in float stroke_width;
|
in float stroke_width;
|
||||||
in vec4 color;
|
in vec4 color;
|
||||||
in float joint_type;
|
|
||||||
in float gloss;
|
in float gloss;
|
||||||
in float shadow;
|
in float shadow;
|
||||||
|
|
||||||
|
|
@ -22,7 +21,6 @@ out vec3 v_global_unit_normal;
|
||||||
|
|
||||||
out float v_stroke_width;
|
out float v_stroke_width;
|
||||||
out vec4 v_color;
|
out vec4 v_color;
|
||||||
out float v_joint_type;
|
|
||||||
out float v_gloss;
|
out float v_gloss;
|
||||||
out float v_shadow;
|
out float v_shadow;
|
||||||
|
|
||||||
|
|
@ -41,7 +39,6 @@ void main(){
|
||||||
|
|
||||||
v_stroke_width = STROKE_WIDTH_CONVERSION * stroke_width;
|
v_stroke_width = STROKE_WIDTH_CONVERSION * stroke_width;
|
||||||
v_color = color;
|
v_color = color;
|
||||||
v_joint_type = joint_type;
|
|
||||||
v_gloss = gloss;
|
v_gloss = gloss;
|
||||||
v_shadow = shadow;
|
v_shadow = shadow;
|
||||||
}
|
}
|
||||||
Loading…
Add table
Reference in a new issue