

Write it out then to the buffer at the end. Perform skinning only for the current frame bone matrices, but before writing out the skinned vertex to the buffer, load the previous value of the position and that is your previous frame vertex position. In a compute shader, this becomes quite straight forward, however.
#Ogre engine compute shader skin#
If we don’t do it in a compute shader, we probably need to skin each vertex with the previous frame bone transforms in the current frame to get the velocity of the vertex which is currentPos – prevPos (If we have deinterleaved vertex buffers, we could avoid it by swapping vertex position buffers). For that, we need out previous frame animated vertex positions. The render pipeline of Wicked Engine requires the creation of a screen space velocity buffer. The compute shader approach has some other nice features compared to the first point. But this can be done in a geometry shader with stream out capabilities as well.

Also, we avoid many render state setup, like binding bone matrix buffers for each render pass. we are using regular vertex shaders for those passes with the vertex buffer swapped out for the pre-skinned vertex buffer. So when we render our animated models multiple times, for shadow maps, Z-prepass, lighting pass, etc. One reason for this was the ugly API for the streamout which I wanted to leave behind, but the more important reason was that this could come with several benefits.įirst, compared to traditional skinning in a vertex shader, the render pipeline can be simplified, because we only perform skinning once for each mesh instead of in each render pass. Recently I have moved my mesh skinning implementation from a streamout geometry shader to compute shader.
