mmp / pbrt-v4

Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.
https://pbrt.org
Apache License 2.0
2.8k stars 429 forks source link

Avoid error in Hair material when `beta_m` or `beta_n` is out of range #338

Closed pbrt4bounty closed 1 year ago

pbrt4bounty commented 1 year ago

Hi.. I have a render error when the values for beta_m or beta_n in the Hair material are out of range( > 1)

F:\REPOS\pbrt4blender\src\pbrt\bxdfs.cpp:280 ] FATAL Check failed: beta_n >= 0 && beta_n <= 1
(unknown                                 )      0x0000000000000000 - ☺
(unknown                                 )      0x0000000000000000 - ☺
(unknown                                 )      0x00007FFB290C1B20 - configthreadlocale
(unknown                                 )      0x00007FFB29DA75F0 - BaseThreadInitThunk
(unknown                                 )      0x00007FFB2B642680 - RtlUserThreadStart
Rendering failed at pixel (187, 0) sample 0. Debug with "--debugstart 187,0,0"

To avoid this error on render time, maybe is better to clamp this values on the right range in the material creation time.

FloatTexture beta_m = parameters.GetFloatTexture("beta_m", 0.3f, alloc);
Clamp(beta_m, 0.0f, 1.0f);
FloatTexture beta_n = parameters.GetFloatTexture("beta_n", 0.3f, alloc);
Clamp(beta_n, 0.0f, 1.0f);

Cheers..

pbrt4bounty commented 1 year ago

Or maybe extend this code, which checks the minimum value, so that it also checks the maximum value.. https://github.com/mmp/pbrt-v4/blob/master/src/pbrt/materials.h#L382