Misc. clean up

This commit is contained in:
Grant Sanderson 2023-01-24 21:10:57 -08:00
parent 307487e087
commit 088a2f65a3
2 changed files with 12 additions and 10 deletions

View file

@ -257,16 +257,16 @@ class Camera(object):
def init_fill_fbo(self, ctx: moderngl.context.Context):
# Experimental
size = self.get_pixel_shape()
self.fill_texture = ctx.texture(
size=self.get_pixel_shape(),
size=size,
components=4,
samples=self.samples,
# Important to make sure floating point (not fixed point) is
# used so that alpha values are not clipped
dtype='f2',
)
# 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_prog = ctx.program(
vertex_shader='''
@ -292,9 +292,11 @@ class Camera(object):
frag_color = texture(Texture, v_textcoord);
frag_color = abs(frag_color);
if(frag_color.a == 0) discard;
//TODO, set gl_FragDepth;
}
''',
)
tid = self.n_textures
self.fill_texture.use(tid)
self.fill_prog['Texture'].value = tid
@ -476,13 +478,13 @@ class Camera(object):
return
self.fill_fbo.clear(0.0, 0.0, 0.0, 0.0)
self.fill_fbo.use()
self.ctx.enable(moderngl.BLEND)
self.ctx.blend_func = moderngl.ONE, moderngl.ONE
self.ctx.blend_func = (
moderngl.ONE, moderngl.ZERO,
moderngl.ONE, moderngl.ONE,
)
vao.render(render_primitive)
self.ctx.blend_func = moderngl.DEFAULT_BLENDING
self.fbo.use()
self.fill_texture.use(0)
self.fill_prog['Texture'].value = 0
self.fill_texture_vao.render(moderngl.TRIANGLE_STRIP)
def get_render_group_list(self, mobject: Mobject) -> Iterable[dict[str, Any]]:

View file

@ -43,7 +43,7 @@ void emit_triangle(vec3 points[3], vec4 v_color[3]){
}
void emit_in_triangle(){
void emit_simple_triangle(){
emit_triangle(
vec3[3](verts[0], verts[1], verts[2]),
vec4[3](v_color[0], v_color[1], v_color[2])
@ -70,7 +70,7 @@ void main(){
);
// Edge triangle
fill_all = 0.0;
emit_in_triangle();
emit_simple_triangle();
}else{
// In this case, one should fill all if the vertices are
// not in sequential order
@ -78,7 +78,7 @@ void main(){
(v_vert_index[1] - v_vert_index[0]) != 1.0 ||
(v_vert_index[2] - v_vert_index[1]) != 1.0
);
emit_in_triangle();
emit_simple_triangle();
}
}