Sign in to follow this  
ill

Deferred Shading Decals on Animated Characters

Recommended Posts

I was doing some reading on deferred shading decals and how you basically use projective texturing similarly to shining a flashlight on an object or shadowmapping.

 

However, if I have an animated character with a bloodstain on it, the bloodstain won't deform with the model this way.  The worst is if I have a bloody hand on a character, and the character moves the hand near its leg, suddenly the decal might project onto the leg.  The deferred decal algorithms all mention how amazing this technique is and it seamlessly handles static and dynamic geometry, but they don't talk about how to handle animated characters how I want.

 

It may not be too noticeable if I keep the decal small, but then it's a bit hard to have an effect similar to paint covered zombies in Halflife 2: http://www.visualwalkthroughs.com/halflife2/ravenholm1/30.jpg

Edited by ill

Share this post


Link to post
Share on other sites

Its a matter of having the projection matrix for the decal texture attached to the skeleton appropriately. This way, as the rigged character moves around, the projection axis for the blood splatter also moves with the model. 

 

For characters that are skinned to multiple bones, you effectively want to anchor your decal projection matrix to multiple bones too. Basically, take the vertex closest to the center of the projection and use its skinning weights etc.

Share this post


Link to post
Share on other sites

I can understand keeping the decal itself relative to the skeleton of the character.  Like if the character is holding a gun, the gun is relative to the hand bone.  I'd keep the decal relative to whatever bone was hit on the character.

 

But, in this image, the blood decal needs to somehow deform along with the geometry of the character.

http://media.moddb.com/images/downloads/1/22/21410/wounds.jpg

 

If I simply kept the decal relative to the arm of the character, the blood wouldn't move with the rest of the model as parts of it stretch due to the animations.  Figuring out the specific triangles and vertices of the model affected may not be very good for performance either.

 

The easiest solution I can come up with right now which I mentioned is just drawing the whole model as if I was doing an additive forward lighting pass, but only drawing the decal.  The decal would be projected relative to the original pose of the model, so each vertex knows the uvs of the decal texture to reference, but then transform the vertices to the current animation pose.

Share this post


Link to post
Share on other sites

Yep, its a complex problem.

 

Left 4 Dead 2 actually came up with a completely different way of doing their gore model which involves essentially masking between two models, instead of projective texturing. There's a whitepaper on it floating around somewhere. Probably available on the valve website.

Share this post


Link to post
Share on other sites

I found this.

 

http://www.valvesoftware.com/publications/2010/gdc2010_vlachos_l4d2wounds.pdf

 

I never realized the wounds were that amazing in that game.  I always thought some of those were precanned somehow.

 

They do talk about projective texturing though for the blood.

 

 

 

I also found this Dice slide deck.  They talk about using the geometry shader.

http://www.slideshare.net/repii/02-g-d-c09-shadow-and-decals-frostbite-final3flat

Edited by ill

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