Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Schlick function in disney material maybe wrong #270

Open
jxo opened this issue Jan 3, 2020 · 2 comments
Open

Schlick function in disney material maybe wrong #270

jxo opened this issue Jan 3, 2020 · 2 comments

Comments

@jxo
Copy link

jxo commented Jan 3, 2020

// The Schlick Fresnel approximation is:
//
// R = R(0) + (1 - R(0)) (1 - cos theta)^5,
//
// where R(0) is the reflectance at normal indicence.
inline Float SchlickWeight(Float cosTheta) {
    Float m = Clamp(1 - cosTheta, 0, 1);
    return (m * m) * (m * m) * m;
}

inline Float FrSchlick(Float R0, Float cosTheta) {
    return Lerp(SchlickWeight(cosTheta), R0, 1);
}

inline Spectrum FrSchlick(const Spectrum &R0, Float cosTheta) {
    return Lerp(SchlickWeight(cosTheta), R0, Spectrum(1.));
}

Lerp here is (1 - SchlickWeight(cosTheta)) * R0 + SchlickWeight(cosTheta)
not R0 + (1 - R0) * SchlickWeight(cosTheta)

@oceanusxiv
Copy link

@jxo I think it's just the comment equation that is wrong, and the actual function implementation is still correct.

@jxo
Copy link
Author

jxo commented Sep 23, 2020

@eric1221bday
see here, the comment equation is right.
https://en.wikipedia.org/wiki/Schlick's_approximation
Lerp definition:
inline Float Lerp(Float t, Float v1, Float v2) { return (1 - t) * v1 + t * v2; }
Lerp(R0, SchlickWeight(cosTheta), 1) may be right

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants