Skip to content

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

@kumo0086

Description

@kumo0086

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,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions