Revert "Revert "Go back to fill shader tracing vertex index manually""

This reverts commit 387de61119ea13b63d68c8e56a776717b99f2a8c.
This commit is contained in:
Grant Sanderson
2023-01-12 00:16:05 -08:00
parent ae42f6244e
commit c0b3c246de
2 changed files with 8 additions and 3 deletions

View File

@ -57,6 +57,7 @@ class VMobject(Mobject):
('point', np.float32, (3,)),
('orientation', np.float32, (1,)),
('color', np.float32, (4,)),
('vert_index', np.float32, (1,)),
]
stroke_dtype: Sequence[Tuple[str, type, Tuple[int]]] = [
("point", np.float32, (3,)),
@ -1212,7 +1213,11 @@ class VMobject(Mobject):
return self.stroke_data
def get_fill_shader_data(self) -> np.ndarray:
self.fill_data = resize_array(self.fill_data, len(self.get_points()))
points = self.get_points()
if len(self.fill_data) != len(points):
self.fill_data = resize_array(self.fill_data, len(points))
self.fill_data["vert_index"][:, 0] = range(len(points))
self.read_data_to_shader(self.fill_data, "point", "points")
self.read_data_to_shader(self.fill_data, "color", "fill_rgba")
self.read_data_to_shader(self.fill_data, "orientation", "orientation")

View File

@ -5,6 +5,7 @@
in vec3 point;
in float orientation;
in vec4 color;
in float vert_index;
out vec3 bp; // Bezier control point
out float v_orientation;
@ -18,6 +19,5 @@ void main(){
bp = position_point_into_frame(point);
v_orientation = orientation;
v_color = color;
// Implicit conversion from int to float
v_vert_index = gl_VertexID;
v_vert_index = vert_index;
}