Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Werner <stefan.werner@tangent-animation.com>2019-10-15 16:06:04 +0300
committerStefan Werner <stefan@keindesign.de>2020-01-14 16:52:32 +0300
commit042e4daa72b7b69925a173d3937f04d35a189baf (patch)
treee0e267b74ddb0425299532137f84f1e2465d2c74 /intern/cycles/bvh
parent0187735eea17ff580f80115bd840747400732fe7 (diff)
Cycles: Crash fix for random walk SSS with Embree.
Diffstat (limited to 'intern/cycles/bvh')
-rw-r--r--intern/cycles/bvh/bvh_embree.cpp38
1 files changed, 22 insertions, 16 deletions
diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp
index d12a0c137ea..42d2e66017c 100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@ -168,26 +168,32 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args)
}
}
- ++ctx->ss_isect->num_hits;
- int hit_idx;
+ int hit_idx = 0;
- if (ctx->ss_isect->num_hits <= ctx->max_hits) {
- hit_idx = ctx->ss_isect->num_hits - 1;
- }
- else {
- /* reservoir sampling: if we are at the maximum number of
- * hits, randomly replace element or skip it */
- hit_idx = lcg_step_uint(ctx->lcg_state) % ctx->ss_isect->num_hits;
+ if (ctx->lcg_state) {
- if (hit_idx >= ctx->max_hits) {
- /* This tells Embree to continue tracing. */
- *args->valid = 0;
- break;
+ ++ctx->ss_isect->num_hits;
+ if (ctx->ss_isect->num_hits <= ctx->max_hits) {
+ hit_idx = ctx->ss_isect->num_hits - 1;
+ }
+ else {
+ /* reservoir sampling: if we are at the maximum number of
+ * hits, randomly replace element or skip it */
+ hit_idx = lcg_step_uint(ctx->lcg_state) % ctx->ss_isect->num_hits;
+
+ if (hit_idx >= ctx->max_hits) {
+ /* This tells Embree to continue tracing. */
+ *args->valid = 0;
+ break;
+ }
}
}
- /* record intersection */
- kernel_embree_convert_local_hit(
- kg, ray, hit, &ctx->ss_isect->hits[hit_idx], ctx->sss_object_id);
+ else {
+ ctx->ss_isect->num_hits = 1;
+ }
+ /* record intersection */
+ kernel_embree_convert_local_hit(
+ kg, ray, hit, &ctx->ss_isect->hits[hit_idx], ctx->sss_object_id);
ctx->ss_isect->Ng[hit_idx].x = hit->Ng_x;
ctx->ss_isect->Ng[hit_idx].y = hit->Ng_y;
ctx->ss_isect->Ng[hit_idx].z = hit->Ng_z;