• Create Account

### #ActualTsus

Posted 21 May 2012 - 02:21 AM

Hi,

If I'm not mistaken, the angle in question should be between the normal and the light direction. (To be more precisely half of the angle between the negated incoming light and outgoing light direction, but if we work with perfect reflection it comes down to NdotL.)
float base = max(0, 1-dot(n, l)); // better do the max here. (According to the OptiX source code not a bad idea as there are cases which yield artifacts if omitted.)
float exp = pow(base, 5);
float fresnel = fZero + (1-fZero)*exp;

fZero a little shorter:
GLfloat fZero = pow( (1.0f-(1.0f/1.31f))/ (1.0f+(1.0f/1.31f)), 2);

Make sure, n and l are both normalized and in the same space. For debugging purposes you can set fZero to 0.

Hope it helps a little.
Cheers!

### #1Tsus

Posted 20 May 2012 - 06:09 PM

Hi,

If I'm not mistaken, the angle in question should be between the normal and the light direction. (To be more precisely half of the angle between the negated incoming light and outgoing light direction, but if we work with perfect reflection it comes down to NdotL.)
float base = max(0, 1-dot(n, l)); // better do the max here. (According to the OptiX source code not a bad idea as there are cases which yield artifacts if omitted.)
float exp = pow(base, 5);
float fresnel = fZero + (1-fZero)*exp;
If I’m not mistaken fZero is:
GLfloat fZero = pow( (1.0f-(1.0f/1.31f))/ (1.0f+(1.0f/1.31f)), 2);

Make sure, n and l are both normalized and in the same space (your normal is in view space, your light direction in world space). For debugging purposes you can set fZero to 0.

Hope it helps a little.
Cheers!

PARTNERS