[Bf-blender-cvs] [fc4f45a0a40] cycles-x: Fix T91425: VDB shadow rendering incorrect in some cases
Brecht Van Lommel
noreply at git.blender.org
Mon Sep 20 16:27:02 CEST 2021
Commit: fc4f45a0a40583ab65a83c3e291e67bd851afafb
Author: Brecht Van Lommel
Date: Mon Sep 20 14:24:31 2021 +0200
Branches: cycles-x
https://developer.blender.org/rBfc4f45a0a40583ab65a83c3e291e67bd851afafb
Fix T91425: VDB shadow rendering incorrect in some cases
===================================================================
M intern/cycles/bvh/bvh_embree.cpp
M intern/cycles/kernel/bvh/bvh_shadow_all.h
===================================================================
diff --git a/intern/cycles/bvh/bvh_embree.cpp b/intern/cycles/bvh/bvh_embree.cpp
index 03226dcbc77..96852510b63 100644
--- a/intern/cycles/bvh/bvh_embree.cpp
+++ b/intern/cycles/bvh/bvh_embree.cpp
@@ -104,21 +104,26 @@ static void rtc_filter_occluded_func(const RTCFilterFunctionNArguments *args)
/* If maximum number of hits was reached, replace the intersection with the
* highest distance. We want to find the N closest intersections. */
int isect_index = num_recorded_hits;
- if (isect_index >= ctx->max_hits) {
+ if (num_recorded_hits + 1 >= ctx->max_hits) {
float max_t = ctx->isect_s[0].t;
- isect_index = 0;
+ int max_recorded_hit = 0;
for (int i = 1; i < num_recorded_hits; ++i) {
if (ctx->isect_s[i].t > max_t) {
- isect_index = i;
+ max_recorded_hit = i;
max_t = ctx->isect_s[i].t;
}
}
- /* TODO: is there some way we can tell Embree to stop intersecting beyond
+ if (num_recorded_hits >= ctx->max_hits) {
+ isect_index = max_recorded_hit;
+ }
+
+ /* Limit the ray distance and stop counting hits beyond this.
+ * TODO: is there some way we can tell Embree to stop intersecting beyond
* this distance when max number of hits is reached?. Or maybe it will
* become irrelevant if we make max_hits a very high number on the CPU. */
- ctx->max_t = min(current_isect.t, max_t);
+ ctx->max_t = max(current_isect.t, max_t);
}
ctx->isect_s[isect_index] = current_isect;
diff --git a/intern/cycles/kernel/bvh/bvh_shadow_all.h b/intern/cycles/kernel/bvh/bvh_shadow_all.h
index d2e3be78d4e..0ae36fccf9b 100644
--- a/intern/cycles/kernel/bvh/bvh_shadow_all.h
+++ b/intern/cycles/kernel/bvh/bvh_shadow_all.h
@@ -221,12 +221,8 @@ ccl_device_inline
isect = isect_array + max_recorded_hit;
- /* If we already found more hits than we record, we can limit the
- * ray distance and stop counting hits beyond this, as we are sure to
- * need to another ray-trace call. */
- if (*num_hits > max_hits) {
- isect_t = max_recorded_t * t_world_to_instance;
- }
+ /* Limit the ray distance and stop counting hits beyond this. */
+ isect_t = max_recorded_t * t_world_to_instance;
}
else {
/* Still have space for intersection, use next hit. */
More information about the Bf-blender-cvs
mailing list