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 'Shape "loopsubdiv"' #67

Closed
wahn opened this issue Oct 22, 2018 · 2 comments
Closed

Implement 'Shape "loopsubdiv"' #67

wahn opened this issue Oct 22, 2018 · 2 comments
Assignees

Comments

@wahn
Copy link
Owner

wahn commented Oct 22, 2018

The one and only test scene distributed with the C++ code contains a subdivision surface:

Shape "loopsubdiv"  "integer nlevels" [1 ] "integer indices" ...

killeroo-simple

Beside the problem that we can't handle Include statements yet (see issue #41), we need to implement CreateLoopSubdiv(...) on the Rust side and a bunch of helper functions/structs:

std::vector<std::shared_ptr<Shape>> CreateLoopSubdiv(const Transform *o2w,
                                                     const Transform *w2o,
                                                     bool reverseOrientation,
                                                     const ParamSet &params) {
    int nLevels = params.FindOneInt("levels",
                                    params.FindOneInt("nlevels", 3));
    int nps, nIndices;
    const int *vertexIndices = params.FindInt("indices", &nIndices);
    const Point3f *P = params.FindPoint3f("P", &nps);
    if (!vertexIndices) {
        Error("Vertex indices \"indices\" not provided for LoopSubdiv shape.");
        return std::vector<std::shared_ptr<Shape>>();
    }
    if (!P) {
        Error("Vertex positions \"P\" not provided for LoopSubdiv shape.");
        return std::vector<std::shared_ptr<Shape>>();
    }

    // don't actually use this for now...
    std::string scheme = params.FindOneString("scheme", "loop");
    return LoopSubdivide(o2w, w2o, reverseOrientation, nLevels, nIndices,
                         vertexIndices, nps, P);
}
> pwd
/.../github/pbrt-v3/src/shapes
> rg "struct SD"
loopsubdiv.cpp
43:struct SDFace;
44:struct SDVertex;
51:struct SDVertex {
64:struct SDFace {
96:struct SDEdge {
@wahn wahn self-assigned this Oct 22, 2018
@wahn
Copy link
Owner Author

wahn commented Oct 29, 2018

Here is a first result (with only one instance of the killeroo geometry) for Rust:

killeroo-simple-rust

There is a difference to the C++ version though:

diff

> imf_diff -f -d killeroo-simple-cpp.exr killeroo-simple-rust.exr diff.jpg
differing pixels:	  0.032% (155 of 490000)
average difference:	 18.131%
maximum difference:	 67.999%
Summary: A few pixels differ strongly.
== "killeroo-simple-cpp.exr" and "killeroo-simple-rust.exr" are different

@wahn
Copy link
Owner Author

wahn commented Oct 29, 2018

After commit a7c7382 (and using the bdpt integrator with 256 pixelsamples) we get almost identical results:

pbrt

> imf_diff -f -d killeroo-simple-cpp.exr killeroo-simple-rust.exr diff.jpg
differing pixels:	  0.003% (14 of 490000)
average difference:	  1.581%
maximum difference:	  2.609%
Summary: A few pixels differ slightly.
== "killeroo-simple-cpp.exr" and "killeroo-simple-rust.exr" are similar

diff

@wahn wahn closed this as completed Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant