Repository: ManimCommunity/manim

Issue:
`StreamLines` in OpenGL do not work with the projection shaders.
## Description of bug / unexpected behavior
<!-- Add a clear and concise description of the problem you encountered. -->

After #1971 `StreamLines` were able to be rendered in `OpenGL`, however, they work only when used with Grant's shaders, not the projection shaders. This is not ideal because we plan to eventually switch over to fully supporting the projection shaders.

When running this code:
```py
class BasicUsage(Scene):
    def construct(self):
        func = lambda pos: ((pos[0] * UR + pos[1] * LEFT) - pos) / 3
        self.add(StreamLines(func))
```
The following error is produced:
```py
(manim-zPbAr8g6-py3.9) PS C:\Users\laith\Documents\GitHub\hydro_manim> manim -p --renderer=opengl mkt.py BasicUsage --use_projection_stroke_shaders --use_projection_fill_shaders
Manim Community v0.9.0

Python 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Type 'copyright', 'credits' or 'license' for more information
IPython 7.23.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\cli\render\commands.py:108 in render           │
│                                                                                                  │
│   105 │   │   │   while keep_running:                                                            │
│   106 │   │   │   │   for SceneClass in scene_classes_from_file(file):                           │
│   107 │   │   │   │   │   scene = SceneClass(renderer)                                           │
│ ❱ 108 │   │   │   │   │   status = scene.render()                                                │
│   109 │   │   │   │   │   if status:                                                             │
│   110 │   │   │   │   │   │   continue                                                           │
│   111 │   │   │   │   │   else:                                                                  │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\scene\scene.py:215 in render                   │
│                                                                                                  │
│    212 │   │   """                                                                               │
│    213 │   │   self.setup()                                                                      │
│    214 │   │   try:                                                                              │
│ ❱  215 │   │   │   self.construct()                                                              │
│    216 │   │   except EndSceneEarlyException:                                                    │
│    217 │   │   │   pass                                                                          │
│    218 │   │   except RerunSceneException as e:                                                  │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\mkt.py:2906 in construct                             │
│                                                                                                  │
│   2903 │   def construct(self):                                                                  │
│   2904 │   │   func = lambda pos: ((pos[0] * UR + pos[1] * LEFT) - pos) / 3.                     │
│   2905 │   │   self.add(StreamLines(func, colors=[BLUE, PINK, PURPLE], stroke_width=6., opacity  │
│ ❱ 2906 │   │   self.interactive_embed()                                                          │
│   2907                                                                                           │
│   2908 class D(Scene):                                                                           │
│   2909 │   def construct(self):                                                                  │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\scene\scene.py:1074 in interactive_embed       │
│                                                                                                  │
│   1071 │   │                                                                                     │
│   1072 │   │   self.camera.model_matrix = self.camera.default_model_matrix                       │
│   1073 │   │                                                                                     │
│ ❱ 1074 │   │   self.interact(shell, keyboard_thread)                                             │
│   1075 │                                                                                         │
│   1076 │   def interact(self, shell, keyboard_thread):                                           │
│   1077 │   │   event_handler = RerunSceneHandler(self.queue)                                     │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\scene\scene.py:1131 in interact                │
│                                                                                                  │
│   1128 │   │   │   │   self.renderer.animation_start_time = 0                                    │
│   1129 │   │   │   │   dt = time.time() - last_time                                              │
│   1130 │   │   │   │   last_time = time.time()                                                   │
│ ❱ 1131 │   │   │   │   self.renderer.render(self, dt, self.moving_mobjects)                      │
│   1132 │   │   │   │   self.update_mobjects(dt)                                                  │
│   1133 │   │   │   │   self.update_meshes(dt)                                                    │
│   1134 │   │   │   │   self.update_self(dt)                                                      │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\renderer\opengl_renderer.py:398 in render      │
│                                                                                                  │
│   395 │   │   self.window.swap_buffers()                                                         │
│   396 │                                                                                          │
│   397 │   def render(self, scene, frame_offset, moving_mobjects):                                │
│ ❱ 398 │   │   self.update_frame(scene)                                                           │
│   399 │   │                                                                                      │
│   400 │   │   if self.skip_animations:                                                           │
│   401 │   │   │   return                                                                         │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\renderer\opengl_renderer.py:418 in             │
│ update_frame                                                                                     │
│                                                                                                  │
│   415 │   │   self.refresh_perspective_uniforms(scene.camera)                                    │
│   416 │   │                                                                                      │
│   417 │   │   for mobject in scene.mobjects:                                                     │
│ ❱ 418 │   │   │   self.render_mobject(mobject)                                                   │
│   419 │   │                                                                                      │
│   420 │   │   for obj in scene.meshes:                                                           │
│   421 │   │   │   for mesh in obj.get_meshes():                                                  │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\renderer\opengl_renderer.py:302 in             │
│ render_mobject                                                                                   │
│                                                                                                  │
│   299 │   │   │   │   render_opengl_vectorized_mobject_fill(self, mobject)                       │
│   300 │   │   │                                                                                  │
│   301 │   │   │   if config["use_projection_stroke_shaders"]:                                    │
│ ❱ 302 │   │   │   │   render_opengl_vectorized_mobject_stroke(self, mobject)                     │
│   303 │   │                                                                                      │
│   304 │   │   shader_wrapper_list = mobject.get_shader_wrapper_list()                            │
│   305                                                                                            │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\renderer\vectorized_mobject_rendering.py:193   │
│ in render_opengl_vectorized_mobject_stroke                                                       │
│                                                                                                  │
│   190 │   matrix_to_mobject_list = build_matrix_lists(mobject)                                   │
│   191 │   for matrix_tuple, mobject_list in matrix_to_mobject_list.items():                      │
│   192 │   │   model_matrix = np.array(matrix_tuple).reshape((4, 4))                              │
│ ❱ 193 │   │   render_mobject_strokes_with_matrix(renderer, model_matrix, mobject_list)           │
│   194                                                                                            │
│   195                                                                                            │
│   196 def render_mobject_strokes_with_matrix(renderer, model_matrix, mobjects):                  │
│                                                                                                  │
│ C:\Users\laith\Documents\GitHub\hydro_manim\manim\renderer\vectorized_mobject_rendering.py:213   │
│ in render_mobject_strokes_with_matrix                                                            │
│                                                                                                  │
│   210 │   │   end_offset = write_offset + submob.points.shape[0]                                 │
│   211 │   │                                                                                      │
│   212 │   │   points[write_offset:end_offset] = submob.points                                    │
│ ❱ 213 │   │   colors[write_offset:end_offset] = np.repeat(                                       │
│   214 │   │   │   submob.stroke_rgba,                                                            │
│   215 │   │   │   submob.points.shape[0],                                                        │
│   216 │   │   │   axis=0,                                                                        │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
ValueError: could not broadcast input array from shape (133956,4) into shape (366,4)
```

but produces 
![image](https://user-images.githubusercontent.com/70682032/134279024-e7889995-8592-41f7-9507-038c61c5a206.png)

with the default shaders




Discussion:

Resolving patch:
diff --git a/manim/renderer/vectorized_mobject_rendering.py b/manim/renderer/vectorized_mobject_rendering.py
--- a/manim/renderer/vectorized_mobject_rendering.py
+++ b/manim/renderer/vectorized_mobject_rendering.py
@@ -210,11 +210,14 @@ def render_mobject_strokes_with_matrix(renderer, model_matrix, mobjects):
         end_offset = write_offset + submob.points.shape[0]
 
         points[write_offset:end_offset] = submob.points
-        colors[write_offset:end_offset] = np.repeat(
-            submob.stroke_rgba,
-            submob.points.shape[0],
-            axis=0,
-        )
+        if submob.stroke_rgba.shape[0] == points[write_offset:end_offset].shape[0]:
+            colors[write_offset:end_offset] = submob.stroke_rgba
+        else:
+            colors[write_offset:end_offset] = np.repeat(
+                submob.stroke_rgba,
+                submob.points.shape[0],
+                axis=0,
+            )
         widths[write_offset:end_offset] = np.repeat(
             submob.stroke_width,
             submob.points.shape[0],


Test patch: