Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Your two options here have a trade off: supply twice the geometry once and interpolate between that, or supply only one set of geometry, but do so for each frame. You have to weigh geometry size vs. upload bandwidth.</p> <p>Given my experience with iOS devices, I'd highly recommend option 1. Uploading new geometry on every frame can be extremely expensive on these devices. </p> <p>If the vertices are constant, you can upload them once into one or two vertex buffer objects (VBOs) with the <code>GL_STATIC_DRAW</code> flag set. The PowerVR SGX series has hardware optimizations for dealing with static VBOs, so they are very fast to work with after the initial upload.</p> <p>As far as how to upload two sets of vertices for use in a single shader, geometry is just another input attribute for your shader. You could have one, two, or more sets of vertices fed into a single vertex shader. You just define the attributes using code like</p> <pre><code>attribute vec3 startingPosition; attribute vec3 endingPosition; </code></pre> <p>and interpolate between them using code like</p> <pre><code>vec3 finalPosition = startingPosition * (1.0 - fractionalProgress) + endingPosition * fractionalProgress; </code></pre> <p><strong>Edit:</strong> Tommy points out the <code>mix()</code> operation, which I'd forgotten about and is a better way to do the above vertex interpolation.</p> <p>In order to inform your shader program as to where to get the second set of vertices, you'd use pretty much the same <code>glVertexAttribPointer()</code> call for the second set of geometry as the first, only pointing to that VBO and attribute.</p> <p>Note that you can perform this calculation as a vector, rather than breaking out all three components individually. This doesn't get you much with a <code>highp</code> default precision on current PowerVR SGX chips, but could be faster on future ones than doing this one component at a time.</p> <p>You might also want to look into other techniques used for vertex skinning, because there might be other ways of animating vertices that don't require two full sets of vertices to be uploaded.</p> <p>The one case that I've heard where option 2 (uploading new geometry on each frame) might be preferable is in specific cases where using the Accelerate framework to do vector manipulation of the geometry ends up being faster than doing the skinning on-GPU. I remember the Unity folks were talking about this once, but I can't remember if it was for really small or really large sets of geometry. Option 1 has been faster in all the cases I've worked with myself.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload