Fur rendering is a highly expensive thing to do in realtime. In this guide, I’ll be showing you how to implement it through the shell rendering techinique. It can achieve some really nice results with low cost. If you want a more realistic approach, you can try using Geometric Shaders, that will not be covered in this tutorial, but you can find some great resources in this article about grass rendering, from Roystan.
Shell Rendering simulates fur by rendering various layers of our object. Like this:
To start, add these files into your project:
The shader is split in two parts, a .shader and a .cginc. This way it is easier to organize the code, once it has multiple passes. These files should be in the same folder.
Once that’s done, create a sphere and assign it a material that uses the shader you've just downloaded “Fur/SimpleFur”. You should see a lit model, now we need to create the math to do the offset of the mesh.
Start by opening the DynamicFurLib file. Inside it you will see two frag functions, and two vert functions. In the empty one, a function that does the normal based vertex offset will be implemented.
This is how the code looks:
Back to unity, you can see that the object is bigger. That’s because what you are seeing is actually a shell outside your object, we need to make it be rendered in a noisy way. So let's multiply it by a noise texture, this way:
Back to unity, assign a noise texture (you can use this) on the material, and you should get the following result:
The basics are ready, but this isn’t enough to give the illusion of fur being rendered. Copy and paste the second pass from the shader, increasing your furstep value until it reaches 1.
It’s getting close, but far from good. We need to have a crispier look on the edges. To achieve this the alpha can be reduced on each new pass.
For this, declare a var called _Density and update your frag function to:
You can create a variable and multiply it by the noise texture to increase the fur count.
And add gravity by adding a Rigidness variable and update your vert function to the following:
You can add rim Lighting to get a better result:
(I also added a _RimPower float value)
You can get the final assets for this tutorial by becoming a 5$+ Patron.