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 UberMaterial #35

Closed
wahn opened this issue Jan 4, 2018 · 1 comment
Closed

Implement UberMaterial #35

wahn opened this issue Jan 4, 2018 · 1 comment
Assignees
Labels

Comments

@wahn
Copy link
Owner

wahn commented Jan 4, 2018

I'm looking for more PBRT test scenes and stumbled upon Benedikt Bitterli's Rendering Resources. The first test scene already needs a new material, which I haven't implemented yet, the UberMaterial:

pbrt

> rg uber bathroom
bathroom/scene.pbrt
20:	MakeNamedMaterial "Rug" "string type" [ "uber" ] "rgb Ks" [ 0.000000 0.000000 0.000000 ] "texture Kd" [ "Texture01" ] "texture opacity" [ "Texture02" ] 
29:	MakeNamedMaterial "BulbGlass" "string type" [ "uber" ] "rgb Kd" [ 0.000000 0.000000 0.000000 ] "rgb Ks" [ 0.000000 0.000000 0.000000 ] "rgb opacity" [ 0.000000 0.000000 0.000000 ] 

On the C++ side the class to convert to Rust looks like this:

// UberMaterial Declarations
class UberMaterial : public Material {
  public:
    UberMaterial(const std::shared_ptr<Texture<Spectrum>> &Kd,
                 const std::shared_ptr<Texture<Spectrum>> &Ks,
                 const std::shared_ptr<Texture<Spectrum>> &Kr,
                 const std::shared_ptr<Texture<Spectrum>> &Kt,
                 const std::shared_ptr<Texture<Float>> &roughness,
                 const std::shared_ptr<Texture<Float>> &roughnessu,
                 const std::shared_ptr<Texture<Float>> &roughnessv,
                 const std::shared_ptr<Texture<Spectrum>> &opacity,
                 const std::shared_ptr<Texture<Float>> &eta,
                 const std::shared_ptr<Texture<Float>> &bumpMap,
                 bool remapRoughness)
        : Kd(Kd),
          Ks(Ks),
          Kr(Kr),
          Kt(Kt),
          opacity(opacity),
          roughness(roughness),
          roughnessu(roughnessu),
          roughnessv(roughnessv),
          eta(eta),
          bumpMap(bumpMap),
          remapRoughness(remapRoughness) {}

    void ComputeScatteringFunctions(SurfaceInteraction *si, MemoryArena &arena,
                                    TransportMode mode,
                                    bool allowMultipleLobes) const;

  private:
    // UberMaterial Private Data
    std::shared_ptr<Texture<Spectrum>> Kd, Ks, Kr, Kt, opacity;
    std::shared_ptr<Texture<Float>> roughness, roughnessu, roughnessv, eta,
        bumpMap;
    bool remapRoughness;
};

UberMaterial *CreateUberMaterial(const TextureParams &mp);

This shouldn't be too much work:

> wc ~/git/github/pbrt-v3/src/materials/uber.h
  89  322 3285 /home/jan/git/github/pbrt-v3/src/materials/uber.h
> wc ~/git/github/pbrt-v3/src/materials/uber.cpp 
 129  479 5190 /home/jan/git/github/pbrt-v3/src/materials/uber.cpp
@wahn wahn added the task label Jan 4, 2018
@wahn wahn self-assigned this Jan 4, 2018
wahn added a commit that referenced this issue Jan 4, 2018
@wahn
Copy link
Owner Author

wahn commented Jan 4, 2018

Commit b3ad5e4 resolves the issue:

pbrt

@wahn wahn closed this as completed Jan 4, 2018
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

1 participant