Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/bvh/bvh_embree.h
| Show All 29 Lines | struct CCLIntersectContext { | ||||
| typedef enum { | typedef enum { | ||||
| RAY_REGULAR = 0, | RAY_REGULAR = 0, | ||||
| RAY_SHADOW_ALL = 1, | RAY_SHADOW_ALL = 1, | ||||
| RAY_LOCAL = 2, | RAY_LOCAL = 2, | ||||
| RAY_SSS = 3, | RAY_SSS = 3, | ||||
| RAY_VOLUME_ALL = 4, | RAY_VOLUME_ALL = 4, | ||||
| } RayType; | } RayType; | ||||
| const 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; | ||||
| float max_t; | float max_t; | ||||
| bool opaque_hit; | bool opaque_hit; | ||||
| /* for SSS Rays: */ | /* for SSS Rays: */ | ||||
| LocalIntersection *local_isect; | LocalIntersection *local_isect; | ||||
| int local_object_id; | int local_object_id; | ||||
| uint *lcg_state; | uint *lcg_state; | ||||
| CCLIntersectContext(const 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; | ||||
| max_t = FLT_MAX; | max_t = FLT_MAX; | ||||
| opaque_hit = false; | opaque_hit = false; | ||||
| isect_s = NULL; | isect_s = NULL; | ||||
| Show All 34 Lines | ccl_device_inline void kernel_embree_setup_rayhit(const Ray &ray, | ||||
| RTCRayHit &rayhit, | RTCRayHit &rayhit, | ||||
| const uint visibility) | const uint visibility) | ||||
| { | { | ||||
| kernel_embree_setup_ray(ray, rayhit.ray, visibility); | kernel_embree_setup_ray(ray, rayhit.ray, visibility); | ||||
| rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID; | rayhit.hit.geomID = RTC_INVALID_GEOMETRY_ID; | ||||
| rayhit.hit.primID = RTC_INVALID_GEOMETRY_ID; | rayhit.hit.primID = RTC_INVALID_GEOMETRY_ID; | ||||
| } | } | ||||
| ccl_device_inline void kernel_embree_convert_hit(const KernelGlobals *kg, | ccl_device_inline void kernel_embree_convert_hit(KernelGlobals kg, | ||||
| const RTCRay *ray, | const RTCRay *ray, | ||||
| const RTCHit *hit, | const RTCHit *hit, | ||||
| Intersection *isect) | Intersection *isect) | ||||
| { | { | ||||
| 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); | ||||
| if (hit->instID[0] != RTC_INVALID_GEOMETRY_ID) { | if (hit->instID[0] != RTC_INVALID_GEOMETRY_ID) { | ||||
| RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData( | RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData( | ||||
| Show All 19 Lines | ccl_device_inline void kernel_embree_convert_hit(KernelGlobals kg, | ||||
| else { | else { | ||||
| isect->type = kernel_tex_fetch(__objects, isect->object).primitive_type; | isect->type = kernel_tex_fetch(__objects, isect->object).primitive_type; | ||||
| isect->u = 1.0f - hit->v - hit->u; | isect->u = 1.0f - hit->v - hit->u; | ||||
| isect->v = hit->u; | isect->v = hit->u; | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline void kernel_embree_convert_sss_hit( | ccl_device_inline void kernel_embree_convert_sss_hit( | ||||
| const KernelGlobals *kg, const RTCRay *ray, const RTCHit *hit, Intersection *isect, int object) | KernelGlobals kg, const RTCRay *ray, const RTCHit *hit, Intersection *isect, int object) | ||||
| { | { | ||||
| 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, object * 2)); | rtcGetGeometry(kernel_data.bvh.scene, object * 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)); | ||||
| isect->object = object; | isect->object = object; | ||||
| isect->type = kernel_tex_fetch(__objects, object).primitive_type; | isect->type = kernel_tex_fetch(__objects, object).primitive_type; | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||