• Create Account

### #ActualChris_F

Posted 30 January 2013 - 07:24 AM

Out of curiocity I wanted to compare Schlick's approximation to the real thing, so I had my hand at implementing it, though, admittedly, I'm not very good with the maths... so I may have made a mistake, or more.

float CosTheta = dot(N, L);
float SinTheta = sqrt(1 - CosTheta * CosTheta);
float temp = n1 * (SinTheta / n2);
temp = n2 * sqrt(1 - temp * temp);
temp = (n1 * CosTheta - temp) / (n1 * CosTheta + temp);
float fresnel = temp * temp;

I'm getting a pretty noticable difference between this and Schlick's.

### #1Chris_F

Posted 30 January 2013 - 07:24 AM

Out of curiocity I wanted to compare Schlick's approximation to the real thing, so I had my hand at implementing it, though, admittedly, I'm not very good with the maths... so I may have made a mistake, or more.

[code=auto:0]
float CosTheta = dot(N, L);
float SinTheta = sqrt(1 - CosTheta * CosTheta);
float temp = n1 * (SinTheta / n2);
temp = n2 * sqrt(1 - temp * temp);
temp = (n1 * CosTheta - temp) / (n1 * CosTheta + temp);
float fresnel = temp * temp;
[code=auto:0]

I'm getting a pretty noticable difference between this and Schlick's.

PARTNERS