mirror of
https://github.com/3b1b/manim.git
synced 2025-04-13 09:47:07 +00:00
Misc. clean up
This commit is contained in:
parent
307487e087
commit
088a2f65a3
2 changed files with 12 additions and 10 deletions
|
@ -257,16 +257,16 @@ class Camera(object):
|
||||||
|
|
||||||
def init_fill_fbo(self, ctx: moderngl.context.Context):
|
def init_fill_fbo(self, ctx: moderngl.context.Context):
|
||||||
# Experimental
|
# Experimental
|
||||||
|
size = self.get_pixel_shape()
|
||||||
self.fill_texture = ctx.texture(
|
self.fill_texture = ctx.texture(
|
||||||
size=self.get_pixel_shape(),
|
size=size,
|
||||||
components=4,
|
components=4,
|
||||||
samples=self.samples,
|
|
||||||
# Important to make sure floating point (not fixed point) is
|
# Important to make sure floating point (not fixed point) is
|
||||||
# used so that alpha values are not clipped
|
# used so that alpha values are not clipped
|
||||||
dtype='f2',
|
dtype='f2',
|
||||||
)
|
)
|
||||||
# TODO, depth buffer is not really used yet
|
# TODO, depth buffer is not really used yet
|
||||||
fill_depth = ctx.depth_renderbuffer(self.get_pixel_shape(), samples=self.samples)
|
fill_depth = ctx.depth_renderbuffer(size)
|
||||||
self.fill_fbo = ctx.framebuffer(self.fill_texture, fill_depth)
|
self.fill_fbo = ctx.framebuffer(self.fill_texture, fill_depth)
|
||||||
self.fill_prog = ctx.program(
|
self.fill_prog = ctx.program(
|
||||||
vertex_shader='''
|
vertex_shader='''
|
||||||
|
@ -292,9 +292,11 @@ class Camera(object):
|
||||||
frag_color = texture(Texture, v_textcoord);
|
frag_color = texture(Texture, v_textcoord);
|
||||||
frag_color = abs(frag_color);
|
frag_color = abs(frag_color);
|
||||||
if(frag_color.a == 0) discard;
|
if(frag_color.a == 0) discard;
|
||||||
|
//TODO, set gl_FragDepth;
|
||||||
}
|
}
|
||||||
''',
|
''',
|
||||||
)
|
)
|
||||||
|
|
||||||
tid = self.n_textures
|
tid = self.n_textures
|
||||||
self.fill_texture.use(tid)
|
self.fill_texture.use(tid)
|
||||||
self.fill_prog['Texture'].value = tid
|
self.fill_prog['Texture'].value = tid
|
||||||
|
@ -476,13 +478,13 @@ class Camera(object):
|
||||||
return
|
return
|
||||||
self.fill_fbo.clear(0.0, 0.0, 0.0, 0.0)
|
self.fill_fbo.clear(0.0, 0.0, 0.0, 0.0)
|
||||||
self.fill_fbo.use()
|
self.fill_fbo.use()
|
||||||
self.ctx.enable(moderngl.BLEND)
|
self.ctx.blend_func = (
|
||||||
self.ctx.blend_func = moderngl.ONE, moderngl.ONE
|
moderngl.ONE, moderngl.ZERO,
|
||||||
|
moderngl.ONE, moderngl.ONE,
|
||||||
|
)
|
||||||
vao.render(render_primitive)
|
vao.render(render_primitive)
|
||||||
self.ctx.blend_func = moderngl.DEFAULT_BLENDING
|
self.ctx.blend_func = moderngl.DEFAULT_BLENDING
|
||||||
self.fbo.use()
|
self.fbo.use()
|
||||||
self.fill_texture.use(0)
|
|
||||||
self.fill_prog['Texture'].value = 0
|
|
||||||
self.fill_texture_vao.render(moderngl.TRIANGLE_STRIP)
|
self.fill_texture_vao.render(moderngl.TRIANGLE_STRIP)
|
||||||
|
|
||||||
def get_render_group_list(self, mobject: Mobject) -> Iterable[dict[str, Any]]:
|
def get_render_group_list(self, mobject: Mobject) -> Iterable[dict[str, Any]]:
|
||||||
|
|
|
@ -43,7 +43,7 @@ void emit_triangle(vec3 points[3], vec4 v_color[3]){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void emit_in_triangle(){
|
void emit_simple_triangle(){
|
||||||
emit_triangle(
|
emit_triangle(
|
||||||
vec3[3](verts[0], verts[1], verts[2]),
|
vec3[3](verts[0], verts[1], verts[2]),
|
||||||
vec4[3](v_color[0], v_color[1], v_color[2])
|
vec4[3](v_color[0], v_color[1], v_color[2])
|
||||||
|
@ -70,7 +70,7 @@ void main(){
|
||||||
);
|
);
|
||||||
// Edge triangle
|
// Edge triangle
|
||||||
fill_all = 0.0;
|
fill_all = 0.0;
|
||||||
emit_in_triangle();
|
emit_simple_triangle();
|
||||||
}else{
|
}else{
|
||||||
// In this case, one should fill all if the vertices are
|
// In this case, one should fill all if the vertices are
|
||||||
// not in sequential order
|
// not in sequential order
|
||||||
|
@ -78,7 +78,7 @@ void main(){
|
||||||
(v_vert_index[1] - v_vert_index[0]) != 1.0 ||
|
(v_vert_index[1] - v_vert_index[0]) != 1.0 ||
|
||||||
(v_vert_index[2] - v_vert_index[1]) != 1.0
|
(v_vert_index[2] - v_vert_index[1]) != 1.0
|
||||||
);
|
);
|
||||||
emit_in_triangle();
|
emit_simple_triangle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue