GLSL Programming/Unity/Two-Sided Smooth Surfaces

This tutorial covers two-sided per-pixel lighting (i.e. two-sided Phong shading).

Here we combine the per-pixel lighting discussed in with the two-sided lighting discussed in.

Shader Coder
The required changes to the code of are: new properties for the back material, deactivation of culling, new local variables for the material parameters in the fragment shader, which are set either to the front material parameters or the back material parameters according to. Also, the surface normal vector is negated in case a back face is rendered. It's actually quite straightforward. The code looks like this:

As always, the only difference between the two passes is the lack of ambient lighting and the additive blending in the second pass.

Summary
Congratulations, you have reached the end of this short tutorial. We have seen:
 * How two-sided surfaces can be rendered with per-pixel lighting.