Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_volume.h
| Context not available. | |||||
| volume_ray.t = FLT_MAX; | volume_ray.t = FLT_MAX; | ||||
| int stack_index = 0, enclosed_index = 0; | int stack_index = 0, enclosed_index = 0; | ||||
| #ifdef __VOLUME_RECORD_ALL__ | |||||
| #define MAX_VOLUME_HITS (2*VOLUME_STACK_SIZE) | |||||
| Intersection hits[MAX_VOLUME_HITS]; | |||||
| uint num_hits = scene_intersect_volume_all(kg, | |||||
| &volume_ray, | |||||
| hits, | |||||
| MAX_VOLUME_HITS); | |||||
| if(num_hits > 0) { | |||||
| int enclosed_volumes[VOLUME_STACK_SIZE]; | |||||
| Intersection *isect = hits; | |||||
| for(uint hit = 0; hit < num_hits; ++hit, ++isect) { | |||||
| ShaderData sd; | |||||
| shader_setup_from_ray(kg, &sd, isect, &volume_ray, 0, 0); | |||||
| if(sd.flag & SD_BACKFACING) { | |||||
| /* If ray exited the volume and never entered to that volume | |||||
| * it means that camera is inside such a volume. | |||||
| */ | |||||
| bool is_enclosed = false; | |||||
| for(int i = 0; i < enclosed_index; ++i) { | |||||
| if(enclosed_volumes[i] == sd.object) { | |||||
| is_enclosed = true; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if(is_enclosed == false) { | |||||
| stack[stack_index].object = sd.object; | |||||
| stack[stack_index].shader = sd.shader; | |||||
| ++stack_index; | |||||
| } | |||||
| } | |||||
| else { | |||||
| /* If ray from camera enters the volume, this volume shouldn't | |||||
| * be added to the stack on exit. | |||||
| */ | |||||
| enclosed_volumes[enclosed_index++] = sd.object; | |||||
| } | |||||
| } | |||||
| } | |||||
| #undef MAX_VOLUME_HITS | |||||
| #else | |||||
| int enclosed_volumes[VOLUME_STACK_SIZE]; | int enclosed_volumes[VOLUME_STACK_SIZE]; | ||||
| int step = 0; | int step = 0; | ||||
| Context not available. | |||||
| volume_ray.P = ray_offset(sd.P, -sd.Ng); | volume_ray.P = ray_offset(sd.P, -sd.Ng); | ||||
| ++step; | ++step; | ||||
| } | } | ||||
| #endif | |||||
| /* stack_index of 0 means quick checks outside of the kernel gave false | /* stack_index of 0 means quick checks outside of the kernel gave false | ||||
| * positive, nothing to worry about, just we've wasted quite a few of | * positive, nothing to worry about, just we've wasted quite a few of | ||||
| * ticks just to come into conclusion that camera is in the air. | * ticks just to come into conclusion that camera is in the air. | ||||
| Context not available. | |||||
| } | } | ||||
| } | } | ||||
| #ifdef __SUBSURFACE__ | |||||
| ccl_device void kernel_volume_stack_update_for_subsurface(KernelGlobals *kg, | ccl_device void kernel_volume_stack_update_for_subsurface(KernelGlobals *kg, | ||||
| Ray *ray, | Ray *ray, | ||||
| VolumeStack *stack) | VolumeStack *stack) | ||||
| Context not available. | |||||
| kernel_assert(kernel_data.integrator.use_volumes); | kernel_assert(kernel_data.integrator.use_volumes); | ||||
| Ray volume_ray = *ray; | Ray volume_ray = *ray; | ||||
| #ifdef __VOLUME_RECORD_ALL__ | |||||
| #define MAX_VOLUME_HITS (VOLUME_STACK_SIZE) | |||||
| Intersection hits[MAX_VOLUME_HITS]; | |||||
| uint num_hits = scene_intersect_volume_all(kg, | |||||
| &volume_ray, | |||||
| hits, | |||||
| MAX_VOLUME_HITS); | |||||
| if(num_hits > 0) { | |||||
| Intersection *isect = hits; | |||||
| for(uint hit = 0; hit < num_hits; ++hit, ++isect) { | |||||
| ShaderData sd; | |||||
| shader_setup_from_ray(kg, &sd, isect, &volume_ray, 0, 0); | |||||
| kernel_volume_stack_enter_exit(kg, &sd, stack); | |||||
| } | |||||
| } | |||||
| #undef MAX_VOLUME_HITS | |||||
| #else | |||||
| Intersection isect; | Intersection isect; | ||||
| int step = 0; | int step = 0; | ||||
| while(step < VOLUME_STACK_SIZE && | while(step < VOLUME_STACK_SIZE && | ||||
| Context not available. | |||||
| volume_ray.t -= sd.ray_length; | volume_ray.t -= sd.ray_length; | ||||
| ++step; | ++step; | ||||
| } | } | ||||
| } | |||||
| #endif | #endif | ||||
| } | |||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
| Context not available. | |||||