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

Eta param order could be wrong when calculating half vector #124

Open
bing007 opened this issue Sep 3, 2023 · 1 comment
Open

Eta param order could be wrong when calculating half vector #124

bing007 opened this issue Sep 3, 2023 · 1 comment

Comments

@bing007
Copy link

bing007 commented Sep 3, 2023

Hi, I couldn't wrap my head around about the order of eta arguments being passed to computeNormalizedRefractionHalfVector in BsdfTransmissionCookTorrance.cc

// Compute microfacet / half vector, pointing towards the surface side
// with the lowest ior
Vec3f m;
if (!computeNormalizedRefractionHalfVector(mEtaI,
                                           slice.getWo(),
                                           etaT,
                                           wi,
                                           m)) {
    return sBlack;
}

but the method is expecting the order etaT, wo, etaI, wi, m as shown below as well as in the paper:

// H is always pointing towards medium with lowest IOR, but only if wo and wi
// are pointing on opposite side of the surface (wrt. N).
finline bool
computeNormalizedRefractionHalfVector(const float iorWo, const scene_rdl2::math::Vec3f &wo,
        const float iorWi, const scene_rdl2::math::Vec3f &wi, scene_rdl2::math::Vec3f &H)
{
    static const float halfVectorLengthMinSqr = 0.001f * 0.001f;

    H = -(iorWo * wo + iorWi * wi);

    float lengthHSqr = lengthSqr(H);
    if (lengthHSqr > halfVectorLengthMinSqr) {
        H *= scene_rdl2::math::rsqrt(lengthHSqr);
        return true;
    } else {
        return false;
    }
}
image

Thanks,

@bing007
Copy link
Author

bing007 commented Sep 4, 2023

If we search the usage of these ETAs, there appear to be other usages with similar issues.

eval does not produce any result as it always returns at this check:

    // Exclude cases where microfacet m is pointing to the opposite side of
    // the surface (wrt. N). This corresponds to the X+(m.n) term of the normal
    // distribution function D(m); see eq. (25), (30) or (33)
    const float cosThetaM = dot(m, mFrame.getN());
    if (cosThetaM <= sEpsilon) return sBlack;

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

1 participant