blender/intern/cycles/kernel/osl/nodes/node_fresnel.h
Campbell Barton 2d290040a1 style cleanup
2012-06-04 22:44:58 +00:00

22 lines
483 B
C

float fresnel_dielectric(vector Incoming, normal Normal, float eta)
{
/* compute fresnel reflectance without explicitly computing
the refracted direction */
float c = fabs(dot(Incoming, Normal));
float g = eta * eta - 1 + c * c;
float result;
if (g > 0) {
g = sqrt(g);
float A = (g - c) / (g + c);
float B = (c * (g + c) - 1) / (c * (g - c) + 1);
result = 0.5 * A * A * (1 + B * B);
}
else
result = 1.0; /* TIR (no refracted component) */
return result;
}