5353# include " util/util_logging.h"
5454# include " util/util_progress.h"
5555# include " util/util_stats.h"
56+ # include " util/util_hash.h"
5657
5758CCL_NAMESPACE_BEGIN
5859
@@ -256,10 +257,23 @@ static void rtc_filter_occluded_func_thick_curve(const RTC_NAMESPACE::RTCFilterF
256257 rtc_filter_occluded_func (args);
257258}
258259
260+ /* Generate a pseudo random bit sequence trying to keep disjoint spans uncorrelated.
261+ https://research.nvidia.com/publication/stratified-sampling-stochastic-transparency
262+ */
263+ inline float get_opacity_stratified (uint rng_pixel_sample, uint rng_surface) {
264+ // pixel_id + sample * num_samples
265+ uint x = reverse_bits_32 (rng_pixel_sample) + rng_surface;
266+ x = x ^ (x * 0x6C50B47Cu );
267+ x = x ^ (x * 0xB82F1E52u );
268+ x = x ^ (x * 0xC7AFE638u );
269+ x = x ^ (x * 0x8D22F6E6u );
270+ return (float )(x * 0x1p-32 );
271+ }
272+
259273static void rtc_filter_func_transparent_points (const RTC_NAMESPACE::RTCFilterFunctionNArguments *args)
260274{
261- const RTC_NAMESPACE::RTCRay *ray = (RTCRay *)args->ray ;
262- RTC_NAMESPACE::RTCHit *hit = (RTCHit *)args->hit ;
275+ const RTC_NAMESPACE::RTCRay *ray = (RTC_NAMESPACE:: RTCRay *)args->ray ;
276+ RTC_NAMESPACE::RTCHit *hit = (RTC_NAMESPACE:: RTCHit *)args->hit ;
263277 CCLIntersectContext *ctx = ((IntersectContext *)args->context )->userRayExt ;
264278 KernelGlobals *kg = ctx->kg ;
265279
@@ -275,8 +289,7 @@ static void rtc_filter_func_transparent_points(const RTC_NAMESPACE::RTCFilterFun
275289 const float opacity = kernel_tex_fetch (__points_opacity, opacity_offset);
276290
277291 /* Unique random number per ray per geometry */
278- uint hash = (uint&)ctx->ps_rng_transparent ;
279- const float rand_opacity = cmj_randfloat (hash, cmj_hash (object, prim));
292+ const float rand_opacity = cmj_randfloat (ctx->rng_transparent , cmj_hash (object, prim));
280293
281294 if (rand_opacity > opacity) {
282295 *args->valid = 0 ;
0 commit comments