Subsurface scattering is a term used in computer graphics to describe the method for attaining the 'softer' look of natural materials such as skin, marble, and milk. The term comes from medical and light science. It means that light coming into the material scatters around below the surface, and then comes out again. It may be useful to know that even tiny amounts of scattering can enhance the apparent ''softness'' of a surface.
mental images provides two kinds of shaders for subsurface scattering. One approach implements subsurface scattering with volume scattering -- a physically correct simulation of the light scattering underneath the surface. The second approach does not use volumetric scattering at all, but rather simulates its appearance using light maps in a layered approach. This provides for a faster, easier-to-control method for achieving the SSS effect, and is especially tailored for rendering human skin.
Each approach has its unique strength regarding the tradeoff of desired visual effect and performance. For example, the physical approach uses photon tracing and handles the ability to pass caustics through the medium using the SSS material. It handles deeper SSS effects. Whereas, the non-physical approach doesn't require photon tracing, and handles shallower softening effects such as skin, leaves, grass, wax, plastic, etc. The information in the following sections should help you understand which approach is right for your project.
The physical subsurface scattering shader simulates the volumetric scattering of light underneath the object's surface. It uses a photon map (kd-tree) dedicated to this object to store the photon information. A photon map isn't a map as much as a list of 3D points with light information. To illustrate this, the picture at right shows these photons on the inside of the dragon object. At each 3D location inside the dragon, the photon shader stores data about the incoming light. Each ray can bounce around inside, scattering and storing multiple times within the object. |
The parameters of this shader control how the light bounces around with actual physical coefficients for absorption and scattering.
The simulation separates into three types of scattering -- diffusion, single scattering, multiple scattering -- as depicted in the following diagram.
The physical SSS shaders require photon tracing. Either Global Illumination or Caustics must be enabled. Check your light energy, or Photon Intensity in Maya 6.
This is a general tip when using GI or caustics. Avoid point lights because they shoot photons 360 degrees in a sphere around the point. In general, use a spot light with a beam centered on the object(s) receiving the photons. For more control, try using two coincident lights: one for general lighting, and one dedicated to filling the photons in the SSS object.
This can be an extremely useful visualization tool. Start with max photons = 1, and very small radius to envision photon coverage. Each is stored as primary red, green or blue color.
Original scene created in Maya, and exported to mi file by Dominika Waclawiak. Permission to hand edit and rerender also courtesy of Dominika Waclawiak.
As you increase the number of max photons in the misss_physical shader, the colors blend together. Keeping that in mind, go back and adjust the light energy/intensity and number of stored photons to ensure there are enough in your volume. For your reference, the above images store 50,000 global illumination, and 50,000 caustic photons. Compare to using 5,000 apiece below.
[5,000 photons apiece] |
[original 50,000 apiece] |
[5,000 photons apiece] |
[original 50,000 apiece] |
The material and transmission inputs of the physical SSS shader can take in textures or other material shaders. If these inputs are too complex, it can confuse your understanding of the sss parameters. So when learning how to use the parameters, start with a simple color, or lambert shader for the material. To envision just the photons, try a black material, white transmission color.
material 0 0 0, transmission 1 1 1 1 |
[original green texture] |
material 0 0 0, transmission 1 1 1 1 |
[original green texture] |
Use existing coefficients, for example from milk, or dragon, and then turn the conversion factor to match your world units. Keep in mind that the coefficients supplied by mental images are in millimeters, so that a conversion factor of 25.4 will change units to inches, and about 300 will convert to feet. You may also need to readjust the light energy. The conversion factor above is 10. Below we try some values on either side of that.
To get a better feel for some of these parameters (especially what the units mean), we'll create a unit cube, using a spot light from the front while we look at single photons scattered into the cube from the side. If you want to skip the setup, we have both an .ma
file and an .mi
file. The .mi
file is stripped of maya specific dependency.
.mi file |
Maya 6 .ma file |
---|---|
cubesss.mi |
cubesss.ma |
In this scene, the spot light has an energy of 1000 1000 1000, (color of 1 1 1 and intensity of 1000), with 20,000 globillum photons.
Using our tips, the cube has black material and white transmission, 1 for max_photons and 0.4 max_radius. Across r, g and b, the absorption coefficient is low at 0.001, and the scattering coefficient is set to 1. In our unit space, we're thinking that this is in millimeters (mm), so we set the scale conversion up to 20, to indicate just less than an inch on each side of the cube. Here are all the parameters:
material
0. 0. 0. 1.
transmission
1. 1. 1. 1.
ior
1.
absorption_coeff
0.001 0.001 0.001
scattering_coeff
1. 1. 1.
scale_conversion
20.
scattering_anisotropy
0.
depth
4.
max_samples
4
max_photons
1
max_radius
0.4
approx_diffusion
on
approx_single_scatter
off
approx_multiple_scatter
on
lights
["spotLight1"]
To view these parameters in the attribute editor for the maya scene supplied above, select misss_physical1
. [I tend to just type it in the sel text entry box.]
Lets talk about mean free path length. It is the typical distance a photon will travel before being either absorbed or scattered. In our case, we set the absorption coefficient low enough that we'll just look at scattering. Think of yourself as a photon going through a room with tables in it; the higher the scattering coefficient, the more tables. The average distance you can freely travel is your free path length.To get this distance, invert the coefficient, ie, in our example, 1/1. Except that we also have a scale conversion factor. Multiply the scale conversion by the coefficient before inverting, so the mean free path length in our example will be 1/20 of the length of the unit cube. If the coefficient were 0.5, it would be twice as long, or 1/10.
Next consider depth, the distance at which diffusion takes over instead of multiple scattering. Depth is a multiplier of mean free path length, and therefore depends on the coefficients as well. For example, our depth of 4 indicates that the depth is 4 * 1/20, or 1/5 of the unit cube. Diffusion occurs below this depth from the surface, while multiple scattering occurs above this depth. When setting up correctly, values between 2-8 are typical. In this example, if depth were 10, ie 10/20, at 1/2 of the unit cube, the diffusion layer would dissappear because there is not much depth that far in from the surface of the unit cube.
Note the apparent layer on the left side of the cube where the light is entering. Now if we isolate diffusion from multiple scattering, we can envison the layers more clearly.
multiple scatter only |
diffusion only |
both |
Now put both multiple scattering and diffusion back on, and lets examine different depths. Try re-rendering with a depth of 2, and it will go closer to the left side. Try rendering with a depth of 6, and it will go further from the left side.
depth 2 |
depth 4 |
depth 6 |
One more note. This might also be a good situation to experiment with max_samples, the number of photon map lookups evaluated in single/multiple scattering. At 1 it is on the surface, and more samples go deeper. Try setting samples to 1, and you'll only see samples taken singly at the surface for generating color. Try getting by with as few samples as possible. The following pictures all have a depth of 4.
samples 1 |
samples 4 |
samples 16 |
Once you think the photons are behaving, increase the max_photons and max_radius to smear the color. Note that max_radius
is divided by scale_conversion
, so we set it to 20 to cover the whole interior of the cube. Then by increasing the photons, we see:
max_photons 10 |
max_photons 100 |
max_photons 1000 |
Note that the inner diffusion layer is adding quite a bit of energy. If you increase the absorption coefficients, it will decrease the energy of light reaching below depth. Here, with absorption at 0.01 0.01 0.01, and max_photons 1000, we see the different layers. Also note the blue tint.
multiple scatter only |
diffusion only |
both |
And now here's a similar example, using a grape from Dominika, which also adds a lambert shader with a texture into the material slot of the misss_physical shader.
max_photons 10 |
max_photons 100 |
max_photons 1000 |
Maya 6 .ma file for above |
---|
grapesss.ma
|
If using the Maya scene file, change the texture maps to link to some of your own.
For those wishing to work with mi files, we put a grape in the place of the cube in the above example. And for more, we added GI and caustics to the floor.