Saturday, March 15, 2014

Building Fresnel from scratch

I wanted to see how the Fresnel node works so I attempted to build it in the material editor.
According to a comment in the .uc file for the function it's, "pow(1 - max(Normal dot Camera,0),Exponent)" with a default exponent of 3.
So it turns out that Fresnel is 1- the dot product of a camera vector and a normal (top).
Well that was easy… So in reality my goal was to build a dot product in the material editor.
Luckily there's a way to get the dot product without a bunch of fancy trigonometry: X1*X2 + Y1*Y2 + Z1*Z2

Switch params were just for testing the results.