Merge branch 'glitch-fix' into video-work

This commit is contained in:
Grant Sanderson
2023-01-31 11:59:54 -08:00
5 changed files with 9 additions and 27 deletions

View File

@ -68,8 +68,8 @@ class VMobject(Mobject):
fill_data_names = ['point', 'fill_rgba', 'base_point', 'unit_normal']
stroke_data_names = ['point', 'stroke_rgba', 'stroke_width', 'joint_product']
fill_render_primitive: int = moderngl.TRIANGLE_STRIP
stroke_render_primitive: int = moderngl.TRIANGLE_STRIP
fill_render_primitive: int = moderngl.TRIANGLES
stroke_render_primitive: int = moderngl.TRIANGLES
pre_function_handle_to_anchor_scale_factor: float = 0.01
make_smooth_after_applying_functions: bool = False
@ -1300,21 +1300,17 @@ class VMobject(Mobject):
submob.get_joint_products()
has_fill = submob.has_fill()
has_stroke = submob.has_stroke()
indices = submob.get_outer_vert_indices()
if has_stroke:
lst = back_stroke_datas if submob.stroke_behind else stroke_datas
lst.append(submob.data[stroke_names])
# Set data array to be one longer than number of points,
# with a dummy vertex added at the end. This is to ensure
# it can be safely stacked onto other stroke data arrays.
lst.append(submob.data[stroke_names][-1:])
lst.append(submob.data[stroke_names][indices])
if has_fill:
data = submob.data[fill_names]
data["base_point"][:] = data["point"][0]
fill_datas.append(data)
if self._use_winding_fill:
# Add dummy, as above
fill_datas.append(data[-1:])
fill_datas.append(data[indices])
else:
fill_datas.append(data)
fill_indices.append(submob.get_triangulation())
if not has_stroke and has_fill:
# Add fill border
@ -1324,10 +1320,7 @@ class VMobject(Mobject):
border_stroke_data = submob.data[names].astype(
self.stroke_shader_wrapper.vert_data.dtype
)
print(border_stroke_data.dtype)
fill_border_datas.append(border_stroke_data)
fill_border_datas.append(border_stroke_data[-1:])
fill_border_datas.append(border_stroke_data[indices])
shader_wrappers = [
self.back_stroke_shader_wrapper.read_in(

View File

@ -285,7 +285,7 @@ class FillShaderWrapper(ShaderWrapper):
winding = (len(self.vert_indices) == 0)
vao.program['winding'].value = winding
if not winding:
vao.render(moderngl.TRIANGLES)
vao.render()
return
original_fbo = self.ctx.fbo
@ -303,7 +303,7 @@ class FillShaderWrapper(ShaderWrapper):
gl.glBlendEquationSeparate(gl.GL_FUNC_ADD, gl.GL_MAX)
self.ctx.blend_equation = moderngl.FUNC_ADD, moderngl.MAX
vao.render(moderngl.TRIANGLE_STRIP)
vao.render()
original_fbo.use()
gl.glBlendFunc(gl.GL_ONE, gl.GL_ONE_MINUS_SRC_ALPHA)

View File

@ -57,10 +57,6 @@ void emit_simple_triangle(){
void main(){
// We use the triangle strip primative, but
// actually only need every other strip element
if (winding && int(v_vert_index[0]) % 2 == 1) return;
// Curves are marked as ended when the handle after
// the first anchor is set equal to that anchor
if (verts[0] == verts[1]) return;

View File

@ -13,7 +13,6 @@ in vec3 verts[3];
in vec4 v_joint_product[3];
in float v_stroke_width[3];
in vec4 v_color[3];
in float v_vert_index[3];
out vec4 color;
out float uv_stroke_width;
@ -154,10 +153,6 @@ void get_corners(
}
void main() {
// We use the triangle strip primative, but
// actually only need every other strip element
if (int(v_vert_index[0]) % 2 == 1) return;
// Curves are marked as ended when the handle after
// the first anchor is set equal to that anchor
if (verts[0] == verts[1]) return;

View File

@ -15,7 +15,6 @@ out vec3 verts;
out vec4 v_joint_product;
out float v_stroke_width;
out vec4 v_color;
out float v_vert_index;
const float STROKE_WIDTH_CONVERSION = 0.01;
@ -27,5 +26,4 @@ void main(){
}
v_joint_product = joint_product;
v_color = stroke_rgba;
v_vert_index = gl_VertexID;
}