Hello Monogame Community
I’ve recently started working on a new project using Monogame and would like some advice on how to handle the rendering of a custom deformed 3D mesh, here’s what I’m doing.
Way back when I first started playing with 3D about 15 years ago I was using Dark Basic Professional, which allowed me to directly input the position offset and rotation of all bones in a mesh during runtime and I developed my own custom way of animating that did not use the traditional keyframe method.
In addition to implementing something like that I also want to be able to handle the actual mesh deformation with my own code, and this creates a problem.
While I have played with RB Whitaker’s XNA tutorials and am happy with basic 3D in Monogame there seems to be nothing for handing custom mesh deformation.
I have already considered a couple of options for how to handle this but I’m not happy with either of them:
Method 1 - Recreate the Vertex Buffer every frame to update the mesh data. I seriously do not believe this would be very efficient since I imagine the Vertex Buffer was not designed for dynamic data. It probably would work, but it would be slow.
Method 2 - Pass the updated mesh data into the shader via an array. This would probably be even worse than Method 1 performance-wise as well as being incredibly wasteful on the graphics pipeline, since not only would the mesh data be passed via the Vertex Buffer but into the shader parameters as well, plus I’d need to ensure the base vertex data has enough data for the shader to be able to allocate the deformed data correctly.
Of those two I prefer Method 1, but I’m sure there must be a better way of handling this.
Also, I don’t want to handle the actual mesh deformation inside the shader since I may need to render the deformed meshes multiple times, the articles I have read suggest handling the mesh deformation on the cpu in those cases.
Although I could certainly try these methods out and see how well they perform, I would still be left wondering if there is a better way I could use right from the outset.
Any suggestions, advice or links to tutorials would be greatly appreciated.
Avan
PS: I apologise if my use of terminology is wrong, I’m am mostly self-taught in programming.