Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh_embree.h
| Show All 22 Lines | |||||
| #include "util/util_vector.h" | #include "util/util_vector.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| struct CCLIntersectContext { | struct CCLIntersectContext { | ||||
| typedef enum { | typedef enum { | ||||
| RAY_REGULAR = 0, | RAY_REGULAR = 0, | ||||
| RAY_SHADOW_ALL = 1, | RAY_SHADOW_ALL = 1, | ||||
| RAY_SSS = 2, | RAY_LOCAL = 2, | ||||
| RAY_VOLUME_ALL = 3, | RAY_SSS = 3, | ||||
| RAY_VOLUME_ALL = 4, | |||||
| } RayType; | } RayType; | ||||
| KernelGlobals *kg; | KernelGlobals *kg; | ||||
| RayType type; | RayType type; | ||||
| /* for shadow rays */ | /* for shadow rays */ | ||||
| Intersection *isect_s; | Intersection *isect_s; | ||||
| int max_hits; | int max_hits; | ||||
| int num_hits; | int num_hits; | ||||
| /* for SSS Rays: */ | /* for SSS Rays: */ | ||||
| LocalIntersection *ss_isect; | LocalIntersection *local_isect; | ||||
| int sss_object_id; | int local_object_id; | ||||
| uint *lcg_state; | uint *lcg_state; | ||||
| CCLIntersectContext(KernelGlobals *kg_, RayType type_) | CCLIntersectContext(KernelGlobals *kg_, RayType type_) | ||||
| { | { | ||||
| kg = kg_; | kg = kg_; | ||||
| type = type_; | type = type_; | ||||
| max_hits = 1; | max_hits = 1; | ||||
| num_hits = 0; | num_hits = 0; | ||||
| isect_s = NULL; | isect_s = NULL; | ||||
| ss_isect = NULL; | local_isect = NULL; | ||||
| sss_object_id = -1; | local_object_id = -1; | ||||
| lcg_state = NULL; | lcg_state = NULL; | ||||
| } | } | ||||
| }; | }; | ||||
| class IntersectContext { | class IntersectContext { | ||||
| public: | public: | ||||
| IntersectContext(CCLIntersectContext *ctx) | IntersectContext(CCLIntersectContext *ctx) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | ccl_device_inline void kernel_embree_convert_hit(KernelGlobals *kg, | ||||
| else { | else { | ||||
| isect->prim = hit->primID + (intptr_t)rtcGetGeometryUserData( | isect->prim = hit->primID + (intptr_t)rtcGetGeometryUserData( | ||||
| rtcGetGeometry(kernel_data.bvh.scene, hit->geomID)); | rtcGetGeometry(kernel_data.bvh.scene, hit->geomID)); | ||||
| isect->object = OBJECT_NONE; | isect->object = OBJECT_NONE; | ||||
| } | } | ||||
| isect->type = kernel_tex_fetch(__prim_type, isect->prim); | isect->type = kernel_tex_fetch(__prim_type, isect->prim); | ||||
| } | } | ||||
| ccl_device_inline void kernel_embree_convert_local_hit(KernelGlobals *kg, | ccl_device_inline void kernel_embree_convert_sss_hit(KernelGlobals *kg, | ||||
| const RTCRay *ray, | const RTCRay *ray, | ||||
| const RTCHit *hit, | const RTCHit *hit, | ||||
| Intersection *isect, | Intersection *isect, | ||||
| int local_object_id) | int local_object_id) | ||||
| { | { | ||||
| isect->u = 1.0f - hit->v - hit->u; | isect->u = 1.0f - hit->v - hit->u; | ||||
| isect->v = hit->u; | isect->v = hit->u; | ||||
| isect->t = ray->tfar; | isect->t = ray->tfar; | ||||
| isect->Ng = make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z); | isect->Ng = make_float3(hit->Ng_x, hit->Ng_y, hit->Ng_z); | ||||
| RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData( | RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData( | ||||
| rtcGetGeometry(kernel_data.bvh.scene, local_object_id * 2)); | rtcGetGeometry(kernel_data.bvh.scene, local_object_id * 2)); | ||||
| isect->prim = hit->primID + | isect->prim = hit->primID + | ||||
| (intptr_t)rtcGetGeometryUserData(rtcGetGeometry(inst_scene, hit->geomID)) + | (intptr_t)rtcGetGeometryUserData(rtcGetGeometry(inst_scene, hit->geomID)) + | ||||
| kernel_tex_fetch(__object_node, local_object_id); | kernel_tex_fetch(__object_node, local_object_id); | ||||
| isect->object = local_object_id; | isect->object = local_object_id; | ||||
| isect->type = kernel_tex_fetch(__prim_type, isect->prim); | isect->type = kernel_tex_fetch(__prim_type, isect->prim); | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||