Fixed a corner case in the sobol sampler which could cause NaNs etc
parent
423ffd59dd
commit
1f1b58adf8
|
@ -47,31 +47,31 @@
|
|||
#undef INFINITY
|
||||
#endif
|
||||
|
||||
#if defined(__WINDOWS__)
|
||||
#define ONE_MINUS_EPS_FLT 0.999999940395355225f
|
||||
#define ONE_MINUS_EPS_DBL 0.999999999999999888
|
||||
#else
|
||||
#define ONE_MINUS_EPS_FLT 0x1.fffffffffffff7p-1
|
||||
#define ONE_MINUS_EPS_DBL 0x1.fffffep-1f
|
||||
#endif
|
||||
|
||||
#ifdef SINGLE_PRECISION
|
||||
#define M_E 2.71828182845904523536f
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#define INV_PI 0.31830988618379067154f
|
||||
#define INV_TWOPI 0.15915494309189533577f
|
||||
#define INV_FOURPI 0.07957747154594766788f
|
||||
#define SQRT_TWO 1.41421356237309504880f
|
||||
#define INV_SQRT_TWO 0.70710678118654752440f
|
||||
#if defined(__WINDOWS__)
|
||||
#define ONE_MINUS_EPS 0.999999940395355225f
|
||||
#define M_E 2.71828182845904523536f
|
||||
#define M_PI 3.14159265358979323846f
|
||||
#define INV_PI 0.31830988618379067154f
|
||||
#define INV_TWOPI 0.15915494309189533577f
|
||||
#define INV_FOURPI 0.07957747154594766788f
|
||||
#define SQRT_TWO 1.41421356237309504880f
|
||||
#define INV_SQRT_TWO 0.70710678118654752440f
|
||||
#define ONE_MINUS_EPS ONE_MINUS_EPS_FLT
|
||||
#else
|
||||
#define ONE_MINUS_EPS 0x1.fffffep-1f
|
||||
#endif
|
||||
#else
|
||||
#define M_E 2.71828182845904523536
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define INV_PI 0.31830988618379067154
|
||||
#define INV_TWOPI 0.15915494309189533577
|
||||
#define INV_FOURPI 0.07957747154594766788
|
||||
#define SQRT_TWO 1.41421356237309504880
|
||||
#define INV_SQRT_TWO 0.70710678118654752440
|
||||
#if defined(__WINDOWS__)
|
||||
#define ONE_MINUS_EPS 0.999999999999999888
|
||||
#else
|
||||
#define ONE_MINUS_EPS 0x1.fffffffffffff7p-1
|
||||
#endif
|
||||
#define M_E 2.71828182845904523536
|
||||
#define M_PI 3.14159265358979323846
|
||||
#define INV_PI 0.31830988618379067154
|
||||
#define INV_TWOPI 0.15915494309189533577
|
||||
#define INV_FOURPI 0.07957747154594766788
|
||||
#define SQRT_TWO 1.41421356237309504880
|
||||
#define INV_SQRT_TWO 0.70710678118654752440
|
||||
#define ONE_MINUS_EPS ONE_MINUS_EPS_DBL
|
||||
#endif
|
||||
#endif /* __MITSUBA_CORE_CONSTANTS_H */
|
||||
|
|
|
@ -54,7 +54,7 @@ inline float sampleSingle(
|
|||
result ^= Matrices::matrices32[i];
|
||||
}
|
||||
|
||||
return result * (1.f / (1ULL << 32));
|
||||
return std::min(result * (1.0f / (1ULL << 32)), ONE_MINUS_EPS_FLT);
|
||||
}
|
||||
|
||||
// Compute one component of the Sobol'-sequence, where the component
|
||||
|
@ -77,7 +77,7 @@ inline double sampleDouble(
|
|||
result ^= Matrices::matrices64[i];
|
||||
}
|
||||
|
||||
return result * (1.0 / (1ULL << Matrices::size));
|
||||
return std::min(result * (1.0 / (1ULL << Matrices::size)), ONE_MINUS_EPS_DBL);
|
||||
}
|
||||
|
||||
// Call sampleSingle or sampleDouble depending on the compilation options
|
||||
|
|
Loading…
Reference in New Issue