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/kernel/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/kernel/bvh')
-rw-r--r-- | intern/cycles/kernel/bvh/bvh.h | 36 | ||||
-rw-r--r-- | intern/cycles/kernel/bvh/bvh_embree.h | 24 |
2 files changed, 33 insertions, 27 deletions
diff --git a/intern/cycles/kernel/bvh/bvh.h b/intern/cycles/kernel/bvh/bvh.h index 0346f5e09e7..8e17ab9af7a 100644 --- a/intern/cycles/kernel/bvh/bvh.h +++ b/intern/cycles/kernel/bvh/bvh.h @@ -329,24 +329,26 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals *kg, # ifdef __EMBREE__ if (kernel_data.bvh.scene) { - CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_SSS); + const bool has_bvh = !(kernel_tex_fetch(__object_flag, local_object) & + SD_OBJECT_TRANSFORM_APPLIED); + CCLIntersectContext ctx( + kg, has_bvh ? CCLIntersectContext::RAY_SSS : CCLIntersectContext::RAY_LOCAL); ctx.lcg_state = lcg_state; ctx.max_hits = max_hits; - ctx.ss_isect = local_isect; + ctx.local_isect = local_isect; local_isect->num_hits = 0; - ctx.sss_object_id = local_object; + ctx.local_object_id = local_object; IntersectContext rtc_ctx(&ctx); RTCRay rtc_ray; kernel_embree_setup_ray(*ray, rtc_ray, PATH_RAY_ALL_VISIBILITY); - /* Get the Embree scene for this intersection. */ - RTCGeometry geom = rtcGetGeometry(kernel_data.bvh.scene, local_object * 2); - if (geom) { - float3 P = ray->P; - float3 dir = ray->D; - float3 idir = ray->D; - const int object_flag = kernel_tex_fetch(__object_flag, local_object); - if (!(object_flag & SD_OBJECT_TRANSFORM_APPLIED)) { + /* If this object has its own BVH, use it. */ + if (has_bvh) { + RTCGeometry geom = rtcGetGeometry(kernel_data.bvh.scene, local_object * 2); + if (geom) { + float3 P = ray->P; + float3 dir = ray->D; + float3 idir = ray->D; Transform ob_itfm; rtc_ray.tfar = bvh_instance_motion_push( kg, local_object, ray, &P, &dir, &idir, ray->t, &ob_itfm); @@ -360,11 +362,15 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals *kg, rtc_ray.dir_x = dir.x; rtc_ray.dir_y = dir.y; rtc_ray.dir_z = dir.z; + RTCScene scene = (RTCScene)rtcGetGeometryUserData(geom); + kernel_assert(scene); + if (scene) { + rtcOccluded1(scene, &rtc_ctx.context, &rtc_ray); + } } - RTCScene scene = (RTCScene)rtcGetGeometryUserData(geom); - if (scene) { - rtcOccluded1(scene, &rtc_ctx.context, &rtc_ray); - } + } + else { + rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray); } return local_isect->num_hits > 0; diff --git a/intern/cycles/kernel/bvh/bvh_embree.h b/intern/cycles/kernel/bvh/bvh_embree.h index 661bba54fd4..ffea7d37440 100644 --- a/intern/cycles/kernel/bvh/bvh_embree.h +++ b/intern/cycles/kernel/bvh/bvh_embree.h @@ -28,9 +28,9 @@ struct CCLIntersectContext { typedef enum { RAY_REGULAR = 0, RAY_SHADOW_ALL = 1, - RAY_SSS = 2, - RAY_VOLUME_ALL = 3, - + RAY_LOCAL = 2, + RAY_SSS = 3, + RAY_VOLUME_ALL = 4, } RayType; KernelGlobals *kg; @@ -42,8 +42,8 @@ struct CCLIntersectContext { int num_hits; /* for SSS Rays: */ - LocalIntersection *ss_isect; - int sss_object_id; + LocalIntersection *local_isect; + int local_object_id; uint *lcg_state; CCLIntersectContext(KernelGlobals *kg_, RayType type_) @@ -53,8 +53,8 @@ struct CCLIntersectContext { max_hits = 1; num_hits = 0; isect_s = NULL; - ss_isect = NULL; - sss_object_id = -1; + local_isect = NULL; + local_object_id = -1; lcg_state = NULL; } }; @@ -121,11 +121,11 @@ ccl_device_inline void kernel_embree_convert_hit(KernelGlobals *kg, isect->type = kernel_tex_fetch(__prim_type, isect->prim); } -ccl_device_inline void kernel_embree_convert_local_hit(KernelGlobals *kg, - const RTCRay *ray, - const RTCHit *hit, - Intersection *isect, - int local_object_id) +ccl_device_inline void kernel_embree_convert_sss_hit(KernelGlobals *kg, + const RTCRay *ray, + const RTCHit *hit, + Intersection *isect, + int local_object_id) { isect->u = 1.0f - hit->v - hit->u; isect->v = hit->u; |