diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-04-19 19:02:30 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2014-04-21 21:34:25 +0400 |
commit | 9ab259f55b67c6e3b8028d95b23e708c3bc0c6fd (patch) | |
tree | ffaba2fef52cf1066bbf875a4a5391ad0879c3ff /intern/cycles/kernel/geom/geom_bvh_traversal.h | |
parent | f6abc96b6b3ee53e100263e93de2e4323cd7231e (diff) |
Cycles: shadow function optimization for transparent shadows (CPU only).
Old algorithm:
Raytrace from one transparent surface to the next step by step. To minimize
overhead in cases where we don't need transparent shadows, we first trace a
regular shadow ray. We check if the hit primitive was potentially transparent,
and only in that case start marching. this gives extra ray cast for the cases
were we do want transparency.
New algorithm:
We trace a single ray. If it hits any opaque surface, or more than a given
number of transparent surfaces is hit, then we consider the geometry to be
entirely blocked. If not, all transparent surfaces will be recorded and we
will shade them one by one to determine how much light is blocked. This all
happens in one scene intersection function.
Recording all hits works well in some cases but may be slower in others. If
we have many semi-transparent hairs, one intersection may be faster because
you'd be reinteresecting the same hairs a lot with each step otherwise. If
however there is mostly binary transparency then we may be recording many
unnecessary intersections when one of the first surfaces blocks all light.
We found that this helps quite nicely in some scenes, on koro.blend this can
give a 50% reduction in render time, on the pabellon barcelona scene and a
forest scene with transparent leaves it was 30%. Some other files rendered
maybe 1% or 2% slower, but this seems a reasonable tradeoff.
Differential Revision: https://developer.blender.org/D473
Diffstat (limited to 'intern/cycles/kernel/geom/geom_bvh_traversal.h')
-rw-r--r-- | intern/cycles/kernel/geom/geom_bvh_traversal.h | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/intern/cycles/kernel/geom/geom_bvh_traversal.h b/intern/cycles/kernel/geom/geom_bvh_traversal.h index 566aa421474..6cb622d384c 100644 --- a/intern/cycles/kernel/geom/geom_bvh_traversal.h +++ b/intern/cycles/kernel/geom/geom_bvh_traversal.h @@ -53,7 +53,6 @@ ccl_device bool BVH_FUNCTION_NAME int nodeAddr = kernel_data.bvh.root; /* ray parameters in registers */ - const float tmax = ray->t; float3 P = ray->P; float3 dir = bvh_clamp_direction(ray->D); float3 idir = bvh_inverse_direction(dir); @@ -63,7 +62,7 @@ ccl_device bool BVH_FUNCTION_NAME Transform ob_tfm; #endif - isect->t = tmax; + isect->t = ray->t; isect->object = OBJECT_NONE; isect->prim = PRIM_NONE; isect->u = 0.0f; @@ -264,18 +263,10 @@ ccl_device bool BVH_FUNCTION_NAME #if FEATURE(BVH_HAIR) case PRIMITIVE_CURVE: case PRIMITIVE_MOTION_CURVE: { -#if FEATURE(BVH_HAIR_MINIMUM_WIDTH) if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) hit = bvh_cardinal_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type, lcg_state, difl, extmax); else hit = bvh_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type, lcg_state, difl, extmax); -#else - if(kernel_data.curve.curveflags & CURVE_KN_INTERPOLATE) - hit = bvh_cardinal_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type); - else - hit = bvh_curve_intersect(kg, isect, P, dir, visibility, object, primAddr, ray->time, type); -#endif - break; } #endif @@ -307,9 +298,9 @@ ccl_device bool BVH_FUNCTION_NAME object = kernel_tex_fetch(__prim_object, -primAddr-1); #if FEATURE(BVH_MOTION) - bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm, tmax); + bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm); #else - bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t, tmax); + bvh_instance_push(kg, object, ray, &P, &dir, &idir, &isect->t); #endif #if defined(__KERNEL_SSE2__) @@ -337,9 +328,9 @@ ccl_device bool BVH_FUNCTION_NAME /* instance pop */ #if FEATURE(BVH_MOTION) - bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm, tmax); + bvh_instance_motion_pop(kg, object, ray, &P, &dir, &idir, &isect->t, &ob_tfm); #else - bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect->t, tmax); + bvh_instance_pop(kg, object, ray, &P, &dir, &idir, &isect->t); #endif #if defined(__KERNEL_SSE2__) |