October 1, 2017

Evil pumpkins - or how to simulate subsurface scattering

If you are making a game, it's really important that the game looks good and that the game runs as fast as possible on the computer. It's often difficult to achieve both good looks and speed, so you have to cheat by using various tricks. One of the cheats I read about was how to achieve fast subsurface scattering in Unity. The idea behind subsurface scattering is that light tends to shine through some materials. For example, if you are holding up your hand against a strong light source, you will see that some of the light shines through you the edges of your fingers. To implement this effect I decided to make a Halloween pumpkin.

I began by making a pumpkin sculpture in Blender.

Making a sculpture in a 3D software is not that far from using physical clay. This is why the technique has become popular because it's easier to model something in clay than by adding triangles one after the other. The most popular sculpt software is ZBrush, but Blender has a sculpt part which is also working fine. The problem with a sculpture is that it consists of far too many triangles so it will fail if you put it in a game:

The solutions is that we once again have to cheat by making a less complicated model on the top of the more complicated model. This process is called retopo. The less complicated version looks like this:

But this less complicated version is kinda ugly. To make it look better we can use the more complicated version and "bake" normals and ambient occlusion, which is again a cheat to make an ugly model look better:

...and now it's just a matter of adding the subsurface scattering materials to the pumpkin, and it will look like this: