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

impl Shape for Curve #37

Closed
wahn opened this Issue Jan 10, 2018 · 6 comments

Comments

Projects
None yet
1 participant
@wahn
Copy link
Owner

wahn commented Jan 10, 2018

So far we support only four shapes:

$ rg -trust 'impl Shape' src
src/shapes/disk.rs
75:impl Shape for Disk {

src/shapes/sphere.rs
85:impl Shape for Sphere {

src/shapes/cylinder.rs
76:impl Shape for Cylinder {

src/shapes/triangle.rs
117:impl Shape for Triangle {

For hair we need curves:

Shape "curve" "string type" [ "cylinder" ] "point P" [ ... ] ...

So we have to implement all trait functions:

$ rg -trust 'trait Shape' src -A 15
src/core/shape.rs
8:pub trait Shape {
9-    fn object_bound(&self) -> Bounds3f;
10-    fn world_bound(&self) -> Bounds3f;
11-    fn intersect(&self, r: &Ray) -> Option<(SurfaceInteraction, Float)>;
12-    fn intersect_p(&self, r: &Ray) -> bool;
13-    fn get_reverse_orientation(&self) -> bool;
14-    fn get_transform_swaps_handedness(&self) -> bool;
15-    fn area(&self) -> Float;
16-    fn sample(&self, u: Point2f, pdf: &mut Float) -> InteractionCommon;
17-    fn sample_with_ref_point(&self,
18-                             iref: &InteractionCommon,
19-                             u: Point2f,
20-                             pdf: &mut Float)
21-                             -> InteractionCommon;
22-    fn pdf(&self, iref: &Interaction, wi: Vector3f) -> Float;
23-}

@wahn wahn added the task label Jan 10, 2018

@wahn wahn self-assigned this Jan 10, 2018

wahn added a commit that referenced this issue Jan 10, 2018

@wahn

This comment has been minimized.

Copy link
Owner

wahn commented Jan 11, 2018

Here is a test scene for straight hair (using curves) rendered by the C++ version:

straight-hair

@wahn

This comment has been minimized.

Copy link
Owner

wahn commented Jan 12, 2018

... and a scene with curly hair:

curly-hair

@wahn

This comment has been minimized.

Copy link
Owner

wahn commented Jan 15, 2018

After commit 008acc6 we get the following panic during rendering the (slightly modified) test scene:

$ ./target/release/examples/pest_test ../../self_hosted/Rust/pbrt/assets/scenes/hair/curly-hair.pbrt
...
BVHAccel::recursive_build(...)
PT88.005236252S seconds for building BVH ...
BVHAccel::flatten_bvh_tree(...)
PT1.191646535S seconds for flattening BVH ...
...
thread '<unnamed>' panicked at 'index out of bounds: the len is 3 but the index is 3', src/shapes/curve.rs:169:60

Memory consumption is pretty high as well ...

@wahn

This comment has been minimized.

Copy link
Owner

wahn commented Jan 16, 2018

Since commit 2f21f43 the curve geometry can be rendered (at least on a laptop with 32GB of memory):

curly-hair_rust_matte_512

In comparison to the C++ version the curves (using a default matte material for now) are rendered too bright:

curly-hair_cpp_matte_512

We still have to implement Curve::intersect_p(...), but I wait for another machine (with only 12GB of memory, which results in swapping) to finish rendering ...

@wahn

This comment has been minimized.

Copy link
Owner

wahn commented Jan 16, 2018

Commit 3e7dfe7 implements Curve::intersect_p(...) and improves the resulting image:

pbrt

@wahn

This comment has been minimized.

Copy link
Owner

wahn commented Jan 23, 2018

The geometry part seems to work fine ...

@wahn wahn closed this Jan 23, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment