82 float3 local_ray_P = ray_P;
83 float3 local_ray_D = ray_D;
110 const float transparent =
average(holdout_weight * throughput);
128#ifdef __LIGHT_LINKING__
136#ifdef __SHADOW_LINKING__
165 float sum_sample_weight = 0.0f;
166 for (
int i = 0;
i < sd->num_closure;
i++) {
170 sum_sample_weight += sc->sample_weight;
173 if (sum_sample_weight <= 0.0f) {
189#ifdef __RAY_DIFFERENTIALS__
193 const float pick_pdf = pc->sample_weight / sum_sample_weight;
210 const int light_group,
211 const int mnee_vertex_count)
220 integrator_state_copy_volume_stack_to_shadow(kg, shadow_state,
state);
229 const Spectrum throughput = unlit_throughput * bsdf_spectrum;
232 state, path, render_pixel_index);
234 state, path, rng_offset);
236 state, path, rng_pixel);
241 state, path, transparent_bounce);
243 state, path, volume_bounds_bounce);
245 state, path, glossy_bounce);
250 state, path, portal_bounce);
254 if (mnee_vertex_count > 0) {
268 state, path, transmission_bounce);
270 state, path, diffuse_bounce);
272 state, path, bounce);
278#if defined(__PATH_GUIDING__)
282 state, guiding, path_segment);
292template<u
int node_feature_mask>
293#if defined(__KERNEL_GPU__)
334 const bool is_transmission =
dot(ls.D, sd->N) < 0.0f;
336 if (ls.prim !=
PRIM_NONE && ls.prim == sd->prim && ls.object == sd->object) {
339 if (
dot(ls.D, is_transmission ? -sd->Ng : sd->Ng) > 0.0f) {
356 int mnee_vertex_count = 0;
377 if (mnee_vertex_count > 0) {
414 if (is_transmission) {
416 volume_stack_enter_exit<true>(kg, shadow_state, sd);
463 return subsurface_bounce(kg,
state, sd, sc);
471 float bsdf_pdf = 0.0f;
472 float unguided_bsdf_pdf = 0.0f;
478 float bsdf_eta = 1.0f;
479 float mis_pdf = 1.0f;
481#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
485 label = surface_shader_bsdf_guided_sample_closure(kg,
495 &bsdf_sampled_roughness,
515 &bsdf_sampled_roughness,
522 unguided_bsdf_pdf = bsdf_pdf;
536#ifdef __RAY_DIFFERENTIALS__
561#ifdef __LIGHT_LINKING__
576 bsdf_sampled_roughness,
586 if (!path_state_volume_next(
state)) {
598 const uint32_t path_flag)
603 state, path, continuation_probability);
604 if (continuation_probability == 0.0f) {
607 if (continuation_probability != 1.0f) {
638 sd,
kernel_data.integrator.ao_additive_factor, &ao_N);
644 bool skip_self =
true;
653 ray.tmax =
kernel_data.integrator.ao_bounces_distance;
655 ray.self.object = (skip_self) ? sd->object :
OBJECT_NONE;
656 ray.self.prim = (skip_self) ? sd->prim :
PRIM_NONE;
668 integrator_state_copy_volume_stack_to_shadow(kg, shadow_state,
state);
682 state, path, render_pixel_index);
684 state, path, rng_offset);
686 state, path, rng_pixel);
693 state, path, volume_bounds_bounce);
702template<u
int node_feature_mask>
715 int continue_path_label = 0;
747 subsurface_shader_data_setup(kg, &sd);
781#ifdef __DENOISING_FEATURES__
790#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
792 surface_shader_prepare_guiding(kg,
state, &sd, &rng_state);
804 integrate_surface_ao(kg,
state, &sd, &rng_state);
818 continue_path_label = integrate_surface_volume_only_bounce(
state, &sd);
823 volume_stack_enter_exit<false>(kg,
state, &sd);
827 return continue_path_label;
830template<DeviceKernel current_kernel>
854#ifdef __SHADOW_LINKING__
858 if (shadow_linking_schedule_intersection_kernel<current_kernel>(kg,
state)) {
ccl_device Spectrum bsdf_eval(KernelGlobals kg, ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 wo, ccl_private float *pdf)
dot(value.rgb, luminance_coefficients)") DEFINE_VALUE("REDUCE(lhs
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_NAMESPACE_BEGIN ccl_device_noinline_cpu Spectrum light_sample_shader_eval(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *ccl_restrict emission_sd, ccl_private LightSample *ccl_restrict ls, const float time)
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 shader_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_device_inline float light_sample_mis_weight_forward_surface(KernelGlobals kg, IntegratorState state, const uint32_t path_flag, const ccl_private ShaderData *sd)
ccl_device_inline void film_write_data_passes(KernelGlobals kg, IntegratorState state, const ccl_private ShaderData *sd, ccl_global float *ccl_restrict render_buffer)
#define kernel_assert(cond)
#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 AS_SHADER_DATA(shader_data_tiny_storage)
const ThreadKernelGlobalsCPU * KernelGlobals
#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 KERNEL_FEATURE_NODE_RAYTRACE
#define KERNEL_FEATURE_MNEE
#define IF_KERNEL_FEATURE(feature)
#define CCL_NAMESPACE_END
ccl_device_forceinline float differential_make_compact(const float dD)
ccl_device_forceinline float differential_zero_compact()
ccl_device_inline void triangle_vertices(KernelGlobals kg, const int prim, float3 P[3])
VecBase< float, D > normalize(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_write_debug_passes(KernelGlobals kg, IntegratorState state, const ccl_private ShaderData *sd, ccl_global float *ccl_restrict render_buffer)
ccl_device_forceinline void guiding_record_surface_emission(KernelGlobals kg, IntegratorState state, const Spectrum Le, const float mis_weight)
ccl_device_forceinline void guiding_record_surface_bounce(KernelGlobals kg, IntegratorState state, const Spectrum weight, const float pdf, const float3 N, const float3 wo, const float2 roughness, const float eta)
ccl_device_forceinline void guiding_record_surface_segment(KernelGlobals kg, IntegratorState state, const ccl_private ShaderData *sd)
ccl_device_inline bool light_link_object_match(KernelGlobals kg, const int object_receiver, const int object_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)
@ PRIMITIVE_MOTION_TRIANGLE
@ PATH_RAY_SHADOW_CATCHER_PASS
@ PATH_RAY_TRANSPARENT_BACKGROUND
@ PATH_RAY_TERMINATE_ON_NEXT_SURFACE
@ SD_OBJECT_CAUSTICS_RECEIVER
@ SD_OBJECT_TRANSFORM_APPLIED
@ SD_OBJECT_CAUSTICS_CASTER
@ LABEL_SUBSURFACE_SCATTER
ShaderData ShaderDataCausticsStorage
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_SUBSURFACE
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_RAYTRACE
@ DEVICE_KERNEL_INTEGRATOR_SHADE_SURFACE_MNEE
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_SHADOW
@ DEVICE_KERNEL_INTEGRATOR_INTERSECT_CLOSEST
ccl_device_inline uint lcg_state_init(const uint rng_hash, const uint rng_offset, const uint sample, const uint scramble)
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 float len_squared(const float2 a)
ccl_device_inline bool is_zero(const float2 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_forceinline int kernel_path_mnee_sample(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *sd, ccl_private ShaderData *sd_mnee, const ccl_private RNGState *rng_state, ccl_private LightSample *ls, ccl_private BsdfEval *throughput)
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 shader_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 void sample_cos_hemisphere(const float3 N, const float2 rand_in, ccl_private float3 *wo, ccl_private float *pdf)
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_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)
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 void integrator_shade_surface_mnee(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 void integrate_surface_direct_light(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *sd, const ccl_private RNGState *rng_state)
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_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)
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_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 IntegratorShadowState integrator_shadow_path_init(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 float surface_shader_bsdf_eval(KernelGlobals kg, IntegratorState state, ccl_private ShaderData *sd, const float3 wo, ccl_private BsdfEval *bsdf_eval, const uint light_shader_flags)
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_device void surface_shader_eval(KernelGlobals kg, ConstIntegratorGenericState state, ccl_private ShaderData *ccl_restrict sd, ccl_global float *ccl_restrict buffer, const uint32_t path_flag, bool use_caustics_storage=false)
CCL_NAMESPACE_BEGIN ccl_device_inline void surface_shader_prepare_closures(KernelGlobals kg, ConstIntegratorState state, ccl_private ShaderData *sd, const uint32_t path_flag)
ccl_device Spectrum surface_shader_ao(const ccl_private ShaderData *sd, const float ao_factor, ccl_private float3 *N_)
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)
packed_float3 PackedSpectrum