blob: 0c8a5276edef6fdb778d0f7a397b9b1d5328b4ee (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
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;
}
|