Specular Reflection
From C4 Engine Wiki
Yeah baby! This is specular reflection for objects in effect pass! This page allows you to construct your own specular reflection algorithm.
Specular Reflection Basis:
In the light pass, you can add the complex shader process: Specular Reflection. This page allows you to recreate this process from scratch.
First, the vectors:
- Ntan represent the Object Normal, (0,0,1) by default or the value in the Normal Map if bump is applied.
- H is the Tangent Halfway direction (available in the interpolants in Light Pass only). H = normalize(V+L)
- V = Tangent View Direction (available in the interpolants)
- L = Tangent Light Direction (available in the interpolants in Light Pass only)
Then combine those vectors to recreate Specular Reflection.
Specular Reflection In light Pass:
- Recreate a simple specular reflection: Ntan = (0,0,1), so H.Ntan = H.(0,0,1) = H.z so finally the algorithm is sat(H.z)^p
- Recreate a specular reflection with Normal Mapping:
- Recreate a specular reflection on a double sided object: Saturate H.Ntan permits not to apply specular reflection when the result is negative, i.e. when you see the back face. Saturate the absolute value of the result permits to calculate specular reflection on both sides.
Try to play with vectors to find other way specular reflection is apply (anisotropy, metal, etc...).
Specular Reflection In ambient Pass:
As H (Tangent Halfway Direction) and L (Tangent Light Direction) are not available in Ambient Pass, you have to recreate them first. H = normalize(V+L) where L as to be calculated before (static light) or dynamically by a script.
- Recreate a specular reflection in ambient pass for a static light.
- Recreate a specular reflection in ambient pass for a Flashlight. Flashlight is a light from the camera view so it can be replaced by the V. Thus normalize(V+V) = V.







