GLSL Programming/Unity/Translucent Surfaces

This tutorial covers translucent surfaces.

It is one of several tutorials about lighting that go beyond the Phong reflection model. However, it is based on per-pixel lighting with the Phong reflection model as described in. If you haven't read that tutorial yet, you should read it first.

The Phong reflection model doesn't take translucency into account, i.e. the possibility that light is transmitted through a material. This tutorial is about translucent surfaces, i.e. surfaces that allow light to transmit from one face to the other, e.g. paper, clothes, plastic films, or leaves.



Diffuse Translucency
We will distinguish between two kinds of light transmission: diffuse translucency and forward-scattered translucency, which correspond to the diffuse and specular terms in the Phong reflection model. Diffuse translucency is a diffuse transmission of light analogously to the diffuse reflection term in the Phong reflection model (see ): it only depends on the dot product of the surface normal vector and the direction to the light source — except that we use the negative surface normal vector since the light source is on the backside, thus the equation for the diffuse translucent illumination is:

$$I_\text{diffuse trans.} = I_\text{incoming}\,k_\text{diffuse trans.} \max(0,\mathbf{L}\cdot(- \mathbf{N}))$$

This is the most common illumination for many translucent surfaces, e.g. paper and leaves.

Forward-Scattered Translucency
Some translucent surfaces (e.g. plastic films) are almost transparent and allow light to shine through the surface almost directly but with some forward scattering; i.e., one can see light sources through the surface but the image is somewhat blurred. This is similar to the specular term of the Phong reflection model (see for the equation) except that we replace the reflected light direction R by the negative light direction -L and the exponent $$n_\text{shininess}$$ corresponds now to the sharpness of the forward-scattered light:

$$I_\text{forward trans.} = I_\text{incoming}\,k_\text{forward trans.} \max(0, \mathbf{-L}\cdot \mathbf{V})^{n_\text{sharpness}}$$

Of course, this model of forward-scattered translucency is not accurate at all but it allows us to fake the effect and tweak the parameters.

Implementation
The following implementation is based on, which presents per-pixel lighting with the Phong reflection model. The implementation allows for rendering backfaces and flips the surface normal vector in this case. A more elaborated version could also use different colors for the frontface and the backface (see ). In addition to the terms of the Phong reflection model, we also compute illumination by diffuse translucency and forward-scattered translucency. Here is the part that is specific for the fragment shader:

Complete Shader Code
The complete shader code defines the shader properties for the material constants and adds another pass for additional light sources with additive blending but without the ambient lighting:

Summary
Congratulations! You finished this tutorial on translucent surfaces, which are very common but cannot be modeled by the Phong reflection model. We have covered:
 * What translucent surfaces are.
 * Which forms of translucency are most common (diffuse translucency and forward-scattered translucency).
 * How to implement diffuse and forward-scattered translucency.