Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/integrator/shade_surface.h
| Show First 20 Lines • Show All 312 Lines • ▼ Show 20 Lines | #endif | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, diffuse_bounce) = INTEGRATOR_STATE( | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, diffuse_bounce) = INTEGRATOR_STATE( | ||||
| state, path, diffuse_bounce); | state, path, diffuse_bounce); | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, bounce) = INTEGRATOR_STATE( | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, bounce) = INTEGRATOR_STATE( | ||||
| state, path, bounce); | state, path, bounce); | ||||
| } | } | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = throughput; | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = throughput; | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, lpe_state) = INTEGRATOR_STATE( | |||||
| state, path, lpe_state); | |||||
| if (kernel_data.kernel_features & KERNEL_FEATURE_SHADOW_PASS) { | if (kernel_data.kernel_features & KERNEL_FEATURE_SHADOW_PASS) { | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, unshadowed_throughput) = throughput; | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, unshadowed_throughput) = throughput; | ||||
| } | } | ||||
| /* Write Lightgroup, +1 as lightgroup is int but we need to encode into a uint8_t. */ | /* Write Lightgroup, +1 as lightgroup is int but we need to encode into a uint8_t. */ | ||||
| INTEGRATOR_STATE_WRITE( | INTEGRATOR_STATE_WRITE( | ||||
| shadow_state, shadow_path, lightgroup) = (ls.type != LIGHT_BACKGROUND) ? | shadow_state, shadow_path, lightgroup) = (ls.type != LIGHT_BACKGROUND) ? | ||||
| ls.group + 1 : | ls.group + 1 : | ||||
| kernel_data.background.lightgroup + 1; | kernel_data.background.lightgroup + 1; | ||||
| /* This event should only be in the shadow path, otherwise expressions ending on a light event | |||||
| * might be prematurely ended. */ | |||||
| if (ls.type != LIGHT_TRIANGLE) { | |||||
| const KernelLight *klight = &kernel_data_fetch(lights, ls.lamp); | |||||
| path_automata_emit_light_event_shadow(kg, shadow_state, klight->lpe_tag_index); | |||||
| } | |||||
| else { | |||||
| const KernelObject *kobject = &kernel_data_fetch(objects, ls.object); | |||||
| path_automata_emit_emissive_object_event_shadow(kg, shadow_state, kobject->lpe_tag_index); | |||||
| } | |||||
| } | } | ||||
| /* Path tracing: bounce off or through surface with new direction. */ | /* Path tracing: bounce off or through surface with new direction. */ | ||||
| ccl_device_forceinline int integrate_surface_bsdf_bssrdf_bounce( | ccl_device_forceinline int integrate_surface_bsdf_bssrdf_bounce( | ||||
| KernelGlobals kg, | KernelGlobals kg, | ||||
| IntegratorState state, | IntegratorState state, | ||||
| ccl_private ShaderData *sd, | ccl_private ShaderData *sd, | ||||
| ccl_private const RNGState *rng_state) | ccl_private const RNGState *rng_state) | ||||
| ▲ Show 20 Lines • Show All 171 Lines • ▼ Show 20 Lines | ccl_device_forceinline void integrate_surface_ao(KernelGlobals kg, | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, flag) = shadow_flag; | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, flag) = shadow_flag; | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, bounce) = bounce; | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, bounce) = bounce; | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, transparent_bounce) = transparent_bounce; | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, transparent_bounce) = transparent_bounce; | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = throughput; | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = throughput; | ||||
| if (kernel_data.kernel_features & KERNEL_FEATURE_AO_ADDITIVE) { | if (kernel_data.kernel_features & KERNEL_FEATURE_AO_ADDITIVE) { | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, unshadowed_throughput) = ao_weight; | INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, unshadowed_throughput) = ao_weight; | ||||
| } | } | ||||
| INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, lpe_state) = INTEGRATOR_STATE( | |||||
| state, path, lpe_state); | |||||
| } | } | ||||
| #endif /* defined(__AO__) */ | #endif /* defined(__AO__) */ | ||||
| template<uint node_feature_mask> | template<uint node_feature_mask> | ||||
| ccl_device bool integrate_surface(KernelGlobals kg, | ccl_device bool integrate_surface(KernelGlobals kg, | ||||
| IntegratorState state, | IntegratorState state, | ||||
| ccl_global float *ccl_restrict render_buffer) | ccl_global float *ccl_restrict render_buffer) | ||||
| ▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | #ifdef __DENOISING_FEATURES__ | ||||
| film_write_denoising_features_surface(kg, state, &sd, render_buffer); | film_write_denoising_features_surface(kg, state, &sd, render_buffer); | ||||
| #endif | #endif | ||||
| } | } | ||||
| /* Load random number state. */ | /* Load random number state. */ | ||||
| RNGState rng_state; | RNGState rng_state; | ||||
| path_state_rng_load(state, &rng_state); | path_state_rng_load(state, &rng_state); | ||||
| /* Direct light. */ | |||||
| PROFILING_EVENT(PROFILING_SHADE_SURFACE_DIRECT_LIGHT); | |||||
| integrate_surface_direct_light<node_feature_mask>(kg, state, &sd, &rng_state); | |||||
| #if defined(__AO__) | #if defined(__AO__) | ||||
| /* Ambient occlusion pass. */ | /* Ambient occlusion pass. */ | ||||
| if (kernel_data.kernel_features & KERNEL_FEATURE_AO) { | if (kernel_data.kernel_features & KERNEL_FEATURE_AO) { | ||||
| PROFILING_EVENT(PROFILING_SHADE_SURFACE_AO); | PROFILING_EVENT(PROFILING_SHADE_SURFACE_AO); | ||||
| integrate_surface_ao(kg, state, &sd, &rng_state, render_buffer); | integrate_surface_ao(kg, state, &sd, &rng_state, render_buffer); | ||||
| } | } | ||||
| #endif | #endif | ||||
| PROFILING_EVENT(PROFILING_SHADE_SURFACE_INDIRECT_LIGHT); | PROFILING_EVENT(PROFILING_SHADE_SURFACE_INDIRECT_LIGHT); | ||||
| continue_path_label = integrate_surface_bsdf_bssrdf_bounce(kg, state, &sd, &rng_state); | continue_path_label = integrate_surface_bsdf_bssrdf_bounce(kg, state, &sd, &rng_state); | ||||
| const KernelObject *kobject = &kernel_data_fetch(objects, sd.object); | |||||
| path_automata_emit_bounce(kg, state, continue_path_label, kobject->lpe_tag_index); | |||||
| /* Direct light. | |||||
| * TODO(lpe) : properly refactor this. | |||||
| * Moved after integrate_surface_bounce so that the BDSF evaluation can be used to update the | |||||
| * path automata to emit the interaction event before the light event, and to ensure that the | |||||
| * shadow_path has a proper LPE state taking into account these events. */ | |||||
| PROFILING_EVENT(PROFILING_SHADE_SURFACE_DIRECT_LIGHT); | |||||
| integrate_surface_direct_light<node_feature_mask>(kg, state, &sd, &rng_state); | |||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| } | } | ||||
| else { | else { | ||||
| if (integrate_surface_terminate(state, path_flag)) { | if (integrate_surface_terminate(state, path_flag)) { | ||||
| return false; | return false; | ||||
| } | } | ||||
| PROFILING_EVENT(PROFILING_SHADE_SURFACE_INDIRECT_LIGHT); | PROFILING_EVENT(PROFILING_SHADE_SURFACE_INDIRECT_LIGHT); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • Show Last 20 Lines | |||||