KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am using 3 vertex buffers at one time (I actually have many, but there are only 3 used at once). They contain information which is mixed together in a shader to produce the desired output -- a 2D skeletal animation. There are two bone buffers, which contain the position/rotation/scale for a bone at any given frame. There is one skin buffer, which contains the vertices for rendering a region of a texture as if it were at the world origin, (0,0) . In the shader, the two bone buffers are combined with an easing value (passed through as a uniform), and then by transforming the skin vertices, the parts are rendered in the correct places. This performs great, and is a good improvement on where I started out -- I calculated everything on the GPU, and just passed in x/y/u/v coordinates, I was limited by streaming so much data to the GPU each frame. However, there's a lot of duplicated information. The skin buffer contains only what it needs, 4 vertices per skin part, each unique. When it gets combined with the bone though, each bone vertex is duplicated 4 times -- to match the skin buffer. Working on mobile, this is a pain in the nuts, because I'm running low on memory, and it annoys me that there's so much wastage. This is how the buffers would look if there were just 1 bone. Bone buffer 1 [x1,y1,rot1] [x1,y1,rot1] [x1,y1,rot1] [x1,y1,rot1] Bone buffer 2 [x2,y2,rot2] [x2,y2,rot2] [x2,y2,rot2] [x2,y2,rot2] Skin buffer [xA,yA,uA,vA] [xB,yB,uB,vB] [xC,yC,uC,vC] [xD,yD,uD,vD] I won't post the full shader, because there's too much extra stuff going on in there (rotation and scale work similarly): attribute vec2 bonePosition1; // x1, y1 attribute vec2 bonePosition2; // x2, y2 attribute vec2 skinPosition; // xA (or xB .. ), yA
Tags (comma-separated)
Save Edits
Cancel