From b3def11f5b751ead0bc8bcf100ff4ab3f2b10981 Mon Sep 17 00:00:00 2001 From: Thomas Dinges Date: Wed, 29 Apr 2015 23:21:05 +0200 Subject: Cycles: Record all possible volume intersections for SSS and camera checks This replaces sequential ray moving followed with scene intersection with single BVH traversal, which gives us all possible intersections. Only implemented for CPU, due to qsort and a bigger memory usage on GPU which we rather avoid. GPU still uses the regular bvh volume intersection code, while CPU now uses the new code. This improves render performance for scenes with: a) Camera inside volume mesh b) SSS mesh intersecting a volume mesh/domain In simple volume files (not much geometry) performance is roughly the same (slightly faster). In files with a lot of geometry, the performance increase is larger. bmps.blend with a volume shader and camera inside the mesh, it renders ~10% faster here. Patch by Sergey and myself. Differential Revision: https://developer.blender.org/D1264 --- intern/cycles/kernel/kernel_shadow.h | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) (limited to 'intern/cycles/kernel/kernel_shadow.h') diff --git a/intern/cycles/kernel/kernel_shadow.h b/intern/cycles/kernel/kernel_shadow.h index 8923fcebee5..d7c4fa02bcf 100644 --- a/intern/cycles/kernel/kernel_shadow.h +++ b/intern/cycles/kernel/kernel_shadow.h @@ -39,19 +39,6 @@ CCL_NAMESPACE_BEGIN * This is CPU only because of qsort, and malloc or high stack space usage to * record all these intersections. */ -ccl_device_noinline int shadow_intersections_compare(const void *a, const void *b) -{ - const Intersection *isect_a = (const Intersection*)a; - const Intersection *isect_b = (const Intersection*)b; - - if(isect_a->t < isect_b->t) - return -1; - else if(isect_a->t > isect_b->t) - return 1; - else - return 0; -} - #define STACK_MAX_HITS 64 ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray *ray, float3 *shadow) @@ -95,7 +82,7 @@ ccl_device_inline bool shadow_blocked(KernelGlobals *kg, PathState *state, Ray * PathState ps = *state; #endif - qsort(hits, num_hits, sizeof(Intersection), shadow_intersections_compare); + qsort(hits, num_hits, sizeof(Intersection), intersections_compare); for(int hit = 0; hit < num_hits; hit++, isect++) { /* adjust intersection distance for moving ray forward */ -- cgit v1.2.3