Monday, October 22, 2007

"Sub Surface Scattering? What the hell is that?" some people might be asking themselves. Subsurface scattering in order to answer your question, is a phenomenon in which light hits the surface of an object and is then scattered throughout the object, lighting it both on the surface and under neath. A good example cane be seen here:

Subsurface scattering (or SSS) when light interacts with the surface of a material, and exits the surface at a different point than it entered. The light will generally penetrate the surface and be reflected a number of times at irregular angles inside the material, causing light to look soft and the material to look translucent or opaque. Hold your hand up to sunlight and you will see the effects of Subsurface scattering as the sunlight enters the webbing between your fingers and exits again, causing your skin to illuminate from the inside. Subsurface scattering is extraordinarily useful in graphics and animation as far as generating a realistic character with skin that is almost lifelike in bright lights.

Depth Map based SSS

One method of generating SSS is accomplished by estimating this distance inside an object, in a manner similar to shadow mapping. The scene is rendered from the light's point of view into a depth map, so that the distance to the nearest surface is stored. The depth map is then projected onto it using standard projective texture mapping and the scene re-rendered. In this pass, when shading a given point, the distance from the light at the point the ray entered the surface can be obtained by a simple texture lookup. By subtracting this value from the point the ray exited the object we can gather an estimate of the distance the light has traveled through the object.


The measure of distance obtained by this method can be used in several ways. One such way is to use it to index directly into an artist created 1D texture that falls off exponentially with distance. This approach, combined with other more traditional lighting models, allows the creation of different materials such as Marble, Jade, and wax.

Potentially, problems can arise if models are not convex, however there are occasional workarounds, although perfection is still a long way off.

Sometimes light isn’t diffused when passing through object using this technique; back features are clearly shown. One solution to this is to take multiple samples at different points on surface of the depth map. Alternatively, a different approach to approximation can be used, known as texture-space diffusion.




Texture Space Diffusion

As noted at the start of the section, one of the more obvious effects of subsurface scattering is a general blurring of the diffuse lighting. Rather than arbitrarily modifying the diffuse function, diffusion can be more accurately modeled by simulating it in texture space. This technique was pioneered in rendering faces in The Matrix Reloaded, and now is used as a realtime animation technique.

The method unwraps the mesh of an object using a vertex shader, first calculating the lighting based on the original vertex coordinates. The vertices are then remapped using the UV Texture Coordinates as the screen position of the vertex, suitable transformed from the [0, 1] range of texture coordinates to the [-1, 1] range of normalized device coordinates. By lighting the unwrapped mesh in this manner, we obtain a 2D image representing the lighting on the object, which can then be processed and reapplied to the model as a Normal Map. To simulate diffusion, the light map texture can simply be blurred. Rendering the lighting to a lower-resolution texture in itself provides a certain amount of blurring. The amount of blurring required to accurately model subsurface scattering in skin is still under active research, but performing only a single blur poorly models the true effects. To emulate the wavelength dependent nature of diffusion, the samples used during the (Gaussian) blur can be weighted by channel. This is somewhat of an artistic process. For human skin, the broadest scattering is in red, then green, and blue has very little scattering.

A major benefit of this method is its independence of screen resolution; shading is performed only once per texel in the texture map, rather than for every pixel on the object. An obvious requirement is thus that the object have a good UV mapping, in that each point on the texture must map to only one point of the object. Additionally, the use of texture space diffusion causes implicit soft shadows, alleviating one of the more unrealistic aspects of standard Shadow Mapping.




Image:Scattering-example.jpg

marble is a good example of a meaterial that requires subsurface scattering.


No comments: