Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/integrator/intersect_closest.h
| Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | if (!integrator_state_volume_stack_is_empty(kg, state)) { | ||||
| } | } | ||||
| return; | return; | ||||
| } | } | ||||
| #endif | #endif | ||||
| if (hit) { | if (hit) { | ||||
| /* Hit a surface, continue with light or surface kernel. */ | /* Hit a surface, continue with light or surface kernel. */ | ||||
| if (isect->type & PRIMITIVE_LAMP) { | if (isect->type & PRIMITIVE_LAMP) { | ||||
| const int lamp = isect->prim; | |||||
| ccl_global const KernelLight *klight = &kernel_data_fetch(lights, lamp); | |||||
| path_automata_emit_light_event(kg, state, klight->lpe_tag_index); | |||||
| integrator_path_next(kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT); | integrator_path_next(kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT); | ||||
| } | } | ||||
| else { | else { | ||||
| /* Hit a surface, continue with surface kernel unless terminated. */ | /* Hit a surface, continue with surface kernel unless terminated. */ | ||||
| const int shader = intersection_get_shader(kg, isect); | const int shader = intersection_get_shader(kg, isect); | ||||
| const int flags = kernel_data_fetch(shaders, shader).flags; | const int flags = kernel_data_fetch(shaders, shader).flags; | ||||
| if (flags & SD_HAS_EMISSION) { | |||||
| ccl_global const KernelObject *kobject = &kernel_data_fetch(objects, isect->object); | |||||
| path_automata_emit_emissive_object_event(kg, state, kobject->lpe_tag_index); | |||||
| } | |||||
| if (!integrator_intersect_terminate(kg, state, flags)) { | if (!integrator_intersect_terminate(kg, state, flags)) { | ||||
| const int object_flags = intersection_get_object_flags(kg, isect); | const int object_flags = intersection_get_object_flags(kg, isect); | ||||
| const bool use_caustics = kernel_data.integrator.use_caustics && | const bool use_caustics = kernel_data.integrator.use_caustics && | ||||
| (object_flags & SD_OBJECT_CAUSTICS); | (object_flags & SD_OBJECT_CAUSTICS); | ||||
| const bool use_raytrace_kernel = (flags & SD_HAS_RAYTRACE); | const bool use_raytrace_kernel = (flags & SD_HAS_RAYTRACE); | ||||
| if (use_caustics) { | if (use_caustics) { | ||||
| integrator_path_next_sorted( | integrator_path_next_sorted( | ||||
| kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE, shader); | kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE, shader); | ||||
| Show All 13 Lines | |||||
| #endif | #endif | ||||
| } | } | ||||
| else { | else { | ||||
| integrator_path_terminate(kg, state, current_kernel); | integrator_path_terminate(kg, state, current_kernel); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Background emission is a treated as light source. */ | |||||
| /* TODO(lpe) : background event, which is not for light, but to create masks */ | |||||
| path_automata_emit_light_event(kg, state, PATH_EVENT_LABEL_NONE); | |||||
| /* Nothing hit, continue with background kernel. */ | /* Nothing hit, continue with background kernel. */ | ||||
| integrator_path_next(kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND); | integrator_path_next(kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND); | ||||
| } | } | ||||
| } | } | ||||
| /* Schedule next kernel to be executed after shade volume. | /* Schedule next kernel to be executed after shade volume. | ||||
| * | * | ||||
| * The logic here matches integrator_intersect_next_kernel, except that | * The logic here matches integrator_intersect_next_kernel, except that | ||||
| * volume shading and termination testing have already been done. */ | * volume shading and termination testing have already been done. */ | ||||
| template<DeviceKernel current_kernel> | template<DeviceKernel current_kernel> | ||||
| ccl_device_forceinline void integrator_intersect_next_kernel_after_volume( | ccl_device_forceinline void integrator_intersect_next_kernel_after_volume( | ||||
| KernelGlobals kg, | KernelGlobals kg, | ||||
| IntegratorState state, | IntegratorState state, | ||||
| ccl_private const Intersection *ccl_restrict isect, | ccl_private const Intersection *ccl_restrict isect, | ||||
| ccl_global float *ccl_restrict render_buffer) | ccl_global float *ccl_restrict render_buffer) | ||||
| { | { | ||||
| if (isect->prim != PRIM_NONE) { | if (isect->prim != PRIM_NONE) { | ||||
| /* Hit a surface, continue with light or surface kernel. */ | /* Hit a surface, continue with light or surface kernel. */ | ||||
| if (isect->type & PRIMITIVE_LAMP) { | if (isect->type & PRIMITIVE_LAMP) { | ||||
| const int lamp = isect->prim; | |||||
| ccl_global const KernelLight *klight = &kernel_data_fetch(lights, lamp); | |||||
| path_automata_emit_light_event(kg, state, klight->lpe_tag_index); | |||||
| integrator_path_next(kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT); | integrator_path_next(kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT); | ||||
| return; | return; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Hit a surface, continue with surface kernel unless terminated. */ | /* Hit a surface, continue with surface kernel unless terminated. */ | ||||
| const int shader = intersection_get_shader(kg, isect); | const int shader = intersection_get_shader(kg, isect); | ||||
| const int flags = kernel_data_fetch(shaders, shader).flags; | const int flags = kernel_data_fetch(shaders, shader).flags; | ||||
| const int object_flags = intersection_get_object_flags(kg, isect); | const int object_flags = intersection_get_object_flags(kg, isect); | ||||
| const bool use_caustics = kernel_data.integrator.use_caustics && | const bool use_caustics = kernel_data.integrator.use_caustics && | ||||
| (object_flags & SD_OBJECT_CAUSTICS); | (object_flags & SD_OBJECT_CAUSTICS); | ||||
| const bool use_raytrace_kernel = (flags & SD_HAS_RAYTRACE); | const bool use_raytrace_kernel = (flags & SD_HAS_RAYTRACE); | ||||
| if (flags & SD_HAS_EMISSION) { | |||||
| ccl_global const KernelObject *kobject = &kernel_data_fetch(objects, isect->object); | |||||
| path_automata_emit_emissive_object_event(kg, state, kobject->lpe_tag_index); | |||||
| } | |||||
| if (use_caustics) { | if (use_caustics) { | ||||
| integrator_path_next_sorted( | integrator_path_next_sorted( | ||||
| kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE, shader); | kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE, shader); | ||||
| } | } | ||||
| else if (use_raytrace_kernel) { | else if (use_raytrace_kernel) { | ||||
| integrator_path_next_sorted( | integrator_path_next_sorted( | ||||
| kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE, shader); | kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE, shader); | ||||
| } | } | ||||
| else { | else { | ||||
| integrator_path_next_sorted( | integrator_path_next_sorted( | ||||
| kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE, shader); | kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE, shader); | ||||
| } | } | ||||
| #ifdef __SHADOW_CATCHER__ | #ifdef __SHADOW_CATCHER__ | ||||
| /* Handle shadow catcher. */ | /* Handle shadow catcher. */ | ||||
| integrator_split_shadow_catcher(kg, state, isect, render_buffer); | integrator_split_shadow_catcher(kg, state, isect, render_buffer); | ||||
| #endif | #endif | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| /* Background emission is a treated as light source. */ | |||||
| /* TODO(lpe) : background event */ | |||||
| path_automata_emit_light_event(kg, state, PATH_EVENT_LABEL_NONE); | |||||
| /* Nothing hit, continue with background kernel. */ | /* Nothing hit, continue with background kernel. */ | ||||
| integrator_path_next(kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND); | integrator_path_next(kg, state, current_kernel, DEVICE_KERNEL_INTEGRATOR_SHADE_BACKGROUND); | ||||
| return; | return; | ||||
| } | } | ||||
| } | } | ||||
| ccl_device void integrator_intersect_closest(KernelGlobals kg, | ccl_device void integrator_intersect_closest(KernelGlobals kg, | ||||
| IntegratorState state, | IntegratorState state, | ||||
| ▲ Show 20 Lines • Show All 85 Lines • Show Last 20 Lines | |||||