Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh_volume_all.h
| Show All 29 Lines | |||||
| * BVH_MOTION: motion blur rendering | * BVH_MOTION: motion blur rendering | ||||
| */ | */ | ||||
| #ifndef __KERNEL_GPU__ | #ifndef __KERNEL_GPU__ | ||||
| ccl_device | ccl_device | ||||
| #else | #else | ||||
| ccl_device_inline | ccl_device_inline | ||||
| #endif | #endif | ||||
| uint BVH_FUNCTION_FULL_NAME(BVH)(KernelGlobals *kg, | uint BVH_FUNCTION_FULL_NAME(BVH)(const KernelGlobals *kg, | ||||
| const Ray *ray, | const Ray *ray, | ||||
| Intersection *isect_array, | Intersection *isect_array, | ||||
| const uint max_hits, | const uint max_hits, | ||||
| const uint visibility) | const uint visibility) | ||||
| { | { | ||||
| /* todo: | /* todo: | ||||
| * - test if pushing distance on the stack helps (for non shadow rays) | * - test if pushing distance on the stack helps (for non shadow rays) | ||||
| * - separate version for shadow rays | * - separate version for shadow rays | ||||
| ▲ Show 20 Lines • Show All 98 Lines • ▼ Show 20 Lines | #endif | ||||
| /* only primitives from volume object */ | /* only primitives from volume object */ | ||||
| uint tri_object = (object == OBJECT_NONE) ? | uint tri_object = (object == OBJECT_NONE) ? | ||||
| kernel_tex_fetch(__prim_object, prim_addr) : | kernel_tex_fetch(__prim_object, prim_addr) : | ||||
| object; | object; | ||||
| int object_flag = kernel_tex_fetch(__object_flag, tri_object); | int object_flag = kernel_tex_fetch(__object_flag, tri_object); | ||||
| if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { | if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| hit = triangle_intersect(kg, isect_array, P, dir, visibility, object, prim_addr); | hit = triangle_intersect( | ||||
| kg, isect_array, P, dir, isect_t, visibility, object, prim_addr); | |||||
| if (hit) { | if (hit) { | ||||
| /* Move on to next entry in intersections array. */ | /* Move on to next entry in intersections array. */ | ||||
| isect_array++; | isect_array++; | ||||
| num_hits++; | num_hits++; | ||||
| num_hits_in_instance++; | num_hits_in_instance++; | ||||
| isect_array->t = isect_t; | isect_array->t = isect_t; | ||||
| if (num_hits == max_hits) { | if (num_hits == max_hits) { | ||||
| if (object != OBJECT_NONE) { | if (object != OBJECT_NONE) { | ||||
| Show All 23 Lines | #if BVH_FEATURE(BVH_MOTION) | ||||
| uint tri_object = (object == OBJECT_NONE) ? | uint tri_object = (object == OBJECT_NONE) ? | ||||
| kernel_tex_fetch(__prim_object, prim_addr) : | kernel_tex_fetch(__prim_object, prim_addr) : | ||||
| object; | object; | ||||
| int object_flag = kernel_tex_fetch(__object_flag, tri_object); | int object_flag = kernel_tex_fetch(__object_flag, tri_object); | ||||
| if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { | if ((object_flag & SD_OBJECT_HAS_VOLUME) == 0) { | ||||
| continue; | continue; | ||||
| } | } | ||||
| hit = motion_triangle_intersect( | hit = motion_triangle_intersect( | ||||
| kg, isect_array, P, dir, ray->time, visibility, object, prim_addr); | kg, isect_array, P, dir, isect_t, ray->time, visibility, object, prim_addr); | ||||
| if (hit) { | if (hit) { | ||||
| /* Move on to next entry in intersections array. */ | /* Move on to next entry in intersections array. */ | ||||
| isect_array++; | isect_array++; | ||||
| num_hits++; | num_hits++; | ||||
| num_hits_in_instance++; | num_hits_in_instance++; | ||||
| isect_array->t = isect_t; | isect_array->t = isect_t; | ||||
| if (num_hits == max_hits) { | if (num_hits == max_hits) { | ||||
| if (object != OBJECT_NONE) { | if (object != OBJECT_NONE) { | ||||
| Show All 21 Lines | #endif /* BVH_MOTION */ | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* instance push */ | /* instance push */ | ||||
| object = kernel_tex_fetch(__prim_object, -prim_addr - 1); | object = kernel_tex_fetch(__prim_object, -prim_addr - 1); | ||||
| int object_flag = kernel_tex_fetch(__object_flag, object); | int object_flag = kernel_tex_fetch(__object_flag, object); | ||||
| if (object_flag & SD_OBJECT_HAS_VOLUME) { | if (object_flag & SD_OBJECT_HAS_VOLUME) { | ||||
| #if BVH_FEATURE(BVH_MOTION) | #if BVH_FEATURE(BVH_MOTION) | ||||
| isect_t = bvh_instance_motion_push( | isect_t *= bvh_instance_motion_push(kg, object, ray, &P, &dir, &idir, &ob_itfm); | ||||
| kg, object, ray, &P, &dir, &idir, isect_t, &ob_itfm); | |||||
| #else | #else | ||||
| isect_t = bvh_instance_push(kg, object, ray, &P, &dir, &idir, isect_t); | isect_t *= bvh_instance_push(kg, object, ray, &P, &dir, &idir); | ||||
| #endif | #endif | ||||
| num_hits_in_instance = 0; | num_hits_in_instance = 0; | ||||
| isect_array->t = isect_t; | isect_array->t = isect_t; | ||||
| ++stack_ptr; | ++stack_ptr; | ||||
| kernel_assert(stack_ptr < BVH_STACK_SIZE); | kernel_assert(stack_ptr < BVH_STACK_SIZE); | ||||
| traversal_stack[stack_ptr] = ENTRYPOINT_SENTINEL; | traversal_stack[stack_ptr] = ENTRYPOINT_SENTINEL; | ||||
| ▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | #endif | ||||
| node_addr = traversal_stack[stack_ptr]; | node_addr = traversal_stack[stack_ptr]; | ||||
| --stack_ptr; | --stack_ptr; | ||||
| } | } | ||||
| } while (node_addr != ENTRYPOINT_SENTINEL); | } while (node_addr != ENTRYPOINT_SENTINEL); | ||||
| return num_hits; | return num_hits; | ||||
| } | } | ||||
| ccl_device_inline uint BVH_FUNCTION_NAME(KernelGlobals *kg, | ccl_device_inline uint BVH_FUNCTION_NAME(const KernelGlobals *kg, | ||||
| const Ray *ray, | const Ray *ray, | ||||
| Intersection *isect_array, | Intersection *isect_array, | ||||
| const uint max_hits, | const uint max_hits, | ||||
| const uint visibility) | const uint visibility) | ||||
| { | { | ||||
| return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect_array, max_hits, visibility); | return BVH_FUNCTION_FULL_NAME(BVH)(kg, ray, isect_array, max_hits, visibility); | ||||
| } | } | ||||
| #undef BVH_FUNCTION_NAME | #undef BVH_FUNCTION_NAME | ||||
| #undef BVH_FUNCTION_FEATURES | #undef BVH_FUNCTION_FEATURES | ||||
| #undef NODE_INTERSECT | #undef NODE_INTERSECT | ||||