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

Implement Beckmann microfacet distribution model #80

Closed
abusch opened this issue Dec 5, 2018 · 1 comment
Closed

Implement Beckmann microfacet distribution model #80

abusch opened this issue Dec 5, 2018 · 1 comment
Assignees
Labels

Comments

@abusch
Copy link
Contributor

abusch commented Dec 5, 2018

I think I've got this one in rustracer too.

@wahn wahn self-assigned this Sep 12, 2019
@wahn wahn added the task label Sep 12, 2019
@wahn
Copy link
Owner

wahn commented Sep 19, 2019

In C++ (that's what we need in the Rust counterpart):

class BeckmannDistribution : public MicrofacetDistribution {
  public:
    // BeckmannDistribution Public Methods
    static Float RoughnessToAlpha(Float roughness) {
        roughness = std::max(roughness, (Float)1e-3);
        Float x = std::log(roughness);
        return 1.62142f + 0.819955f * x + 0.1734f * x * x +
               0.0171201f * x * x * x + 0.000640711f * x * x * x * x;
    }
    BeckmannDistribution(Float alphax, Float alphay, bool samplevis = true)
        : MicrofacetDistribution(samplevis), alphax(alphax), alphay(alphay) {}
    Float D(const Vector3f &wh) const;
    Vector3f Sample_wh(const Vector3f &wo, const Point2f &u) const;
    std::string ToString() const;

  private:
    // BeckmannDistribution Private Methods
    Float Lambda(const Vector3f &w) const;

    // BeckmannDistribution Private Data
    const Float alphax, alphay;
};

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

No branches or pull requests

2 participants