42 shader_setup_wavelength(kg, sd,
state);
84 float3 local_ray_P = ray_P;
85 float3 local_ray_D = ray_D;
112 const float transparent =
average(holdout_weight * throughput);
131#ifdef __LIGHT_LINKING__
139#ifdef __SHADOW_LINKING__
155 kg,
state, path_visibility, path_flag, sd);
169 float sum_sample_weight = 0.0f;
170 for (
int i = 0; i < sd->num_closure; i++) {
171 const ccl_private ShaderClosure *sc = &sd->closure[i];
174 sum_sample_weight += sc->sample_weight;
177 if (sum_sample_weight <= 0.0f) {
193#ifdef __RAY_DIFFERENTIALS__
197 const float pick_pdf = pc->sample_weight / sum_sample_weight;
214 const int light_group,
215 const int mnee_vertex_count,
216 const bool constant_light_shader)
218 const DeviceKernel next_kernel = (constant_light_shader) ?
225 if (mnee_vertex_count > 0) {
227 shadow_state = integrator_state_get_mnee_shadow_state(
state);
239 integrator_state_copy_volume_stack_to_shadow(kg, shadow_state,
state);
255 state, path, render_pixel_index);
257 state, path, rng_offset);
259 state, path, rng_pixel);
264 state, path, transparent_bounce);
266 state, path, volume_bounds_bounce);
268 state, path, glossy_bounce);
273 state, path, portal_bounce);
277 if (mnee_vertex_count > 0) {
291 state, path, transmission_bounce);
293 state, path, diffuse_bounce);
295 state, path, bounce);
301#if defined(__PATH_GUIDING__)
305 state, guiding, path_segment);
306 INTEGRATOR_STATE(shadow_state, shadow_path, guiding_light_linking_mis_weight) = 0.0f;
315template<u
int64_t node_feature_mask>
316#if defined(__KERNEL_HIP__)
320#elif defined(__KERNEL_GPU__)
337 int mnee_vertex_count = 0;
344 integrator_state_read_mnee(
state, &ls, &mnee_vertex_count);
371 const bool is_transmission =
dot(ls.D, sd->N) < 0.0f;
373 if (ls.prim !=
PRIM_NONE && ls.prim == sd->prim && ls.object == sd->object) {
376 if (
dot(ls.D, is_transmission ? -sd->Ng : sd->Ng) > 0.0f) {
385 if (mnee_vertex_count == 0 && is_transmission &&
397 kg, ls.shader, ls.prim, ls.type !=
LIGHT_TRIANGLE, light_shader_eval);
401 float avg_roughness_squared = 0.0f;
403 kg,
state, sd, ls.D, &
bsdf_eval, ls.shader, avg_roughness_squared);
408 if (mnee_vertex_count > 0) {
409 light_shader_eval *= integrator_state_read_mnee_throughput(
state);
416 integrator_state_read_mnee_ray(
state, &ls, &ray);
440#ifdef __RAY_DIFFERENTIALS__
459 is_constant_light_shader);
461 if (is_transmission) {
463 volume_stack_enter_exit<true>(kg, shadow_state, sd);
490 state, path, visibility);
514 return subsurface_bounce(kg,
state, sd, sc);
522 float bsdf_pdf = 0.0f;
523 float unguided_bsdf_pdf = 0.0f;
529 float bsdf_eta = 1.0f;
530 float mis_pdf = 1.0f;
532 float bsdf_avg_roughness_squared = 0.0f;
534#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
538 label = surface_shader_bsdf_guided_sample_closure(kg,
548 &bsdf_sampled_roughness,
551 bsdf_avg_roughness_squared);
569 &bsdf_sampled_roughness,
571 bsdf_avg_roughness_squared);
577 unguided_bsdf_pdf = bsdf_pdf;
591#ifdef __RAY_DIFFERENTIALS__
622#ifdef __LIGHT_LINKING__
637 bsdf_sampled_roughness,
647 if (!path_state_volume_next(
state)) {
659 const uint32_t path_flag)
664 state, path, continuation_probability));
665 if (continuation_probability == 0.0f) {
668 if (continuation_probability != 1.0f) {
700 sd,
kernel_data.integrator.ao_additive_factor, &ao_N);
706 bool skip_self =
true;
715 ray.tmax =
kernel_data.integrator.ao_bounces_distance;
717 ray.self.object = (skip_self) ? sd->object :
OBJECT_NONE;
718 ray.self.prim = (skip_self) ? sd->prim :
PRIM_NONE;
730 integrator_state_copy_volume_stack_to_shadow(kg, shadow_state,
state);
744 state, path, render_pixel_index);
746 state, path, rng_offset);
748 state, path, rng_pixel);
752 state, path, visibility);
757 state, path, volume_bounds_bounce);
766template<u
int64_t node_feature_mask>
779 int continue_path_label = 0;
805 update_path_throughput_for_dispersion(kg,
state, sd.rand_wavelength);
816 subsurface_shader_data_setup(kg, &sd);
850#ifdef __DENOISING_FEATURES__
859#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
861 surface_shader_prepare_guiding(kg,
state, &sd, &rng_state);
868 kg,
state, &sd, &rng_state);
877 integrate_surface_ao(kg,
state, &sd, &rng_state);
890# ifdef __DENOISING_FEATURES__
895 continue_path_label = integrate_surface_volume_only_bounce(
state, &sd);
900 volume_stack_enter_exit<false>(kg,
state, &sd);
904 return continue_path_label;
907template<DeviceKernel current_kernel>
954#ifdef __SHADOW_LINKING__
958 if (shadow_linking_schedule_intersection_kernel<current_kernel>(kg,
state)) {
ccl_device_forceinline float bsdf_widen_dD(const KernelGlobals kg, const float prev_dD, const float avg_roughness_squared)
ccl_device Spectrum bsdf_eval(KernelGlobals kg, ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 wo, ccl_private float *pdf)
unsigned long long int uint64_t
ccl_device_forceinline float intersection_t_offset(const float t)
ccl_device_inline float3 ray_offset(const float3 P, const float3 Ng)
ccl_device_inline bool light_sample_terminate(KernelGlobals kg, ccl_private BsdfEval *ccl_restrict eval, const float rand_terminate)
ccl_device_inline void light_sample_to_surface_shadow_ray(KernelGlobals kg, const ccl_private ShaderData *ccl_restrict sd, const ccl_private LightSample *ccl_restrict ls, ccl_private Ray *ray)
ccl_device bool light_sample_from_position(KernelGlobals kg, const float3 rand, const float time, const float3 P, const float3 N, const int object_receiver, const int runtime_flags, const int bounce, const uint32_t path_flag, ccl_private LightSample *ls)
ccl_device_inline float light_sample_mis_weight_nee(KernelGlobals kg, const float nee_pdf, const float forward_pdf)
ccl_device_inline float3 shadow_ray_offset(KernelGlobals kg, const ccl_private ShaderData *ccl_restrict sd, const float3 L, ccl_private bool *r_skip_self)
CCL_NAMESPACE_BEGIN ccl_device bool light_sample_shader_eval_nee_constant(KernelGlobals kg, const int shader_id, const int prim, const bool is_light, ccl_private Spectrum &eval)
ccl_device_inline float light_sample_mis_weight_forward_surface(KernelGlobals kg, IntegratorState state, const PathRayVisibility path_visibility, const uint32_t path_flag, const ccl_private ShaderData *sd)
ccl_device_inline void film_write_data_passes(KernelGlobals kg, IntegratorState state, const uint32_t path_flag, const ccl_private ShaderData *sd, ccl_global float *ccl_restrict render_buffer)
#define kernel_assert(cond)
#define KERNEL_FEATURE_LIGHT_TREE
#define KERNEL_FEATURE_NODE_PORTAL
#define KERNEL_FEATURE_AO
#define ccl_device_forceinline
#define KERNEL_FEATURE_PATH_GUIDING
#define ccl_optional_struct_init
#define kernel_data_fetch(name, index)
#define ccl_device_inline
#define KERNEL_FEATURE_LIGHT_PASSES
#define KERNEL_FEATURE_SHADOW_LINKING
#define KERNEL_FEATURE_NODE_MASK_SURFACE
#define LIGHT_LINK_MASK_ALL
#define KERNEL_FEATURE_LIGHT_LINKING
#define CLOSURE_IS_BSDF_OR_BSSRDF(type)
#define KERNEL_FEATURE_AO_ADDITIVE
#define CLOSURE_IS_RAY_PORTAL(type)
#define CLOSURE_IS_BSSRDF(type)
#define ccl_device_noinline
#define KERNEL_FEATURE_NODE_RAYTRACE
#define KERNEL_FEATURE_MNEE
#define CCL_NAMESPACE_END
ccl_device_forceinline float differential_make_compact(const float dD)
ccl_device_forceinline float differential_zero_compact()
float3 sample_cos_hemisphere(const float2 rand)
ccl_device_inline void triangle_vertices(KernelGlobals kg, const int object, const int prim, float3 P[3])
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
ccl_gpu_kernel_postfix ccl_global KernelWorkTile const int ccl_global float * render_buffer
ccl_device_inline Transform object_get_inverse_transform(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device_inline int object_lightgroup(KernelGlobals kg, const int object)
ccl_device_forceinline void guiding_record_surface_segment(ccl_attr_maybe_unused KernelGlobals kg, ccl_attr_maybe_unused IntegratorState state, ccl_attr_maybe_unused const ccl_private ShaderData *sd)
ccl_device_forceinline void guiding_record_surface_emission(ccl_attr_maybe_unused KernelGlobals kg, ccl_attr_maybe_unused IntegratorState state, ccl_attr_maybe_unused const Spectrum Le, ccl_attr_maybe_unused const float mis_weight)
ccl_device_forceinline void guiding_write_debug_passes(ccl_attr_maybe_unused KernelGlobals kg, ccl_attr_maybe_unused IntegratorState state, ccl_attr_maybe_unused const ccl_private ShaderData *sd, ccl_attr_maybe_unused ccl_global float *ccl_restrict render_buffer)
ccl_device_forceinline void guiding_record_surface_bounce(ccl_attr_maybe_unused KernelGlobals kg, ccl_attr_maybe_unused IntegratorState state, ccl_attr_maybe_unused const Spectrum weight, ccl_attr_maybe_unused const float pdf, ccl_attr_maybe_unused const float3 N, ccl_attr_maybe_unused const float3 wo, ccl_attr_maybe_unused const float2 roughness, ccl_attr_maybe_unused const float eta)
ccl_device_inline bool light_link_object_match(KernelGlobals kg, const int receiver, const int emitter)
ccl_device_inline int light_link_receiver_nee(KernelGlobals kg, const ccl_private ShaderData *sd)
ccl_device_inline int light_link_receiver_forward(KernelGlobals kg, IntegratorState state)
uint32_t PathRayVisibility
@ PRIMITIVE_MOTION_TRIANGLE
@ PATH_RAY_SHADOW_CATCHER_PASS
@ PATH_RAY_TRANSPARENT_BACKGROUND
@ PATH_RAY_TERMINATE_ON_NEXT_SURFACE
@ PATH_RAY_VISIBILITY_CAMERA
@ SD_OBJECT_TRANSFORM_APPLIED
@ SD_OBJECT_CAUSTICS_CASTER
@ LABEL_SUBSURFACE_SCATTER
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_SUBSURFACE
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE
@ DEVICE_KERNEL_INTEGRATOR_SHADOW_PATH_MNEE_PENDING
@ DEVICE_KERNEL_INTEGRATOR_SHADE_LIGHT_NEE
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_SHADOW
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST
ccl_device_inline void film_write_surface_emission(KernelGlobals kg, ConstIntegratorState state, const Spectrum L, const float mis_weight, ccl_global float *ccl_restrict render_buffer, const int lightgroup=LIGHTGROUP_NONE)
ccl_device_inline void film_write_holdout(KernelGlobals kg, ConstIntegratorState state, const uint32_t path_flag, const float transparent, ccl_global float *ccl_restrict render_buffer)
ccl_device_inline bool bsdf_eval_is_zero(ccl_private BsdfEval *eval)
ccl_device_inline Spectrum bsdf_eval_pass_glossy_weight(const ccl_private BsdfEval *eval)
ccl_device_inline void bsdf_eval_mul(ccl_private BsdfEval *eval, const float value)
ccl_device_inline Spectrum bsdf_eval_sum(const ccl_private BsdfEval *eval)
ccl_device_inline Spectrum bsdf_eval_pass_diffuse_weight(const ccl_private BsdfEval *eval)
ccl_device_inline dual1 len_squared(const ccl_private dual< T > &a)
ccl_device_inline bool isequal(const float2 a, const float2 b)
ccl_device_forceinline bool ray_triangle_intersect_self(const float3 ray_P, const float3 ray_D, const float3 verts[3])
#define PROFILING_INIT_FOR_SHADER(kg, event)
#define PROFILING_EVENT(event)
#define PROFILING_SHADER(object, shader)
ccl_device_inline void motion_triangle_vertices(KernelGlobals kg, const int object, const uint3 tri_vindex, const int numsteps, const int numverts, const int step, const float t, float3 verts[3])
ccl_device_inline float path_state_rng_light_termination(KernelGlobals kg, const ccl_private RNGState *state)
ccl_device_inline void path_state_rng_load(ConstIntegratorState state, ccl_private RNGState *rng_state)
ccl_device_inline void path_state_next(KernelGlobals kg, IntegratorState state, const int label, const int runtime_flag)
ccl_device_inline float2 path_state_rng_2D(KernelGlobals kg, const ccl_private RNGState *rng_state, const int dimension)
ccl_device_inline float3 path_state_rng_3D(KernelGlobals kg, const ccl_private RNGState *rng_state, const int dimension)
@ PROFILING_SHADE_SURFACE_SETUP
@ PROFILING_SHADE_SURFACE_EVAL
@ PROFILING_SHADE_SURFACE_INDIRECT_LIGHT
@ PROFILING_SHADE_SURFACE_AO
@ PROFILING_SHADE_SURFACE_DIRECT_LIGHT
@ PROFILING_SHADE_SURFACE_PASSES
ccl_device_inline IntegratorShadowState integrate_direct_light_shadow_init_common(KernelGlobals kg, IntegratorState state, const ccl_private Ray *ccl_restrict ray, const Spectrum bsdf_spectrum, const int light_group, const int mnee_vertex_count, const bool constant_light_shader)
ccl_device_forceinline float3 integrate_surface_ray_offset(KernelGlobals kg, const ccl_private ShaderData *sd, const float3 ray_P, const float3 ray_D)
ccl_device_forceinline void integrator_shade_surface(KernelGlobals kg, IntegratorState state, ccl_global float *ccl_restrict render_buffer)
ccl_device_forceinline bool integrate_surface_holdout(KernelGlobals kg, ConstIntegratorState state, ccl_private ShaderData *sd, ccl_global float *ccl_restrict render_buffer)
ccl_device int integrate_surface_ray_portal(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc)
ccl_device_forceinline void integrator_shade_surface_next_kernel(IntegratorState state)
ccl_device int integrate_surface(KernelGlobals kg, IntegratorState state, ccl_global float *ccl_restrict render_buffer)
ccl_device_forceinline bool integrate_surface_terminate(IntegratorState state, const uint32_t path_flag)
ccl_device_forceinline void integrate_surface_emission(KernelGlobals kg, IntegratorState state, const ccl_private ShaderData *sd, ccl_global float *ccl_restrict render_buffer)
ccl_device_forceinline void integrator_shade_surface_raytrace(KernelGlobals kg, IntegratorState state, ccl_global float *ccl_restrict render_buffer)
ccl_device_forceinline int integrate_surface_bsdf_bssrdf_bounce(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *sd, const ccl_private RNGState *rng_state)
ccl_device ShaderEvalResult integrate_surface_direct_light(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *sd, const ccl_private RNGState *rng_state)
CCL_NAMESPACE_BEGIN ccl_device_forceinline void integrate_surface_shader_setup(KernelGlobals kg, ConstIntegratorState state, ccl_private ShaderData *sd)
ccl_device_inline void shader_setup_from_ray(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, const ccl_private Ray *ccl_restrict ray, const ccl_private Intersection *ccl_restrict isect)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING bsdf_eval_average
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
KERNEL_FEATURE_LIGHT_PASSES unlit_throughput
IntegratorShadowStateCPU * IntegratorShadowState
#define INTEGRATOR_STATE_WRITE(state, nested_struct, member)
#define INTEGRATOR_STATE(state, nested_struct, member)
IntegratorStateCPU * IntegratorState
const IntegratorStateCPU * ConstIntegratorState
ccl_device_forceinline void integrator_shadow_path_terminate(IntegratorShadowState state, const DeviceKernel current_kernel)
ccl_device_forceinline void integrator_shadow_path_next(IntegratorShadowState state, const DeviceKernel current_kernel, const DeviceKernel next_kernel)
ccl_device_forceinline void integrator_path_next(IntegratorState state, const DeviceKernel current_kernel, const DeviceKernel next_kernel)
ccl_device_forceinline void integrator_path_terminate(KernelGlobals kg, IntegratorState state, ccl_global float *ccl_restrict render_buffer, const DeviceKernel current_kernel)
ccl_device_forceinline void integrator_path_cache_miss_sorted(IntegratorState, const DeviceKernel)
ccl_device_forceinline IntegratorShadowState integrator_shadow_path_init(ccl_attr_maybe_unused KernelGlobals kg, IntegratorState state, const DeviceKernel next_kernel, const bool is_ao)
ccl_device_forceinline void integrator_state_write_shadow_ray_self(IntegratorShadowState state, const ccl_private Ray *ccl_restrict ray)
ccl_device_forceinline void integrator_state_read_ray(ConstIntegratorState state, ccl_private Ray *ccl_restrict ray)
ccl_device_forceinline void integrator_state_write_shadow_ray(IntegratorShadowState state, const ccl_private Ray *ccl_restrict ray)
ccl_device_forceinline void integrator_state_read_isect(ConstIntegratorState state, ccl_private Intersection *ccl_restrict isect)
const ccl_device_inline ccl_private ShaderClosure * surface_shader_bsdf_bssrdf_pick(const ccl_private ShaderData *ccl_restrict sd, ccl_private float3 *rand_bsdf)
ccl_device int surface_shader_bsdf_sample_closure(KernelGlobals kg, ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 rand_bsdf, ccl_private BsdfEval *bsdf_eval, ccl_private float3 *wo, ccl_private float *pdf, ccl_private float2 *sampled_roughness, ccl_private float *eta, ccl_private float &r_avg_roughness_squared)
ccl_device void surface_shader_eval(KernelGlobals kg, ConstIntegratorGenericState state, ccl_private ShaderData *ccl_restrict sd, ccl_global float *ccl_restrict buffer, const PathRayVisibility path_visibility, const uint32_t path_flag, bool use_caustics_storage=false)
ccl_device Spectrum surface_shader_ao(const ccl_private ShaderData *sd, const float ao_factor, ccl_private float3 *N_)
ccl_device float surface_shader_bsdf_eval(KernelGlobals kg, ccl_attr_maybe_unused IntegratorState state, ccl_private ShaderData *sd, const float3 wo, ccl_private BsdfEval *bsdf_eval, const uint light_shader_flags, ccl_private float &r_avg_roughness_squared)
ccl_device Spectrum surface_shader_alpha(const ccl_private ShaderData *sd)
ccl_device Spectrum surface_shader_apply_holdout(ccl_private ShaderData *sd)
ccl_device Spectrum surface_shader_emission(const ccl_private ShaderData *sd)
CCL_NAMESPACE_BEGIN ccl_device_inline void surface_shader_prepare_closures(KernelGlobals kg, ConstIntegratorState state, ccl_private ShaderData *sd, const PathRayVisibility path_visibility)
packed_float3 PackedSpectrum