skin shading - texture space diffusion - part 1

Tuesday, August 25, 2009 | |

I tried to improve the build-in shaders, to see if it would be enough for a decent skin shading. Often the specularity of virtual skin does not look right, so I decided to take care of that first. The standard shaders had only one fixed value for "shininess" per material and the specular intensity was not angular-dependent. So I extended the Bumped Specular shader to take an additional specular-texture, where the roughness is stored in the alpha channel and an fresnel term, that increases the intensity at very low angles.

Alright... but it does not look soft and there is no depth at all. All the light is simply reflected at the surface of the skin. In reality though only the "specular" is reflected at the surface, because specular is nothing but a more or less diffuse reflection of a lightsource. The major part of the light (about 94%) travels into the skin, gets scattered multiple times and receives its typical color and gives the skin its soft appearance.

In offline rendering this effect can be achieved with expensive subsurface scattering algorithms, but for realtime applications this is not a option at the moment. But there is a nice way to fake this effect.

The trick is called Texture Space Diffusion: For each frame the skin mesh is rendered in a prepass in texture space (by simply setting the vertex coordinates to the uv coordinates in the vertex shader). The resulting image is blurred several times and then used in the normal rendering process for the diffuse part of the lighting.

One of the most eye-catching effects of the light being scattered inside the various skin layers, is the red colorbleeding e.g. at hard shadowedges. This becomes even more visible when looking at the different color channels of a photo of real skin:

As you can see, the details decrease from blue to red. The red channel seems to me much more blurry. So when it comes to the final rendering on screen, we can now access the individual blur-steps of the lightmap and use them for each of the three color channels with different weights.

I still got some problems with my implementation, but here are the results so far:

More technical infos on the implementation in Unity will come soon...

Next part: Skin shading - texture space diffusion - part 2

0 comment(s):

Post a Comment

Note: Only a member of this blog may post a comment.