Eye Shader
From C4 Engine Wiki
Contents |
Eye Shader
Code explanation
Ambient Pass
This pass is used for environment reflection because your eyes are wet.
Light Pass
Light Pass has this particularity to have two specular reflection calculated: the Iris Specular and the Cornea Specular. Cornea Specular is the specular for the envelop, the outside of the eye whereas the Iris Specular is only for the Iris (seems obvious...).
Iris Specular
Its goal is to make the Iris shine. First I invert the Normal Map by inverting only R and G channels to get the Iris Normal Map from the Cornea Normal Map. Then I calculate the Specular Reflection as usual. I multiply it with my Iris mask (contained in the Cornea Normal Map Alpha Channel) to circumscribe the specular to the Iris only, and also I multiply it with the Eye Color to make the Iris shine. Finally I add it to the diffuse Reflection.
Cornea Specular
Its goal is to boost the environment reflection shininess where specular is supposed to be applied. Specular does not really exist, it is a programming trick for rapidity. So I get the environment reflection map, boost it (by adding brightness and contrast) and multiply it with the Specular Reflection. Finally I add it to the diffuse Reflection.
Links
On this material, the texture map is replaced by a "EyeColor Editor". This editor allows you to change the color and type of your eye directly from script. Also the CubeMap is not suited for C4, I just didn't have courage and time to make it work correctly.



