Sign in to follow this  
mrheisenberg

What is the current trend for skinning?

Recommended Posts

mrheisenberg    362
It has been a while before I did a skinning system and the last time I did one was one the CPU with Directx9.Now I see people talking about vertex shader skinning,compute shader skinning,using textures for bone data..kinda confused here,which is the mosts efficient method?Is interpolation more efficient on the compute shader than in the vertex shader?

Share this post


Link to post
Share on other sites
Ashaman73    13715
I think, that it is pretty common to calculate the bone animation on the CPU and do the skinning in the vertex shader with registers for the bone orientation (quaternion+position or matrix), though saving this data in a texture which will be accessed in the vertex shader could have some advantages.

Share this post


Link to post
Share on other sites
Hodgman    51341
Yeah the current 'baseline' implementation would be calculate bone anim on CPU, put bones into constant registers as matrices, and do skinning with 4 weights in the vertex shader.

Instead of using 4x4 matrices, the simplest improvement is to just use 4x3 matrices (or 3x4, depending) so that you only need 3 registers per bone -- you can do this because one row/column will always be [0,0,0,1].
You can then get down to just 2 registers per bone by using dual-quaternion skinning, or using some kind of rotation+translation format.

On some cards, you might get better fetch performance by putting the bone data into a texture, or a 'tbuffer' instead of a 'cbuffer'.

Another issue is that in most modern renderers, each model is drawn more than once per frame -- e.g. one from a light's point of view for shadow mapping, and then once for the main camera. With vertex-shader skinning, this means that the model is skinned twice (which doesn't occur with CPU skinning).
You can avoid this issue on DX10 cards by using "stream out" -- where instead of rasterizing your skinned vertices, you instead write the results to a vertex buffer. You can then use this temporary vertex buffer to draw the mesh multiple times (without running skinning again).
On DX11, you also have the option of using a compute shader to do this work.

Share this post


Link to post
Share on other sites
mrheisenberg    362
[quote name='MJP' timestamp='1348819195' post='4984654']
With DX11.1 you can output to a buffer from a vertex shader, which is even better than using a compute shader or stream out since you can just output the skinned verts while rasterizing your first pass.
[/quote]

won't that become overly complicated when you implement advanced animations(animation blending,adjusting character body to match the angle of the terrain he is standing on,ect.),you wold have to send a huge amount of matrices

Share this post


Link to post
Share on other sites
Nik02    4349
You wouldn't stream out the bones, just the transformed vertices. The point is that you only need to apply the bone transforms (the heavy lifting of skinning) once, and then re-use the resulting mesh in subsequent drawing passes.

Share this post


Link to post
Share on other sites
Nik02    4349
You can stream out from vertex shader by bypassing the geometry shader. This functionality is available in 11.0 hardware.

The device's CreateGeometryShaderWithStreamOutput method also accepts vertex shader bytecode. You do get a geometry shader handle from that (and you need to set it as the active geometry shader), but it is just a straight pipe that sends the vertices from the VS to the SO buffer.

In addition to that, 11.1 hardware allows you to write arbitrarily to r/w shader resources from within all shader stages, which gives you a lot more flexibility. Edited by Nik02

Share this post


Link to post
Share on other sites
MJP    19790
UAV's from any shader stage is a 11.1 feature, so you'd need a fully-compliant FEATURE_LEVEL_11_1 video card with the necessary driver. I'm not sure if existing DX11 GPU's are fully compliant, but if any are I don't believe there are any publicly-available drivers yet. I could be wrong about that though.

Making a GS with stream out from a vertex shader still creates a "dummy" geometry shader. Either way the really bad part about doing it that way is that you can't rasterize a triangle list while streaming out, because you'd have to stream out the fully-expanded list of vertices which is pretty inefficient. The alternative is to have a dedicated "stream-out" pass where you render with a point list topology and stream out from the GS, since that gives you a non-expanded buffer of vertices that you can index into with your index buffer.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this