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

Unable to render any scene using the hair shape #25

Closed
amyspark opened this issue Sep 11, 2017 · 4 comments
Closed

Unable to render any scene using the hair shape #25

amyspark opened this issue Sep 11, 2017 · 4 comments

Comments

@amyspark
Copy link
Contributor

All hair-related rendering is not working as of 77d0885.
I've tried Benedikt Bitterli's Fur Ball, Hair Curls and Straight Hair scenes. In all of them the console spams (snippet below):

2017-09-11 08:39:09 WARN  wrk2 [ImageBlock] Invalid sample value : [nan, nan, nan, 1, 1]
2017-09-11 08:39:09 WARN  wrk1 [ImageBlock] Invalid sample value : [nan, nan, nan, 1, 1]
2017-09-11 08:39:09 WARN  wrk2 [vector.h:538] Vector3: Division by zero!
2017-09-11 08:39:09 WARN  wrk0 [vector.h:538] Vector3: Division by zero!
2017-09-11 08:39:09 WARN  wrk3 [vector.h:538] Vector3: Division by zero!
2017-09-11 08:39:09 WARN  wrk0 [MIPMap] evalBilinear(): encountered a NaN!
2017-09-11 08:39:09 WARN  wrk3 [MIPMap] evalBilinear(): encountered a NaN!
2017-09-11 08:39:09 WARN  wrk3 [EnvironmentMap] pdfDirect(): encountered a NaN!
2017-09-11 08:39:09 WARN  wrk1 [vector.h:538] Vector3: Division by zero!
2017-09-11 08:39:09 WARN  wrk0 [EnvironmentMap] pdfDirect(): encountered a NaN!

and ends up with pitch black hair being rendered. The Curly Hair scene instantly crashes.

This happens in MacOS Sierra 10.12.6 as well as Windows 7 (MSVC 2017).

@wjakob
Copy link
Member

wjakob commented Sep 11, 2017

Dear @amyspark,

we're currently 100% occupied with other research projects. It would be helpful if you could look into this yourself and post a PR to address the underlying issue.

Best,
Wenzel

@amyspark
Copy link
Contributor Author

I'm no expert, but I'll do my best.
I started by intercepting the division by zeros, which in my case were caused by the integrator attempting to calculate the incident light here:

spec *= Li(sensorRay, rRec);

When Mitsuba intersects the sampled ray with the hair, this query
RadianceQueryRecord rRec(scene, sampler);
generates an Intersection with the shading frame and UV partial position all set to zero. This is the same with any bsdf, and when it tries normalising that vector, it all fails.

@amyspark
Copy link
Contributor Author

amyspark commented Sep 15, 2017

I tried git bisecting since 1ca0413 (when you bumped Mitsuba to 0.5.0). I couldn't get Mitsuba to compile there (lots of Boost uncaught exceptions, clang complaining about libstdc++, et al) so I resorted to manually looking backwards starting from the latest commit.

Counting from today, the first working commit I could find is b8480a3. The first bad one I could find is 8365668.
git bisecting them tells me the bug was introduced by ce80ddc, which is consistent with the shading frame issue I had observed.

EDIT: I've narrowed it down to util.cpp and/or skdtree.h. The changes in hair.cpp only remove the shading frame computation.

@amyspark
Copy link
Contributor Author

amyspark commented Sep 15, 2017

I've finally found the cause of the bug. It seems that previously, Hair's shading frame was initialized to the geometry frame with no further changes:

its.shFrame = its.geoFrame;

Now, the shading frame calculation is standardized with the rest of the shapes. This was not done anywhere previously:
computeShadingFrame(its.shFrame.n, its.dpdu, its.shFrame);

EDIT: The reason why this all breaks down is because its.uv, its.dpdu and its.dpdv are never initialized at fillIntersectionRecord:
/* No UV coordinates for now */

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

Successfully merging a pull request may close this issue.

2 participants