XNA Fur Rendering
// November 22nd, 2009 // No Comments » // My Graphics Programming
I was pretty sick last weekend, and sticking to my odd “get sick, code something” habit, I decided to finally try to make a fur rendering demo. I read a few articles about it years ago, so I knew the general concept behind it: render lots of “shells” around the model with an appropriate fur texture. The fur texture is basically a transparent texture with dots on it, and as the shells get layered on top of each other, the dots are essentially extruded into individual furs (without having to render each fur individually).
I’ve seen fur effects used in a few games, notably Star Fox Adventures for the GameCube, and the more recent Super Mario Galaxy for the Wii. I have no idea if they are using the same technique, but the Super Mario Galaxy queen bee looks similar.
What really got me thinking about finally starting this demo was an article I found on reddit. The article is from xbdev.net, and is (appropriately) called Generating Fur in DirectX or OpenGL Easily. While it’s not the most well-written article I’ve ever read (especially the comments in the provided code), it has some nice diagrams and screenshots of the technique in progress. If you’re interested in learning more about fur rendering, I’d suggest starting there.
After reading that article, I decided to go for it. I got the basics up and running pretty quickly. I added some camera controls and the ability to change a few things on the fly (like the fur length), mostly for testing purposes. One of the first things you notice with basic fur rendering is that everything is the same color, so you only notice the “fur” aspect of it around the edges. I added some basic N dot L lighting and I modified the fur by the model’s texture so it wasn’t all the exactly the same. This helped a bit, but the hairs were still bleeding into each other and not looking very fur-like. Clearly some sort of individual fur shading was needed.
I went back to the fur article linked above to check out their shadowing technique. To be honest, I’m not 100% sure I even implemented it the way they explained it (which I would have to describe as “poorly”). The gist of it is to re-render each shell, offsetting the texture a bit and making it look like a shadow. I didn’t like it from the start. Double the number of shells that need to be rendered? No thanks. I didn’t need to render an actual shadow of each fur. I just wanted the fur to get darker the “deeper” it was, so that’s what I did. The shells closer to the model are rendered a bit darker, and they get brighter as they get further away. The last piece of this puzzle was to make sure the model itself was rendered slightly darker, giving the illusion that the fur is shading the scalp.
One thing I did implement from the article was the concept of gravity affecting the fur. Each shell is offset a tiny bit in the negative Y direction (based on a power function) to give the impression that the fur is bending due to gravity. It’s a very nice effect, and it was easy to implement. I decided to take it a step further and make the fur react as you drag the model around. When you drag it, the fur gets stretched in the opposite direction and slowly interpolates back to its normal “bent” position. It’s fake physics, but it looks neat.
I’ve got some plans to continue this the next time I’m bored. A few features off the top of my head would be: multiple models & swapping at run time, more controls for different settings (gravity, fur density, etc) and adding a fur length map, so certain sections of the model can have different lengths of fur (or be bald).
UPDATE: I created a newer version of my fur demo using Luster. This one uses a fur map to mask out non-fur areas.
-Chris

