What is the current trend for skinning?

Started by
7 comments, last by MJP 11 years, 6 months ago
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?
Advertisement
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.
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.
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.

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.


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
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.

Niko Suni

Ok just 1 last question = in DirectX11.1 you can stream out from the vertex shader,instead of the geometry shader.Is this hardware dependant,or can my directx 11.0 gpu do it?
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.

Niko Suni

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.

This topic is closed to new replies.

Advertisement