Hi, I’m new here but not new to OpenGL in general. I’m writing a game engine very slowly and very carefully, and am in the planning stages for adding in vertex animation (morphing).
I ran into a load of issues while thinking about how, step by step, the whole system would work:
-
Passing large amounts of input (such as keyframe data) into a vertex shader is not easy. The best case is to pack it into a texture and manipulate it in a fragment shader perhaps? Manipulations would involve computing the current pose for each mesh from a set of keyframes.
-
If you do use a texture, how do you get back the results to CPU in case you need them? Maybe a VBO would be good for this, but maybe there’s a better solution?
-
Vertex shaders attach after frustum culling. This makes sense, but I need to attach an animation shader before culling. Otherwise, a mesh whose animation involves growing and shrinking would disappear once the original mesh leaves the frustum. I’ve heard complaints about this when people morph a flat plane of quads into a terrainmap. The terrain disappears as soon as the original plane disappears. I have personally not witnessed this, so maybe I’m wrong. OpenGL does not allow disabling frustum culling, and I would loathe to disable such a common-sense feature just because I want to animate some stuff.
-
What is the best way of identifying the vertex and mesh inside of a vertex shader? Say I receive a vertex in the shader, and its coordinates are (34.0, 2.1002, 3.455). How do I know what to map it to? I suppose that I can hash the coordinates into some value and compare the hash against a list (stored in a texture) to find which mesh it belongs to and the id of the vertex in that mesh.
-
Assuming the identification system in (4), what do I do with culling? In the event that I cannot avoid frustum culling in some way, I’ll be receiving generated vertices that came from my mesh’s edges being clipped against the frustum. These new vertices don’t occur in the original mesh, and therefore cannot be identified easily or animated.
Maybe I’m just an idiot and none of these issues are really issues, but darn it, I want my GPU-accelerated mesh animation…