57 #ifdef __SHADOW_TRICKS__
67 #ifdef __SHADOW_TRICKS__
125 #ifdef __SHADOW_TRICKS__
133 #ifdef __SHADOW_TRICKS__
194 L->transparent = 0.0f;
210 L->transparent = 0.0f;
214 #ifdef __SHADOW_TRICKS__
218 L->shadow_throughput = 0.0f;
219 L->shadow_transparency = 1.0f;
220 L->has_shadow_catcher = 0;
223 #ifdef __DENOISING_FEATURES__
226 L->denoising_depth = 0.0f;
229 #ifdef __KERNEL_DEBUG__
230 L->debug_data.num_bvh_traversed_nodes = 0;
231 L->debug_data.num_bvh_traversed_instances = 0;
232 L->debug_data.num_bvh_intersections = 0;
233 L->debug_data.num_ray_bounces = 0;
245 float inverse_pdf = 1.0f / bsdf_pdf;
251 float3 value = *throughput * inverse_pdf;
260 L_state->
direct = *throughput;
271 *throughput *=
bsdf_eval->diffuse * inverse_pdf;
275 #ifdef __CLAMP_SAMPLE__
278 float limit = (bounce > 0) ?
kernel_data.integrator.sample_clamp_indirect :
291 float limit = (bounce > 0) ?
kernel_data.integrator.sample_clamp_indirect :
296 float clamp_factor = limit /
sum;
298 *throughput *= clamp_factor;
310 #ifdef __SHADOW_TRICKS__
316 float3 contribution = throughput * value;
317 #ifdef __CLAMP_SAMPLE__
318 path_radiance_clamp(
kg, &contribution,
state->bounce - 1);
322 if (
L->use_light_pass) {
323 if (
state->bounce == 0)
324 L->emission += contribution;
325 else if (
state->bounce == 1)
326 L->direct_emission += contribution;
328 L->indirect += contribution;
333 L->emission += contribution;
347 if (
L->use_light_pass &&
state->bounce == 0) {
348 L->ao +=
alpha * throughput * ao;
352 #ifdef __SHADOW_TRICKS__
355 float3 light = throughput * bsdf;
356 L->path_total += light;
357 L->path_total_shaded += ao * light;
365 float3 contribution = throughput * bsdf * ao;
368 if (
L->use_light_pass) {
369 if (
state->bounce == 0) {
371 L->direct_diffuse += contribution;
375 L->indirect += contribution;
381 L->emission += contribution;
390 #ifdef __SHADOW_TRICKS__
392 L->path_total += throughput * bsdf;
411 #ifdef __SHADOW_TRICKS__
414 L->path_total += light;
415 L->path_total_shaded += shadow * light;
423 float3 shaded_throughput = throughput * shadow;
426 if (
L->use_light_pass) {
430 # ifdef __CLAMP_SAMPLE__
431 path_radiance_clamp_throughput(
kg, &full_contribution, &shaded_throughput,
state->bounce);
434 if (
state->bounce == 0) {
436 L->direct_diffuse += shaded_throughput *
bsdf_eval->diffuse;
437 L->direct_glossy += shaded_throughput *
bsdf_eval->glossy;
438 L->direct_transmission += shaded_throughput *
bsdf_eval->transmission;
439 L->direct_volume += shaded_throughput *
bsdf_eval->volume;
442 L->shadow += shadow * shadow_fac;
447 L->indirect += full_contribution;
454 path_radiance_clamp(
kg, &contribution,
state->bounce);
455 L->emission += contribution;
464 #ifdef __SHADOW_TRICKS__
466 L->path_total += throughput *
bsdf_eval->sum_no_mis;
483 #ifdef __SHADOW_TRICKS__
485 L->path_total += throughput * value;
486 L->path_total_shaded += throughput * value *
L->shadow_transparency;
494 float3 contribution = throughput * value;
495 #ifdef __CLAMP_SAMPLE__
496 path_radiance_clamp(
kg, &contribution,
state->bounce - 1);
500 if (
L->use_light_pass) {
502 L->background += contribution;
503 else if (
state->bounce == 1)
504 L->direct_emission += contribution;
506 L->indirect += contribution;
511 L->emission += contribution;
514 #ifdef __DENOISING_FEATURES__
515 L->denoising_albedo +=
state->denoising_feature_weight *
state->denoising_feature_throughput *
524 L->transparent +=
average(throughput);
527 #ifdef __SHADOW_TRICKS__
532 L->shadow_throughput +=
average(throughput);
533 L->shadow_background_color += throughput * background;
534 L->has_shadow_catcher = 1;
544 if (
L->use_light_pass) {
546 L->direct_diffuse +=
L->state.diffuse *
L->direct_emission;
547 L->direct_glossy +=
L->state.glossy *
L->direct_emission;
548 L->direct_transmission +=
L->state.transmission *
L->direct_emission;
549 L->direct_volume +=
L->state.volume *
L->direct_emission;
552 L->indirect_diffuse +=
L->state.diffuse *
L->indirect;
553 L->indirect_glossy +=
L->state.glossy *
L->indirect;
554 L->indirect_transmission +=
L->state.transmission *
L->indirect;
555 L->indirect_volume +=
L->state.volume *
L->indirect;
563 if (
L->use_light_pass) {
578 if (
L->use_light_pass) {
587 #ifdef __SHADOW_TRICKS__
594 float path_total =
average(
L->path_total);
601 else if (path_total == 0.0f) {
602 shadow =
L->shadow_transparency;
605 float path_total_shaded =
average(
L->path_total_shaded);
606 shadow = path_total_shaded / path_total;
611 *
alpha -=
L->shadow_throughput * shadow;
614 L->shadow_background_color *= shadow;
615 *L_sum +=
L->shadow_background_color;
627 float3 L_direct, L_indirect;
628 if (
L->use_light_pass) {
631 L_direct =
L->direct_diffuse +
L->direct_glossy +
L->direct_transmission +
L->direct_volume +
633 L_indirect =
L->indirect_diffuse +
L->indirect_glossy +
L->indirect_transmission +
637 L_direct +=
L->background;
639 L_sum = L_direct + L_indirect;
644 kernel_assert(!
"Non-finite sum in path_radiance_clamp_and_sum!");
670 kernel_assert(!
"Non-finite final sum in path_radiance_clamp_and_sum!");
676 *
alpha = 1.0f -
L->transparent;
679 #ifdef __SHADOW_TRICKS__
680 if (
L->has_shadow_catcher) {
681 path_radiance_sum_shadowcatcher(
kg,
L, &L_sum,
alpha);
696 *clean =
L->emission +
L->background;
697 *noisy =
L->direct_volume +
L->indirect_volume;
699 # define ADD_COMPONENT(flag, component) \
700 if (kernel_data.film.denoising_flags & flag) \
701 *clean += component; \
711 # undef ADD_COMPONENT
713 *noisy =
L->emission;
717 #ifdef __SHADOW_TRICKS__
718 if (
L->has_shadow_catcher) {
719 *noisy +=
L->shadow_background_color;
729 #ifdef __SPLIT_KERNEL__
730 # define safe_float3_add(f, v) \
732 ccl_global float *p = (ccl_global float *)(&(f)); \
733 atomic_add_and_fetch_float(p + 0, (v).x); \
734 atomic_add_and_fetch_float(p + 1, (v).y); \
735 atomic_add_and_fetch_float(p + 2, (v).z); \
737 # define safe_float_add(f, v) atomic_add_and_fetch_float(&(f), (v))
739 # define safe_float3_add(f, v) (f) += (v)
740 # define safe_float_add(f, v) (f) += (v)
761 #undef safe_float_add
762 #undef safe_float3_add
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble z
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum type
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
ccl_device float3 bsdf_eval(KernelGlobals *kg, ShaderData *sd, const ShaderClosure *sc, const float3 omega_in, float *pdf)
static T sum(const btAlignedObjectArray< T > &items)
static CCL_NAMESPACE_BEGIN const double alpha
ccl_device_inline bool bsdf_eval_is_zero(BsdfEval *eval)
ccl_device_inline void path_radiance_accum_total_light(PathRadiance *L, ccl_addr_space PathState *state, float3 throughput, const BsdfEval *bsdf_eval)
ccl_device_inline void bsdf_eval_init(BsdfEval *eval, ClosureType type, float3 value, int use_light_pass)
#define safe_float_add(f, v)
ccl_device_inline void path_radiance_sum_indirect(PathRadiance *L)
ccl_device_inline void path_radiance_accum_light(KernelGlobals *kg, PathRadiance *L, ccl_addr_space PathState *state, float3 throughput, BsdfEval *bsdf_eval, float3 shadow, float shadow_fac, bool is_lamp)
CCL_NAMESPACE_BEGIN ccl_device float3 shader_bsdf_transparency(KernelGlobals *kg, const ShaderData *sd)
ccl_device_inline void path_radiance_accum_sample(PathRadiance *L, PathRadiance *L_sample)
ccl_device_inline void path_radiance_init(KernelGlobals *kg, PathRadiance *L)
ccl_device_inline void path_radiance_accum_transparent(PathRadiance *L, ccl_addr_space PathState *state, float3 throughput)
ccl_device_inline float3 bsdf_eval_sum(const BsdfEval *eval)
ccl_device_inline void bsdf_eval_mis(BsdfEval *eval, float value)
ccl_device_inline void path_radiance_reset_indirect(PathRadiance *L)
ccl_device_inline void bsdf_eval_accum(BsdfEval *eval, ClosureType type, float3 value, float mis_weight)
ccl_device_inline void path_radiance_accum_ao(KernelGlobals *kg, PathRadiance *L, ccl_addr_space PathState *state, float3 throughput, float3 alpha, float3 bsdf, float3 ao)
ccl_device_inline void path_radiance_copy_indirect(PathRadiance *L, const PathRadiance *L_src)
ccl_device_inline void bsdf_eval_mul(BsdfEval *eval, float value)
ccl_device_inline void path_radiance_accum_background(KernelGlobals *kg, PathRadiance *L, ccl_addr_space PathState *state, float3 throughput, float3 value)
ccl_device_inline void path_radiance_accum_emission(KernelGlobals *kg, PathRadiance *L, ccl_addr_space PathState *state, float3 throughput, float3 value)
ccl_device_inline void path_radiance_split_denoising(KernelGlobals *kg, PathRadiance *L, float3 *noisy, float3 *clean)
ccl_device_inline void path_radiance_accum_total_ao(PathRadiance *L, ccl_addr_space PathState *state, float3 throughput, float3 bsdf)
ccl_device_inline void bsdf_eval_mul3(BsdfEval *eval, float3 value)
ccl_device_inline void path_radiance_bsdf_bounce(KernelGlobals *kg, PathRadianceState *L_state, ccl_addr_space float3 *throughput, BsdfEval *bsdf_eval, float bsdf_pdf, int bounce, int bsdf_label)
#define safe_float3_add(f, v)
ccl_device_inline float3 path_radiance_clamp_and_sum(KernelGlobals *kg, PathRadiance *L, float *alpha)
#define kernel_assert(cond)
#define ccl_device_forceinline
#define ccl_device_inline
#define CCL_NAMESPACE_END
@ PATH_RAY_STORE_SHADOW_INFO
@ PATH_RAY_SHADOW_CATCHER
@ PATH_RAY_TRANSPARENT_BACKGROUND
@ DENOISING_CLEAN_GLOSSY_IND
@ DENOISING_CLEAN_DIFFUSE_DIR
@ DENOISING_CLEAN_TRANSMISSION_IND
@ DENOISING_CLEAN_DIFFUSE_IND
@ DENOISING_CLEAN_TRANSMISSION_DIR
@ DENOISING_CLEAN_GLOSSY_DIR
struct PathRadianceState state
float3 indirect_transmission
float3 direct_transmission
#define CLOSURE_IS_BSDF_TRANSMISSION(type)
#define CLOSURE_IS_BSDF_GLOSSY(type)
#define CLOSURE_IS_BSDF_BSSRDF(type)
#define CLOSURE_IS_BSDF_DIFFUSE(type)
@ CLOSURE_BSDF_TRANSPARENT_ID
#define CLOSURE_IS_PHASE(type)
__forceinline int reduce_add(const avxi &v)
ccl_device_inline float3 safe_divide_color(float3 a, float3 b)
ccl_device_inline bool isfinite_safe(float f)
ccl_device_inline bool is_zero(const float2 &a)
ccl_device_inline float average(const float2 &a)
ccl_device_inline float2 fabs(const float2 &a)
ccl_device_inline float3 zero_float3()
ccl_device_inline float3 ensure_finite3(float3 v)