Blender V5.3
light_passes.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "kernel/film/write.h"
8
10
12#include "util/atomic.h"
13
15
16/* --------------------------------------------------------------------
17 * BSDF Evaluation
18 *
19 * BSDF evaluation result, split between diffuse and glossy. This is used to
20 * accumulate render passes separately. Note that reflection, transmission
21 * and volume scattering are written to different render passes, but we assume
22 * that only one of those can happen at a bounce, and so do not need to accumulate
23 * them separately. */
24
26 const ccl_private ShaderClosure *sc,
27 const float3 wo,
28 Spectrum value)
29{
30 eval->diffuse = zero_spectrum();
31 eval->glossy = zero_spectrum();
32
33 if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
34 eval->diffuse = value;
35 }
36 else if (CLOSURE_IS_BSDF_GLOSSY(sc->type)) {
37 eval->glossy = value;
38 }
39 else if (CLOSURE_IS_GLASS(sc->type)) {
40 /* Glass can count as glossy or transmission, depending on which side we end up on. */
41 if (dot(sc->N, wo) > 0.0f) {
42 eval->glossy = value;
43 }
44 }
45
46 eval->sum = value;
47}
48
50{
51 eval->diffuse = zero_spectrum();
52 eval->glossy = zero_spectrum();
53 eval->sum = value;
54}
55
57 const ccl_private ShaderClosure *sc,
58 const float3 wo,
59 Spectrum value)
60{
61 if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
62 eval->diffuse += value;
63 }
64 else if (CLOSURE_IS_BSDF_GLOSSY(sc->type)) {
65 eval->glossy += value;
66 }
67 else if (CLOSURE_IS_GLASS(sc->type)) {
68 if (dot(sc->N, wo) > 0.0f) {
69 eval->glossy += value;
70 }
71 }
72
73 eval->sum += value;
74}
75
77{
78 eval->sum += value;
79}
80
82{
83 return is_zero(eval->sum);
84}
85
87{
88 eval->diffuse *= value;
89 eval->glossy *= value;
90 eval->sum *= value;
91}
92
94{
95 eval->diffuse *= value;
96 eval->glossy *= value;
97 eval->sum *= value;
98}
99
101{
102 return eval->sum;
103}
104
106{
107 /* Ratio of diffuse weight to recover proportions for writing to render pass.
108 * We assume reflection, transmission and volume scatter to be exclusive. */
109 return safe_divide(eval->diffuse, eval->sum);
110}
111
113{
114 /* Ratio of glossy weight to recover proportions for writing to render pass.
115 * We assume reflection, transmission and volume scatter to be exclusive. */
116 return safe_divide(eval->glossy, eval->sum);
117}
118
119/* --------------------------------------------------------------------
120 * Clamping
121 *
122 * Clamping is done on a per-contribution basis so that we can write directly
123 * to render buffers instead of using per-thread memory, and to avoid the
124 * impact of clamping on other contributions. */
125
128 const int bounce)
129{
130#ifdef __KERNEL_DEBUG_NAN__
131 if (!isfinite_safe(*L)) {
132 kernel_assert(!"Cycles sample with non-finite value detected");
133 }
134#endif
135 /* Make sure all components are finite, allowing the contribution to be usable by adaptive
136 * sampling convergence check, but also to make it so render result never causes issues with
137 * post-processing. */
138 *L = ensure_finite(*L);
139
140#ifdef __CLAMP_SAMPLE__
141 const float limit = (bounce > 0) ? kernel_data.integrator.sample_clamp_indirect :
142 kernel_data.integrator.sample_clamp_direct;
143 const float sum = reduce_add(fabs(*L));
144 if (sum > limit) {
145 *L *= limit / sum;
146 }
147#endif
148}
149
150/* --------------------------------------------------------------------
151 * Pass accumulation utilities.
152 */
153
154/* --------------------------------------------------------------------
155 * Adaptive sampling.
156 */
157
161 const int sample,
162 const int sample_offset)
163{
164 if (kernel_data.film.pass_sample_count == PASS_UNUSED) {
165 return sample;
166 }
167
169
171 (ccl_global uint *)(buffer) + kernel_data.film.pass_sample_count, 1) +
172 sample_offset;
173}
174
176 const int sample,
177 const Spectrum contribution,
178 ccl_global float *ccl_restrict buffer)
179{
180 /* Adaptive Sampling. Fill the additional buffer with only one half of the samples and
181 * calculate our stopping criteria. This is the heuristic from "A hierarchical automatic
182 * stopping condition for Monte Carlo global illumination" except that here it is applied
183 * per pixel and not in hierarchical tiles. */
184
185 if (kernel_data.film.pass_adaptive_aux_buffer == PASS_UNUSED) {
186 return;
187 }
188
189 if (sample_is_class_A(kernel_data.integrator.sampling_pattern, sample)) {
190 const float3 contribution_rgb = spectrum_to_rgb(contribution);
191
192 film_write_pass_float4(buffer + kernel_data.film.pass_adaptive_aux_buffer,
193 make_float4(contribution_rgb.x * 2.0f,
194 contribution_rgb.y * 2.0f,
195 contribution_rgb.z * 2.0f,
196 0.0f));
197 }
198}
199
200/* Write the volume and surface contribution for volume scattering probability guiding. */
202 KernelGlobals kg,
203 ccl_global float *ccl_restrict buffer,
204 const PathRayVisibility path_visibility,
205 const uint32_t path_flag,
206 const Spectrum contribution)
207{
208 int pass_offset = PASS_UNUSED;
209 if (path_flag & PATH_RAY_VOLUME_PRIMARY_TRANSMIT) {
210 pass_offset = kernel_data.film.pass_volume_transmit;
211 }
212 else if (path_visibility & PATH_RAY_VISIBILITY_VOLUME_SCATTER) {
213 pass_offset = kernel_data.film.pass_volume_scatter;
214 }
215
216 if (pass_offset != PASS_UNUSED) {
217 film_write_pass_spectrum(buffer + pass_offset, contribution);
218 }
219}
220
221/* --------------------------------------------------------------------
222 * Shadow catcher.
223 */
224
225#ifdef __SHADOW_CATCHER__
226
227/* Accumulate contribution to the Shadow Catcher pass.
228 *
229 * Returns truth if the contribution is fully handled here and is not to be added to the other
230 * passes (like combined, adaptive sampling). */
231
232ccl_device bool film_write_shadow_catcher(KernelGlobals kg,
233 const uint32_t path_flag,
234 const Spectrum contribution,
235 ccl_global float *ccl_restrict buffer)
236{
237 if (!kernel_data.integrator.has_shadow_catcher) {
238 return false;
239 }
240
241 kernel_assert(kernel_data.film.pass_shadow_catcher != PASS_UNUSED);
242 kernel_assert(kernel_data.film.pass_shadow_catcher_matte != PASS_UNUSED);
243
244 /* Matte pass. */
245 if (kernel_shadow_catcher_is_matte_path(path_flag)) {
246 film_write_pass_spectrum(buffer + kernel_data.film.pass_shadow_catcher_matte, contribution);
247 /* NOTE: Accumulate the combined pass and to the samples count pass, so that the adaptive
248 * sampling is based on how noisy the combined pass is as if there were no catchers in the
249 * scene. */
250 }
251
252 /* Shadow catcher pass. */
253 if (kernel_shadow_catcher_is_object_pass(path_flag)) {
254 film_write_pass_spectrum(buffer + kernel_data.film.pass_shadow_catcher, contribution);
255 return true;
256 }
257
258 return false;
259}
260
261ccl_device bool film_write_shadow_catcher_transparent(KernelGlobals kg,
262 const uint32_t path_flag,
263 const Spectrum contribution,
264 const float transparent,
265 ccl_global float *ccl_restrict buffer)
266{
267 if (!kernel_data.integrator.has_shadow_catcher) {
268 return false;
269 }
270
271 kernel_assert(kernel_data.film.pass_shadow_catcher != PASS_UNUSED);
272 kernel_assert(kernel_data.film.pass_shadow_catcher_matte != PASS_UNUSED);
273
274 if (path_flag & PATH_RAY_SHADOW_CATCHER_BACKGROUND) {
275 return true;
276 }
277
278 /* Matte pass. */
279 if (kernel_shadow_catcher_is_matte_path(path_flag)) {
280 const float3 contribution_rgb = spectrum_to_rgb(contribution);
281
282 film_write_pass_float4(buffer + kernel_data.film.pass_shadow_catcher_matte,
283 make_float4(contribution_rgb, transparent));
284 /* NOTE: Accumulate the combined pass and to the samples count pass, so that the adaptive
285 * sampling is based on how noisy the combined pass is as if there were no catchers in the
286 * scene. */
287 }
288
289 /* Shadow catcher pass. */
290 if (kernel_shadow_catcher_is_object_pass(path_flag)) {
291 /* NOTE: The transparency of the shadow catcher pass is ignored. It is not needed for the
292 * calculation and the alpha channel of the pass contains numbers of samples contributed to a
293 * pixel of the pass. */
294 film_write_pass_spectrum(buffer + kernel_data.film.pass_shadow_catcher, contribution);
295 return true;
296 }
297
298 return false;
299}
300
301ccl_device void film_write_shadow_catcher_transparent_only(KernelGlobals kg,
302 const uint32_t path_flag,
303 const float transparent,
304 ccl_global float *ccl_restrict buffer)
305{
306 if (!kernel_data.integrator.has_shadow_catcher) {
307 return;
308 }
309
310 kernel_assert(kernel_data.film.pass_shadow_catcher_matte != PASS_UNUSED);
311
312 /* Matte pass. */
313 if (kernel_shadow_catcher_is_matte_path(path_flag)) {
314 film_write_pass_float(buffer + kernel_data.film.pass_shadow_catcher_matte + 3, transparent);
315 }
316}
317
318/* Write shadow catcher passes on a bounce from the shadow catcher object. */
319ccl_device_forceinline void film_write_shadow_catcher_bounce_data(
321{
322 kernel_assert(kernel_data.film.pass_shadow_catcher_sample_count != PASS_UNUSED);
323 kernel_assert(kernel_data.film.pass_shadow_catcher_matte != PASS_UNUSED);
324
326
327 /* Count sample for the shadow catcher object. */
328 film_write_pass_float(buffer + kernel_data.film.pass_shadow_catcher_sample_count, 1.0f);
329
330 /* Since the split is done, the sample does not contribute to the matte, so accumulate it as
331 * transparency to the matte. */
332 const Spectrum throughput = INTEGRATOR_STATE(state, path, throughput);
333 film_write_pass_float(buffer + kernel_data.film.pass_shadow_catcher_matte + 3,
334 average(throughput));
335}
336
337#endif /* __SHADOW_CATCHER__ */
338
339/* --------------------------------------------------------------------
340 * Render passes.
341 */
342
343/* Write combined pass. */
345 const PathRayVisibility path_visibility,
346 const uint32_t path_flag,
347 const int sample,
348 const Spectrum contribution,
349 ccl_global float *ccl_restrict buffer)
350{
351#ifdef __SHADOW_CATCHER__
352 if (film_write_shadow_catcher(kg, path_flag, contribution, buffer)) {
353 return;
354 }
355#endif
356
357 if (kernel_data.film.light_pass_flag & PASSMASK(COMBINED)) {
358 film_write_pass_spectrum(buffer + kernel_data.film.pass_combined, contribution);
359 }
360
361 film_write_adaptive_buffer(kg, sample, contribution, buffer);
362 film_write_volume_scattering_guiding_pass(kg, buffer, path_visibility, path_flag, contribution);
363}
364
365/* Write combined pass with transparency. */
367 KernelGlobals kg,
368 const PathRayVisibility path_visibility,
369 const uint32_t path_flag,
370 const int sample,
371 const Spectrum contribution,
372 const float transparent,
373 ccl_global float *ccl_restrict buffer)
374{
375#ifdef __SHADOW_CATCHER__
376 if (film_write_shadow_catcher_transparent(kg, path_flag, contribution, transparent, buffer)) {
377 return;
378 }
379#endif
380
381 if (kernel_data.film.light_pass_flag & PASSMASK(COMBINED)) {
382 const float3 contribution_rgb = spectrum_to_rgb(contribution);
383
384 film_write_pass_float4(buffer + kernel_data.film.pass_combined,
385 make_float4(contribution_rgb, transparent));
386 }
387
388 film_write_adaptive_buffer(kg, sample, contribution, buffer);
389 film_write_volume_scattering_guiding_pass(kg, buffer, path_visibility, path_flag, contribution);
390}
391
392/* Write background or emission to appropriate pass. */
394 KernelGlobals kg,
396 Spectrum contribution,
397 ccl_global float *ccl_restrict buffer,
398 const int pass,
399 const int lightgroup = LIGHTGROUP_NONE)
400{
401 if (!(kernel_data.film.light_pass_flag & PASS_ANY)) {
402 return;
403 }
404
405#ifdef __PASSES__
406 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
407 int pass_offset = PASS_UNUSED;
408
409 /* Denoising albedo. */
410# ifdef __DENOISING_FEATURES__
411 if (path_flag & PATH_RAY_DENOISING_FEATURES) {
412 if (kernel_data.film.pass_denoising_albedo != PASS_UNUSED) {
415 const Spectrum denoising_albedo = denoising_feature_throughput * contribution;
416 film_write_pass_spectrum(buffer + kernel_data.film.pass_denoising_albedo, denoising_albedo);
417 }
418 }
419# endif /* __DENOISING_FEATURES__ */
420
421 const bool is_shadowcatcher = (path_flag & PATH_RAY_SHADOW_CATCHER_HIT) != 0;
422 if (!is_shadowcatcher && lightgroup != LIGHTGROUP_NONE &&
423 kernel_data.film.pass_lightgroup != PASS_UNUSED)
424 {
425 film_write_pass_spectrum(buffer + kernel_data.film.pass_lightgroup + 3 * lightgroup,
426 contribution);
427 }
428
429 if (!(path_flag & PATH_RAY_ANY_PASS)) {
430 /* Directly visible, write to emission or background pass. */
431 pass_offset = pass;
432 }
433 else if (is_shadowcatcher) {
434 /* Don't write any light passes for shadow catcher, for easier
435 * compositing back together of the combined pass. */
436 return;
437 }
438 else if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
439 if (path_flag & PATH_RAY_SURFACE_PASS) {
440 /* Indirectly visible through reflection. */
441 const Spectrum diffuse_weight = INTEGRATOR_STATE(state, path, pass_diffuse_weight);
442 const Spectrum glossy_weight = INTEGRATOR_STATE(state, path, pass_glossy_weight);
443
444 /* Glossy */
445 const int glossy_pass_offset = ((INTEGRATOR_STATE(state, path, bounce) == 1) ?
446 kernel_data.film.pass_glossy_direct :
447 kernel_data.film.pass_glossy_indirect);
448 if (glossy_pass_offset != PASS_UNUSED) {
449 film_write_pass_spectrum(buffer + glossy_pass_offset, glossy_weight * contribution);
450 }
451
452 /* Transmission */
453 const int transmission_pass_offset = ((INTEGRATOR_STATE(state, path, bounce) == 1) ?
454 kernel_data.film.pass_transmission_direct :
455 kernel_data.film.pass_transmission_indirect);
456
457 if (transmission_pass_offset != PASS_UNUSED) {
458 /* Transmission is what remains if not diffuse and glossy, not stored explicitly to save
459 * GPU memory. */
460 const Spectrum transmission_weight = one_spectrum() - diffuse_weight - glossy_weight;
461 film_write_pass_spectrum(buffer + transmission_pass_offset,
462 transmission_weight * contribution);
463 }
464
465 /* Reconstruct diffuse subset of throughput. */
466 pass_offset = (INTEGRATOR_STATE(state, path, bounce) == 1) ?
467 kernel_data.film.pass_diffuse_direct :
468 kernel_data.film.pass_diffuse_indirect;
469 if (pass_offset != PASS_UNUSED) {
470 contribution *= diffuse_weight;
471 }
472 }
473 else if (path_flag & PATH_RAY_VOLUME_PASS) {
474 /* Indirectly visible through volume. */
475 pass_offset = (INTEGRATOR_STATE(state, path, bounce) == 1) ?
476 kernel_data.film.pass_volume_direct :
477 kernel_data.film.pass_volume_indirect;
478 }
479 }
480
481 /* Single write call for GPU coherence. */
482 if (pass_offset != PASS_UNUSED) {
483 film_write_pass_spectrum(buffer + pass_offset, contribution);
484 }
485#endif /* __PASSES__ */
486}
487
488/* Write light contribution to render buffer. */
492{
493 /* The throughput for shadow paths already contains the light shader evaluation. */
494 Spectrum contribution = INTEGRATOR_STATE(state, shadow_path, throughput);
495 film_clamp_light(kg, &contribution, INTEGRATOR_STATE(state, shadow_path, bounce));
496
498
499 const PathRayVisibility path_visibility = INTEGRATOR_STATE(state, shadow_path, visibility);
500 const uint32_t path_flag = INTEGRATOR_STATE(state, shadow_path, flag);
501 const int sample = INTEGRATOR_STATE(state, shadow_path, sample);
502
503 /* Ambient occlusion. */
504 if (path_flag & PATH_RAY_SHADOW_FOR_AO) {
505 if ((kernel_data.kernel_features & KERNEL_FEATURE_AO_PASS) &&
506 (path_visibility & PATH_RAY_VISIBILITY_CAMERA))
507 {
508 film_write_pass_spectrum(buffer + kernel_data.film.pass_ao, contribution);
509 }
510 if (kernel_data.kernel_features & KERNEL_FEATURE_AO_ADDITIVE) {
511 const Spectrum ao_weight = INTEGRATOR_STATE(state, shadow_path, unshadowed_throughput);
513 kg, path_visibility, path_flag, sample, contribution * ao_weight, buffer);
514 }
515 return;
516 }
517
518 /* Direct light shadow. */
519 film_write_combined_pass(kg, path_visibility, path_flag, sample, contribution, buffer);
520
521#ifdef __PASSES__
522 if (kernel_data.film.light_pass_flag & PASS_ANY) {
523 const uint32_t path_flag = INTEGRATOR_STATE(state, shadow_path, flag);
524
525 /* Don't write any light passes for shadow catcher, for easier
526 * compositing back together of the combined pass. */
527 if (path_flag & PATH_RAY_SHADOW_CATCHER_HIT) {
528 return;
529 }
530
531 /* Write lightgroup pass. LIGHTGROUP_NONE is ~0 so decode from unsigned to signed */
532 const int lightgroup = (int)(INTEGRATOR_STATE(state, shadow_path, lightgroup)) - 1;
533 if (lightgroup != LIGHTGROUP_NONE && kernel_data.film.pass_lightgroup != PASS_UNUSED) {
534 film_write_pass_spectrum(buffer + kernel_data.film.pass_lightgroup + 3 * lightgroup,
535 contribution);
536 }
537
538 if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
539 int pass_offset = PASS_UNUSED;
540
541 if (path_flag & PATH_RAY_SURFACE_PASS) {
542 /* Indirectly visible through reflection. */
543 const Spectrum diffuse_weight = INTEGRATOR_STATE(state, shadow_path, pass_diffuse_weight);
544 const Spectrum glossy_weight = INTEGRATOR_STATE(state, shadow_path, pass_glossy_weight);
545
546 /* Glossy */
547 const int glossy_pass_offset = ((INTEGRATOR_STATE(state, shadow_path, bounce) == 0) ?
548 kernel_data.film.pass_glossy_direct :
549 kernel_data.film.pass_glossy_indirect);
550 if (glossy_pass_offset != PASS_UNUSED) {
551 film_write_pass_spectrum(buffer + glossy_pass_offset, glossy_weight * contribution);
552 }
553
554 /* Transmission */
555 const int transmission_pass_offset = ((INTEGRATOR_STATE(state, shadow_path, bounce) == 0) ?
556 kernel_data.film.pass_transmission_direct :
557 kernel_data.film.pass_transmission_indirect);
558
559 if (transmission_pass_offset != PASS_UNUSED) {
560 /* Transmission is what remains if not diffuse and glossy, not stored explicitly to save
561 * GPU memory. */
562 const Spectrum transmission_weight = one_spectrum() - diffuse_weight - glossy_weight;
563 film_write_pass_spectrum(buffer + transmission_pass_offset,
564 transmission_weight * contribution);
565 }
566
567 /* Reconstruct diffuse subset of throughput. */
568 pass_offset = (INTEGRATOR_STATE(state, shadow_path, bounce) == 0) ?
569 kernel_data.film.pass_diffuse_direct :
570 kernel_data.film.pass_diffuse_indirect;
571 if (pass_offset != PASS_UNUSED) {
572 contribution *= diffuse_weight;
573 }
574 }
575 else if (path_flag & PATH_RAY_VOLUME_PASS) {
576 /* Indirectly visible through volume. */
577 pass_offset = (INTEGRATOR_STATE(state, shadow_path, bounce) == 0) ?
578 kernel_data.film.pass_volume_direct :
579 kernel_data.film.pass_volume_indirect;
580 }
581
582 /* Single write call for GPU coherence. */
583 if (pass_offset != PASS_UNUSED) {
584 film_write_pass_spectrum(buffer + pass_offset, contribution);
585 }
586 }
587 }
588#endif
589}
590
591/* Write transparency to render buffer.
592 *
593 * Note that we accumulate transparency = 1 - alpha in the render buffer.
594 * Otherwise we'd have to write alpha on path termination, which happens
595 * in many places. */
597 const uint32_t path_flag,
598 const float transparent,
599 ccl_global float *ccl_restrict buffer)
600{
601 if (kernel_data.film.light_pass_flag & PASSMASK(COMBINED)) {
602 film_write_pass_float(buffer + kernel_data.film.pass_combined + 3, transparent);
603 }
604
605#ifdef __SHADOW_CATCHER__
606 film_write_shadow_catcher_transparent_only(kg, path_flag, transparent, buffer);
607#endif
608
609 if (path_flag & PATH_RAY_VOLUME_PRIMARY_TRANSMIT) {
610 kernel_assert(kernel_data.film.pass_volume_transmit != PASS_UNUSED);
611 film_write_pass_spectrum(buffer + kernel_data.film.pass_volume_transmit,
612 make_spectrum(transparent));
613 }
614}
615
616/* Write holdout to render buffer. */
619 const uint32_t path_flag,
620 const float transparent,
622{
624 film_write_transparent(kg, path_flag, transparent, buffer);
625}
626
627/* Write background contribution to render buffer.
628 *
629 * Includes transparency, matching film_write_transparent. */
632 const Spectrum L,
633 const float transparent,
634 const bool is_transparent_background_ray,
636{
637 Spectrum contribution = INTEGRATOR_STATE(state, path, throughput) * L;
638 film_clamp_light(kg, &contribution, INTEGRATOR_STATE(state, path, bounce) - 1);
639
641 const PathRayVisibility path_visibility = INTEGRATOR_STATE(state, path, visibility);
642 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
643
644 if (is_transparent_background_ray) {
645 film_write_transparent(kg, path_flag, transparent, buffer);
646 }
647 else {
648 const int sample = INTEGRATOR_STATE(state, path, sample);
650 kg, path_visibility, path_flag, sample, contribution, transparent, buffer);
651 }
653 state,
654 contribution,
655 buffer,
656 kernel_data.film.pass_background,
657 kernel_data.background.lightgroup);
658}
659
660/* Write emission to render buffer. */
663 const Spectrum L,
665 const int lightgroup = LIGHTGROUP_NONE)
666{
667 Spectrum contribution = L;
668 film_clamp_light(kg, &contribution, INTEGRATOR_STATE(state, path, bounce) - 1);
669
671 const PathRayVisibility path_visibility = INTEGRATOR_STATE(state, path, visibility);
672 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
673 const int sample = INTEGRATOR_STATE(state, path, sample);
674
675 film_write_combined_pass(kg, path_visibility, path_flag, sample, contribution, buffer);
677 kg, state, contribution, buffer, kernel_data.film.pass_emission, lightgroup);
678}
679
682 const Spectrum L,
683 const float mis_weight,
685 const int lightgroup = LIGHTGROUP_NONE)
686{
687 Spectrum contribution = INTEGRATOR_STATE(state, path, throughput) * L * mis_weight;
688 film_clamp_light(kg, &contribution, INTEGRATOR_STATE(state, path, bounce) - 1);
689
691 const PathRayVisibility path_visibility = INTEGRATOR_STATE(state, path, visibility);
692 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
693 const int sample = INTEGRATOR_STATE(state, path, sample);
694
695 film_write_combined_pass(kg, path_visibility, path_flag, sample, contribution, buffer);
697 kg, state, contribution, buffer, kernel_data.film.pass_emission, lightgroup);
698}
699
ATOMIC_INLINE uint32_t atomic_fetch_and_add_uint32(uint32_t *p, uint32_t x)
#define kernel_assert(cond)
#define CLOSURE_IS_GLASS(type)
#define kernel_data
#define PASS_UNUSED
#define ccl_restrict
#define ccl_device_forceinline
#define one_spectrum
#define zero_spectrum
#define make_spectrum(f)
#define CLOSURE_IS_BSDF_GLOSSY(type)
#define ccl_private
#define ccl_device_inline
#define KERNEL_FEATURE_LIGHT_PASSES
#define KERNEL_FEATURE_AO_PASS
#define LIGHTGROUP_NONE
#define CLOSURE_IS_BSDF_DIFFUSE(type)
#define PASSMASK(pass)
#define ccl_global
#define PASS_ANY
#define KERNEL_FEATURE_AO_ADDITIVE
#define CCL_NAMESPACE_END
float dot(VecOp< float, D >, VecOp< float, D >) RET
bool is_zero(float3x3 a)
float safe_divide(float a, float b)
float reduce_add(float2 a)
float average(float2 a)
const int state
ccl_gpu_kernel_postfix ccl_global KernelWorkTile const int ccl_global float * render_buffer
uint32_t PathRayVisibility
@ PATH_RAY_SHADOW_FOR_AO
@ PATH_RAY_SHADOW_CATCHER_HIT
@ PATH_RAY_VOLUME_PASS
@ PATH_RAY_DENOISING_FEATURES
@ PATH_RAY_SURFACE_PASS
@ PATH_RAY_SHADOW_CATCHER_BACKGROUND
@ PATH_RAY_ANY_PASS
@ PATH_RAY_VOLUME_PRIMARY_TRANSMIT
@ PATH_RAY_VISIBILITY_VOLUME_SCATTER
@ PATH_RAY_VISIBILITY_CAMERA
ccl_device_inline float3 spectrum_to_rgb(Spectrum s)
ccl_device_inline void film_write_background(KernelGlobals kg, ConstIntegratorState state, const Spectrum L, const float transparent, const bool is_transparent_background_ray, ccl_global float *ccl_restrict render_buffer)
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_direct_light(KernelGlobals kg, ConstIntegratorShadowState state, ccl_global float *ccl_restrict render_buffer)
ccl_device void film_write_adaptive_buffer(KernelGlobals kg, const int sample, const Spectrum contribution, ccl_global float *ccl_restrict buffer)
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 void film_write_volume_emission(KernelGlobals kg, ConstIntegratorState state, const Spectrum L, ccl_global float *ccl_restrict render_buffer, const int lightgroup=LIGHTGROUP_NONE)
CCL_NAMESPACE_BEGIN ccl_device_inline void bsdf_eval_init(ccl_private BsdfEval *eval, const ccl_private ShaderClosure *sc, const float3 wo, Spectrum value)
ccl_device_inline Spectrum bsdf_eval_pass_glossy_weight(const ccl_private BsdfEval *eval)
ccl_device_inline void bsdf_eval_accum(ccl_private BsdfEval *eval, const ccl_private ShaderClosure *sc, const float3 wo, Spectrum value)
ccl_device_inline void bsdf_eval_mul(ccl_private BsdfEval *eval, const float value)
ccl_device_inline int film_write_sample(KernelGlobals kg, ConstIntegratorState state, ccl_global float *ccl_restrict render_buffer, const int sample, const int sample_offset)
ccl_device_inline Spectrum bsdf_eval_sum(const ccl_private BsdfEval *eval)
ccl_device_inline void film_write_combined_transparent_pass(KernelGlobals kg, const PathRayVisibility path_visibility, const uint32_t path_flag, const int sample, const Spectrum contribution, const float transparent, ccl_global float *ccl_restrict buffer)
ccl_device_inline void film_write_emission_or_background_pass(KernelGlobals kg, ConstIntegratorState state, Spectrum contribution, ccl_global float *ccl_restrict buffer, const int pass, const int lightgroup=LIGHTGROUP_NONE)
ccl_device_forceinline void film_clamp_light(KernelGlobals kg, ccl_private Spectrum *L, const int bounce)
ccl_device_inline void film_write_combined_pass(KernelGlobals kg, const PathRayVisibility path_visibility, const uint32_t path_flag, const int sample, const Spectrum contribution, ccl_global float *ccl_restrict buffer)
ccl_device_inline Spectrum bsdf_eval_pass_diffuse_weight(const ccl_private BsdfEval *eval)
ccl_device_inline void film_write_transparent(KernelGlobals kg, const uint32_t path_flag, const float transparent, ccl_global float *ccl_restrict buffer)
ccl_device_inline void film_write_volume_scattering_guiding_pass(KernelGlobals kg, ccl_global float *ccl_restrict buffer, const PathRayVisibility path_visibility, const uint32_t path_flag, const Spectrum contribution)
ccl_device_inline float ensure_finite(const float v)
Definition math_base.h:370
ccl_device_inline bool isfinite_safe(const float f)
Definition math_base.h:362
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
#define L
ccl_device_inline bool sample_is_class_A(const int pattern, const int sample)
Definition pattern.h:163
#define ccl_device
#define make_float4
pass_diffuse_weight
#define INTEGRATOR_STATE(state, nested_struct, member)
Definition state.h:234
const IntegratorShadowStateCPU * ConstIntegratorShadowState
Definition state.h:230
IntegratorStateCPU * IntegratorState
Definition state.h:227
const IntegratorStateCPU * ConstIntegratorState
Definition state.h:228
KERNEL_FEATURE_LIGHT_PASSES denoising_feature_throughput
float z
Definition sky_math.h:136
float y
Definition sky_math.h:136
float x
Definition sky_math.h:136
float3 Spectrum
ccl_device_inline void film_write_pass_float4(ccl_global float *ccl_restrict buffer, const float4 value)
Definition write.h:92
ccl_device_inline void film_write_pass_spectrum(ccl_global float *ccl_restrict buffer, Spectrum value)
Definition write.h:86
ccl_device_forceinline ccl_global float * film_pass_pixel_render_buffer_shadow(KernelGlobals kg, ConstIntegratorShadowState state, ccl_global float *ccl_restrict render_buffer)
Definition write.h:33
ccl_device_inline void film_write_pass_float(ccl_global float *ccl_restrict buffer, const float value)
Definition write.h:58
CCL_NAMESPACE_BEGIN ccl_device_forceinline ccl_global float * film_pass_pixel_render_buffer(KernelGlobals kg, ConstIntegratorState state, ccl_global float *ccl_restrict render_buffer)
Definition write.h:24