irrCg GPU Skinning: v0 - proof of concept

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki
Post Reply
fmx

irrCg GPU Skinning: v0 - proof of concept

Post by fmx »

For the past month I have looked into implementing GPU skinning into my own irrlicht driven engine, and I have decided to share some of my findings with everyone

First of all, huge thanks to Nadro and his awesome work on irrCg.

Luke did a fantastic job on creating the Skinned Mesh system for irrlicht, but I always felt hindered by its rigidity, not to mention the lack of flexible vertex formats in irrlicht anyways.

So for my engine I created a custom Character system to work around those limitations, rather than mess with irrlicht's source directly and make like difficult for myself in the future.

I took the Mesh Viewer code and plugged my Character system into it, which should allow fair comparisons to be made (note that most of the usual Mesh Viewer features dont work in this demo)

The binary can be downloaded here
http://www.megaupload.com/?d=EHY6OU2R

Image


The implementation is still fairly buggy (some models have dodgy bones, others dont even load), but its proof enough that irrCg CAN be used to GPU skin a model given the right data, without modifying the irrlicht source one jot.


The actual method is called Matrix Pallete Skinning and I got the idea from here:
http://developer.download.nvidia.com/SD ... aletteSkin


To get around the vertex format problem, I used Tangent vertices.

Bone indices are stored into the vertex color (RGBA for upto 4 possible pallete indices) and Bone Weights into the Binormal vector (XYZ for upto 3 possible influencing bones).
This limits the system to 3 bones total, however that isn't much of a problem at all :)
Normal mapping can also still be done, because the Tangent vector remains unchanged and the Binormal can be calculated at runtime anyway.


GPU Skinning is unlikely to be of any use for graphics cards below Geforce 7 or equivalent, my Geforce 6150SE does software skinning much faster than this GPU approach

Another problem with GPU skinning is that the transformed vertices cannot be retreived, so additional render passes (eg shadow mapping) would require GPU skinning to be done again, so clearly there is a set threshold where the performance would seriously suffer.

This demo is restricted to the OpenGL driver only for now, and the implementation still requires a lot of work.
But I will continue to upload demos and share my findings

The Cg shader itself is included with the binary, have fun :D



Demo notes:

+ works with ANY irrlicht compatible models
+ supports models with an INFINITE number of bones!
+ keyframe animations
+ Cg shader code provided

- crashes on termination, buggy cleanup :oops:
- buggy joint rotations sometimes
- some models fail to import correctly, not related to actual GPU skinning implementation
- other Mesh-Viewer settings aren't currently implemented
Last edited by fmx on Wed Sep 22, 2010 10:06 am, edited 1 time in total.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

No offence to BlindSide's XEffects
Ok you didn't have to mention mine if you didn't use it :P

PS: To be a bit useful rather than just argue about libraries, I provide you my old implementation which I worked closely with Luke to develop: http://irrlichtirc.g0dsoft.com/BlindSide/HWSkin.zip (It's very old and I think there's a memory leak or two to be fixed...)
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
fmx

Post by fmx »

I didn't intend to start an arguement about libraries, it really doesn't matter at the end of the day how the shader callbacks are implemented.

But sometimes I feel irrCg needs a little more love :D
I didn't mention your xeffects to put it down, sorry if it sounds that way


I forgot to mention a few important things last night when I made the post.
There are a couple of important reason why i didn't share any code.

For starters, the implemention is still extremely buggy and heavily WIP.

This implementation works with an INFINITE number of bones :wink:
(or as high as memory and irrlicht allow)

Although the shader only works with 20 bone matrices, they are PALETTES.
My system takes care of the paletting and works independently of the Luke's.

Just test it out in the demo
load in a skinned model you know has more than 50 bones or more (some of my test characters had 100+ bones) and it should work, wheras in any implementation derived from the current Skinned-Mesh system, the GPU would entirely ignore the bones above that amount. :)

Ofcourse the demo is still buggy, and it produces a lot of false positives because of my awry model importing, which has nothing to do with the actual GPU skinning side of things.
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Eh the main reason of my post was to share my implementation, which skimming you post I don't see any mention of. Maybe there is something in there that would be useful.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Post Reply