Open McManning opened 4 years ago
An update on this - I started working directly with Blender C structs to access mesh data. I'm basically using .to_pointer()
methods exposed by bpy objects combined with np.ctypeslib
and python buffers to pipe that struct data right into GLSL buffers. It's a 2x-4x speed boost, with the caveat of being more unstable as changes to Blender C structs breaks support easily (already had this happen going from 2.82 to 2.83).
If working with just vertex positions and normals is fine, then the safer method of using foreach_get
works. But once you start adding multiple UV channels, split normals, etc, it starts to become a much wider gap in performance.
There's a noticeable performance bottleneck when modifying a mesh with a lot of faces (anything over 800k on my Radeon 7) - which makes sculpting with the shader running less fun.
My assumption is that it's the step of extracting vertex/triangle arrays from the mesh and uploading that back to the GPU on every change - but I don't know a more performant way to do it and stay in Python-land.