This is the main shader that does the actual scattering. It is highly modular and works with several plug-in shaders, and it can even be cascaded into itself for multi-layer scattering (as is done in misss_fast_skin_phen). It layers the results from the plug-in shaders with the scattered light from the lightmap (optionally nonlinearly, in what is known as "screen" transfer mode in various compositing applications) and presents the result as a final composited color.
color "misss_fast_shader" (
color texture "lightmap",
color texture "depthmap",
shader "bump",
shader "diffuse_illum",
color "diffuse_color",
shader "specular_illum",
scalar "diffuse_weight",
color "front_sss_color",
scalar "front_sss_weight",
scalar "front_sss_radius",
color "back_sss_color",
scalar "back_sss_weight",
scalar "back_sss_radius",
scalar "back_sss_depth",
scalar "scale_conversion",
boolean "screen_composit",
boolean "output_sss_only",
scalar "falloff",
integer "samples",
)
apply material
version 4
struct {
color "result", # composited color
color "diffuse_result", # diffuse layer
color "diffuse_raw",
color "diffuse_level",
color "specular_result", # specular is not altered by the shader, but
# passed through from "specular_illum" sub-shader
color "front_result", # the "front" SSS layer
color "front_raw",
color "front_level",
color "back_result", # the "back" SSS layer
color "back_raw",
color "back_level"
}
"misss_fast_shader_x" (
color texture "lightmap",
color texture "depthmap",
shader "bump",
shader "diffuse_illum",
color "diffuse_color",
shader "specular_illum",
scalar "diffuse_weight",
color "front_sss_color",
scalar "front_sss_weight",
scalar "front_sss_radius",
color "back_sss_color",
scalar "back_sss_weight",
scalar "back_sss_radius",
scalar "back_sss_depth",
scalar "scale_conversion",
boolean "screen_composit",
boolean "output_sss_only",
scalar "falloff",
integer "samples"
)
apply material
version 4
This shader has identical behavior to misss_fast_shader but provides individual components of the shading results as output values before compositing them into the final color value. This supports multi-channel rendering approaches where compositing is performed in external packages.
The misss_fast_shader works conceptually with the layering of several light contributions, all stacked on top of each other. The actual compositing can be done with simple addition or with the softer looking screen compositing.

Plug-in shaders provide the actual contribution for the various layers. bump, diffuse_illum and specular_illum are the main plugin shaders that provide the shading model.
The bump shader affects the surface normal and is called before the "... _illum" shaders and hence affects their shading. However, no bump mapping is performed on the scattered light, since this happens under the surface. It is possible to include the effect of bump mapping in the light before it is scattered by including a bump map shader in the lightmapping phase.
To create the subsurface scattering itself, light from specially prepared lightmaps is gathered, weighted by distance, and tinted. The whole stack is finally layered together as follows, from top to bottom.
The following two observations are noteworthy: First, keep in mind that the contributions from layers 2, 3 and 4 are all multiplied with the " diffuse_color" parameter as an overall tinting and attenuation color for the diffuse contributions. Second, since the plugin shaders are simply called and layered in, it is possible to cascade several shaders together to create multiple layers as follows:

This graph shows how a 2nd iteration of misss_fast_shader is used as the diffuse_illum parameter of the 1st. This works because the scattering function receives its diffuse illumination from the lightmaps, and does not care about what diffuse_illum actually returns. It simply layers it into the mix.
This is precisely how the skin Phenomenon is implemented. A second shader is cascaded into the first, giving an extra layer. In principle, there is nothing preventing the stacking of an arbitrary number of shaders.
This is the lightmapping shader. It is required for the fast subsurface scattering to work [1]. It creates a lightmap and stores the front and back surfaces, their depth, and irradiant light intensities in one or more specially formatted lightmaps. Two modes of behavior are supported:
struct {
vector "point",
vector "normal"
}
"misss_lightmap_write" (
color texture "lightmap",
color texture "depthmap",
string "lightmap_group",
scalar "lightmap_size",
integer "write_lightmap",
scalar "scatter_bias",
shader "input"
)
version 4
apply lightmap
This is the supplied lightmap sampling shader. Any illumination shader can be used like mib_illum_lambert but this one is specially tuned for the job and has additional options for lightmap gamma correction, normal flipping and indirect light inclusion.
color "misss_lambert_gamma" (
color "ambient",
color "ambience",
color "diffuse",
boolean "indirect",
scalar "diffuse_curve",
integer "flip",
integer "mode",
array light "lights"
)
version 4
apply texture
This is a function geared towards recreating the peculiar specular characteristics of skin. It contains two specular highlights and glossy reflections with edge enhancement.
The shader can be used anywhere where specular highlights are needed. It has no diffuse component and hence needs to be layered together with another shader that provides the diffuse shading.
color "misss_skin_specular" (
scalar "overall_weight",
scalar "edge_factor",
color "primary_spec_color",
scalar "primary_weight",
scalar "primary_edge_weight",
scalar "primary_shinyness",
color "secondary_spec_color",
scalar "secondary_weight",
scalar "secondary_edge_weight",
scalar "secondary_shinyness",
scalar "reflect_weight",
scalar "reflect_edge_weight",
scalar "reflect_shinyness",
boolean "reflect_environment_only",
integer "mode",
array light "lights"
)
version 4
apply material
This is a utility "pass through" shader for Phenomenon building. It allows passing shaders as parameters to material Phenomena for items such as environment, photons, and displacement.
color "misss_call_shader" (
shader "shader",
shader "default_shader",
integer "mode"
)
version 2
apply material, texture, environment, photon, shadow, displace
Here is an example in pseudo code of using this shader in a Phenomenon:
declare phenomenon
material "my_phenomenon" (
color "my_special_color",
scalar "my_size",
shader "optional_environment",
...
)
shader "default_environment" "...." (
.... some environment shader ...
)
shader "env" "misss_call_shader" (
# call the passed shader
"shader" = interface "optional_environment",
# if none was passed, call our default
"default_shader" "default_environment"
)
environment = "env"
end declare
[1] The sample shader,
misss_lambert_gamma is optional. Any illumination shader can
be used.
Copyright (©) 1986-2009 by mental images GmbH