Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/kernel_volume.h
| Context not available. | |||||
| Ray *ray, | Ray *ray, | ||||
| VolumeStack *stack) | VolumeStack *stack) | ||||
| { | { | ||||
| #define MAX_VOLUME_HITS (2*VOLUME_STACK_SIZE) | |||||
| /* NULL ray happens in the baker, does it need proper initialization of | /* NULL ray happens in the baker, does it need proper initialization of | ||||
| * camera in volume? | * camera in volume? | ||||
| */ | */ | ||||
| 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; | ||||
| int enclosed_volumes[VOLUME_STACK_SIZE]; | Intersection hits[MAX_VOLUME_HITS]; | ||||
| int step = 0; | uint num_hits = scene_intersect_volume_all(kg, | ||||
| &volume_ray, | |||||
| while(stack_index < VOLUME_STACK_SIZE - 1 && | hits, | ||||
| enclosed_index < VOLUME_STACK_SIZE - 1 && | MAX_VOLUME_HITS); | ||||
| step < 2 * VOLUME_STACK_SIZE) | if(num_hits > 0) { | ||||
| { | int enclosed_volumes[VOLUME_STACK_SIZE]; | ||||
| Intersection isect; | Intersection *isect = hits; | ||||
| if(!scene_intersect_volume(kg, &volume_ray, &isect)) { | |||||
| break; | for(uint hit = 0; hit < num_hits; ++hit, ++isect) { | ||||
| } | ShaderData sd; | ||||
| shader_setup_from_ray(kg, &sd, isect, &volume_ray, 0, 0); | |||||
| ShaderData sd; | if(sd.flag & SD_BACKFACING) { | ||||
| shader_setup_from_ray(kg, &sd, &isect, &volume_ray, 0, 0); | /* If ray exited the volume and never entered to that volume | ||||
| if(sd.flag & SD_BACKFACING) { | * it means that camera is inside such a volume. | ||||
| /* 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) { | ||||
| bool is_enclosed = false; | if(enclosed_volumes[i] == sd.object) { | ||||
| for(int i = 0; i < enclosed_index; ++i) { | is_enclosed = true; | ||||
| if(enclosed_volumes[i] == sd.object) { | break; | ||||
| is_enclosed = true; | } | ||||
| break; | } | ||||
| if(is_enclosed == false) { | |||||
| stack[stack_index].object = sd.object; | |||||
| stack[stack_index].shader = sd.shader; | |||||
| ++stack_index; | |||||
| } | } | ||||
| } | } | ||||
| if(is_enclosed == false) { | else { | ||||
| stack[stack_index].object = sd.object; | /* If ray from camera enters the volume, this volume shouldn't | ||||
| stack[stack_index].shader = sd.shader; | * be added to the stack on exit. | ||||
| ++stack_index; | */ | ||||
| enclosed_volumes[enclosed_index++] = sd.object; | |||||
| } | } | ||||
| } | } | ||||
| 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; | |||||
| } | |||||
| /* Move ray forward. */ | |||||
| volume_ray.P = ray_offset(sd.P, -sd.Ng); | |||||
| ++step; | |||||
| } | } | ||||
| /* 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 | ||||
| Context not available. | |||||
| else { | else { | ||||
| stack[stack_index].shader = SHADER_NONE; | stack[stack_index].shader = SHADER_NONE; | ||||
| } | } | ||||
| #undef MAX_VOLUME_HITS | |||||
| } | } | ||||
| ccl_device void kernel_volume_stack_enter_exit(KernelGlobals *kg, ShaderData *sd, VolumeStack *stack) | ccl_device void kernel_volume_stack_enter_exit(KernelGlobals *kg, ShaderData *sd, VolumeStack *stack) | ||||
| Context not available. | |||||