diff options
author | Stefan Werner <stefan.werner@tangent-animation.com> | 2020-01-15 16:33:16 +0300 |
---|---|---|
committer | Stefan Werner <stefan@keindesign.de> | 2020-01-16 22:42:17 +0300 |
commit | 6257cdc376af02e93b61073b67ffc0514f8af4ac (patch) | |
tree | 1e3377f499793bcdd9495b710118ea8605b29317 /intern/cycles/bvh | |
parent | b05bca23641fc8760b1c340928654f23ea04c6f2 (diff) |
Fix T73064: Embree does not like Bevel shader
Embree's local intersection routine was not prepared
for local intersections without per-object BVH.
Now it should be able to handle any kind of local
intersection, such as AO, bevel and SSS.
Differential Revision: https://developer.blender.org/D6602
Diffstat (limited to 'intern/cycles/bvh')
-rw-r--r-- | intern/cycles/bvh/bvh_embree.cpp | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp index ac7cf6501ba..3e4978a2c0a 100644 --- a/intern/cycles/bvh/bvh_embree.cpp +++ b/intern/cycles/bvh/bvh_embree.cpp @@ -146,7 +146,21 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args) } break; } + case CCLIntersectContext::RAY_LOCAL: case CCLIntersectContext::RAY_SSS: { + /* Check if it's hitting the correct object. */ + Intersection current_isect; + if (ctx->type == CCLIntersectContext::RAY_SSS) { + kernel_embree_convert_sss_hit(kg, ray, hit, ¤t_isect, ctx->local_object_id); + } + else { + kernel_embree_convert_hit(kg, ray, hit, ¤t_isect); + if (ctx->local_object_id != current_isect.object) { + /* This tells Embree to continue tracing. */ + *args->valid = 0; + } + } + /* No intersection information requested, just return a hit. */ if (ctx->max_hits == 0) { break; @@ -160,8 +174,8 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args) } /* See triangle_intersect_subsurface() for the native equivalent. */ - for (int i = min(ctx->max_hits, ctx->ss_isect->num_hits) - 1; i >= 0; --i) { - if (ctx->ss_isect->hits[i].t == ray->tfar) { + for (int i = min(ctx->max_hits, ctx->local_isect->num_hits) - 1; i >= 0; --i) { + if (ctx->local_isect->hits[i].t == ray->tfar) { /* This tells Embree to continue tracing. */ *args->valid = 0; break; @@ -172,14 +186,14 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args) if (ctx->lcg_state) { - ++ctx->ss_isect->num_hits; - if (ctx->ss_isect->num_hits <= ctx->max_hits) { - hit_idx = ctx->ss_isect->num_hits - 1; + ++ctx->local_isect->num_hits; + if (ctx->local_isect->num_hits <= ctx->max_hits) { + hit_idx = ctx->local_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; + hit_idx = lcg_step_uint(ctx->lcg_state) % ctx->local_isect->num_hits; if (hit_idx >= ctx->max_hits) { /* This tells Embree to continue tracing. */ @@ -189,15 +203,11 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args) } } else { - ctx->ss_isect->num_hits = 1; + ctx->local_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; - ctx->ss_isect->Ng[hit_idx] = normalize(ctx->ss_isect->Ng[hit_idx]); + ctx->local_isect->hits[hit_idx] = current_isect; + ctx->local_isect->Ng[hit_idx] = normalize(make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z)); /* This tells Embree to continue tracing .*/ *args->valid = 0; break; |