Blender V5.3
shade_surface.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
9
13
14#include "kernel/light/sample.h"
15
18
23
24#include "kernel/types.h"
25#include "util/math_intersect.h"
26
28
31 ccl_private ShaderData *sd)
32{
35
38
39 shader_setup_from_ray(kg, sd, &ray, &isect);
40
41#ifdef __SPECTRAL__
42 shader_setup_wavelength(kg, sd, state);
43#endif
44}
45
47 const ccl_private ShaderData *sd,
48 const float3 ray_P,
49 const float3 ray_D)
50{
51 /* No ray offset needed for other primitive types. */
52 if (!(sd->type & PRIMITIVE_TRIANGLE)) {
53 return ray_P;
54 }
55
56 /* Self intersection tests already account for the case where a ray hits the
57 * same primitive. However precision issues can still cause neighboring
58 * triangles to be hit. Here we test if the ray-triangle intersection with
59 * the same primitive would miss, implying that a neighboring triangle would
60 * be hit instead.
61 *
62 * This relies on triangle intersection to be watertight, and the object inverse
63 * object transform to match the one used by ray intersection exactly.
64 *
65 * Potential improvements:
66 * - It appears this happens when either barycentric coordinates are small,
67 * or dot(sd->Ng, ray_D) is small. Detect such cases and skip test?
68 * - Instead of ray offset, can we tweak P to lie within the triangle?
69 */
70
71 /* TODO: Investigate if there are better ray offsetting algorithms for each BVH.
72 * Cycles and Custom BVH triangle tests aren't numerically identical, meaning
73 * this method isn't ideal for them. */
74
75 float3 verts[3];
76 if (sd->type == PRIMITIVE_TRIANGLE) {
77 triangle_vertices(kg, sd->object, sd->prim, verts);
78 }
79 else {
81 motion_triangle_vertices(kg, sd->object, sd->prim, sd->time, verts);
82 }
83
84 float3 local_ray_P = ray_P;
85 float3 local_ray_D = ray_D;
86
87 if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
88 const Transform itfm = object_get_inverse_transform(kg, sd);
89 local_ray_P = transform_point(&itfm, local_ray_P);
90 local_ray_D = transform_direction(&itfm, local_ray_D);
91 }
92
93 if (ray_triangle_intersect_self(local_ray_P, local_ray_D, verts)) {
94 return ray_P;
95 }
96 return ray_offset(ray_P, sd->Ng);
97}
98
101 ccl_private ShaderData *sd,
103{
104 /* Write holdout transparency to render buffer and stop if fully holdout. */
105 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
106
107 if (((sd->runtime_flag & SR_HOLDOUT) || (sd->object_flag & SD_OBJECT_HOLDOUT_MASK)) &&
109 {
110 const Spectrum holdout_weight = surface_shader_apply_holdout(sd);
111 const Spectrum throughput = INTEGRATOR_STATE(state, path, throughput);
112 const float transparent = average(holdout_weight * throughput);
113 film_write_holdout(kg, state, path_flag, transparent, render_buffer);
114 if (isequal(holdout_weight, one_spectrum())) {
115 return false;
116 }
117 }
118
119 return true;
120}
121
124 const ccl_private ShaderData *sd,
127{
128 const PathRayVisibility path_visibility = INTEGRATOR_STATE(state, path, visibility);
129 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
130
131#ifdef __LIGHT_LINKING__
132 if (!(path_visibility & PATH_RAY_VISIBILITY_CAMERA) &&
134 {
135 return;
136 }
137#endif
138
139#ifdef __SHADOW_LINKING__
140 /* Indirect emission of shadow-linked emissive surfaces is done via shadow rays to dedicated
141 * light sources. */
142 if (kernel_data.kernel_features & KERNEL_FEATURE_SHADOW_LINKING) {
143 if (!(path_visibility & PATH_RAY_VISIBILITY_CAMERA) &&
144 kernel_data_fetch(objects, sd->object).shadow_set_membership != LIGHT_LINK_MASK_ALL)
145 {
146 return;
147 }
148 }
149#endif
150
151 /* Evaluate emissive closure. */
153
154 const float mis_weight = light_sample_mis_weight_forward_surface(
155 kg, state, path_visibility, path_flag, sd);
156
157 guiding_record_surface_emission(kg, state, L, mis_weight);
159 kg, state, L, mis_weight, render_buffer, object_lightgroup(kg, sd->object));
160}
161
164 ccl_private ShaderData *sd,
165 const ccl_private ShaderClosure *sc)
166{
168
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];
172
173 if (CLOSURE_IS_BSDF_OR_BSSRDF(sc->type)) {
174 sum_sample_weight += sc->sample_weight;
175 }
176 }
177 if (sum_sample_weight <= 0.0f) {
178 return LABEL_NONE;
179 }
180
181 if (len_squared(sd->P - pc->P) > 1e-9f) {
182 /* if the ray origin is changed, unset the current object,
183 * so we can potentially hit the same polygon again */
184 INTEGRATOR_STATE_WRITE(state, isect, object) = OBJECT_NONE;
185 INTEGRATOR_STATE_WRITE(state, ray, P) = pc->P;
186 }
187 else {
188 INTEGRATOR_STATE_WRITE(state, ray, P) = integrate_surface_ray_offset(kg, sd, pc->P, pc->D);
189 }
190 INTEGRATOR_STATE_WRITE(state, ray, D) = pc->D;
191 INTEGRATOR_STATE_WRITE(state, ray, tmin) = 0.0f;
193#ifdef __RAY_DIFFERENTIALS__
195#endif
196
197 const float pick_pdf = pc->sample_weight / sum_sample_weight;
198 INTEGRATOR_STATE_WRITE(state, path, throughput) *= pc->weight / pick_pdf;
199
200 const int label = LABEL_TRANSMIT | LABEL_RAY_PORTAL;
201 path_state_next(kg, state, label, sd->runtime_flag);
202
203 return label;
204}
205
206/* Branch off a shadow path and initialize common part of it.
207 * THe common is between the surface shading and configuration of a special shadow ray for the
208 * shadow linking. */
212 const ccl_private Ray *ccl_restrict ray,
213 const Spectrum bsdf_spectrum,
214 const int light_group,
215 const int mnee_vertex_count,
216 const bool constant_light_shader)
217{
218 const DeviceKernel next_kernel = (constant_light_shader) ?
221
222 /* Branch off shadow kernel. */
223 IntegratorShadowState shadow_state;
224#ifdef __MNEE__
225 if (mnee_vertex_count > 0) {
226 /* Reuse shadow path that was already allocated by intersect_mnee. */
227 shadow_state = integrator_state_get_mnee_shadow_state(state);
229 shadow_state, DEVICE_KERNEL_INTEGRATOR_SHADOW_PATH_MNEE_PENDING, next_kernel);
230 }
231 else
232#endif
233 {
234 shadow_state = integrator_shadow_path_init(kg, state, next_kernel, false);
235 }
236
237#ifdef __VOLUME__
238 /* Copy volume stack and enter/exit volume. */
239 integrator_state_copy_volume_stack_to_shadow(kg, shadow_state, state);
240#endif
241
242 /* Write shadow ray and associated state to global memory. */
243 integrator_state_write_shadow_ray(shadow_state, ray);
245
246 /* Copy state from main path to shadow path. */
247 const Spectrum unlit_throughput = INTEGRATOR_STATE(state, path, throughput);
248 const Spectrum throughput = unlit_throughput * bsdf_spectrum;
249
250 if (!(kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_TREE)) {
251 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, bsdf_eval_average) = average(bsdf_spectrum);
252 }
253
254 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, render_pixel_index) = INTEGRATOR_STATE(
255 state, path, render_pixel_index);
256 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, rng_offset) = INTEGRATOR_STATE(
257 state, path, rng_offset);
258 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, rng_pixel) = INTEGRATOR_STATE(
259 state, path, rng_pixel);
260 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, sample) = INTEGRATOR_STATE(
261 state, path, sample);
262
263 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, transparent_bounce) = INTEGRATOR_STATE(
264 state, path, transparent_bounce);
265 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, volume_bounds_bounce) = INTEGRATOR_STATE(
266 state, path, volume_bounds_bounce);
267 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, glossy_bounce) = INTEGRATOR_STATE(
268 state, path, glossy_bounce);
269 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = throughput;
270
271 if ((kernel_data.kernel_features & KERNEL_FEATURE_NODE_PORTAL)) {
272 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, portal_bounce) = INTEGRATOR_STATE(
273 state, path, portal_bounce);
274 }
275
276#ifdef __MNEE__
277 if (mnee_vertex_count > 0) {
278 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, transmission_bounce) =
279 INTEGRATOR_STATE(state, path, transmission_bounce) + mnee_vertex_count - 1;
280 INTEGRATOR_STATE_WRITE(shadow_state,
281 shadow_path,
282 diffuse_bounce) = INTEGRATOR_STATE(state, path, diffuse_bounce) + 1;
283 INTEGRATOR_STATE_WRITE(shadow_state,
284 shadow_path,
285 bounce) = INTEGRATOR_STATE(state, path, bounce) + mnee_vertex_count;
286 }
287 else
288#endif
289 {
290 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, transmission_bounce) = INTEGRATOR_STATE(
291 state, path, transmission_bounce);
292 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, diffuse_bounce) = INTEGRATOR_STATE(
293 state, path, diffuse_bounce);
294 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, bounce) = INTEGRATOR_STATE(
295 state, path, bounce);
296 }
297
298 /* Write Light-group, +1 as light-group is int but we need to encode into a uint8_t. */
299 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, lightgroup) = light_group + 1;
300
301#if defined(__PATH_GUIDING__)
302 if ((kernel_data.kernel_features & KERNEL_FEATURE_PATH_GUIDING)) {
303 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, unlit_throughput) = unlit_throughput;
304 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, path_segment) = INTEGRATOR_STATE(
305 state, guiding, path_segment);
306 INTEGRATOR_STATE(shadow_state, shadow_path, guiding_light_linking_mis_weight) = 0.0f;
307 }
308#endif
309
310 return shadow_state;
311}
312
313/* Path tracing: sample point on light and evaluate light shader, then
314 * queue shadow ray to be traced. */
315template<uint64_t node_feature_mask>
316#if defined(__KERNEL_HIP__)
317/* Inlining the function makes gfx1102 crash rendering principled_bsdf_bevel_emission_137420.blend
318 * using SDK 7.2.1. */
320#elif defined(__KERNEL_GPU__)
322#else
323/* MSVC has very long compilation time (x20) if we force inline this function */
325#endif
328 ccl_private ShaderData *sd,
329 const ccl_private RNGState *rng_state)
330{
331 /* Test if there is a light or BSDF that needs direct light. */
332 if (!(kernel_data.integrator.use_direct_light && (sd->runtime_flag & SR_BSDF_HAS_EVAL))) {
333 return SHADER_EVAL_EMPTY;
334 }
335
337 int mnee_vertex_count = 0; // NOLINT
338
339#ifdef __MNEE__
340 if ((kernel_data.kernel_features & KERNEL_FEATURE_MNEE) &&
342 {
343 /* MNEE already sampled a light and caustics casters. */
344 integrator_state_read_mnee(state, &ls, &mnee_vertex_count);
345 }
346 else
347#endif
348 {
349 /* Sample position on a light. */
350 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
351 const uint bounce = INTEGRATOR_STATE(state, path, bounce);
352 const float3 rand_light = path_state_rng_3D(kg, rng_state, PRNG_LIGHT);
353
355 rand_light,
356 sd->time,
357 sd->P,
358 sd->N,
360 sd->runtime_flag,
361 bounce,
362 path_flag,
363 &ls))
364 {
365 return SHADER_EVAL_EMPTY;
366 }
367 }
368
369 kernel_assert(ls.pdf != 0.0f);
370
371 const bool is_transmission = dot(ls.D, sd->N) < 0.0f;
372
373 if (ls.prim != PRIM_NONE && ls.prim == sd->prim && ls.object == sd->object) {
374 /* Skip self intersection if light direction lies in the same hemisphere as the geometric
375 * normal. */
376 if (dot(ls.D, is_transmission ? -sd->Ng : sd->Ng) > 0.0f) {
377 return SHADER_EVAL_EMPTY;
378 }
379 }
380
381#ifdef __MNEE__
382 /* On a caustic caster, a caustic light's contribution is delivered to receivers by
383 * MNEE and does not need to be computed again here. */
384 if (kernel_data.kernel_features & KERNEL_FEATURE_MNEE) {
385 if (mnee_vertex_count == 0 && is_transmission &&
386 (sd->object_flag & SD_OBJECT_CAUSTICS_CASTER) && ls.type != LIGHT_TRIANGLE &&
387 kernel_data_fetch(lights, ls.prim).use_caustics)
388 {
389 return SHADER_EVAL_EMPTY;
390 }
391 }
392#endif
393
394 /* Evaluate constant part of light shader, rest will optionally be done in another kernel. */
395 Spectrum light_shader_eval ccl_optional_struct_init;
396 const bool is_constant_light_shader = light_sample_shader_eval_nee_constant(
397 kg, ls.shader, ls.prim, ls.type != LIGHT_TRIANGLE, light_shader_eval);
398
399 /* Evaluate BSDF. */
401 float avg_roughness_squared = 0.0f;
402 const float bsdf_pdf = surface_shader_bsdf_eval(
403 kg, state, sd, ls.D, &bsdf_eval, ls.shader, avg_roughness_squared);
404
406
407#ifdef __MNEE__
408 if (mnee_vertex_count > 0) {
409 light_shader_eval *= integrator_state_read_mnee_throughput(state);
410 bsdf_eval_mul(&bsdf_eval, light_shader_eval);
411
413 return SHADER_EVAL_EMPTY;
414 }
415
416 integrator_state_read_mnee_ray(state, &ls, &ray);
417 }
418 else
419#endif /* __MNEE__ */
420 {
421 const float mis_weight = light_sample_mis_weight_nee(kg, ls.pdf, bsdf_pdf);
422 bsdf_eval_mul(&bsdf_eval, light_shader_eval * ls.eval_fac / ls.pdf * mis_weight);
423
424 /* Path termination for constant light shader. */
425 if (is_constant_light_shader && !(kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_TREE)) {
426 const float terminate = path_state_rng_light_termination(kg, rng_state);
427 if (light_sample_terminate(kg, &bsdf_eval, terminate)) {
428 return SHADER_EVAL_EMPTY;
429 }
430 }
431 /* For non-constant light shader, probabilistic termination happens in
432 * SHADE_LIGHT_NEE when the full contribution is known. */
433 else if (bsdf_eval_is_zero(&bsdf_eval)) {
434 return SHADER_EVAL_EMPTY;
435 }
436
437 /* Create shadow ray. */
438 light_sample_to_surface_shadow_ray(kg, sd, &ls, &ray);
439
440#ifdef __RAY_DIFFERENTIALS__
441 /* Widen ray differences, with same logic as forward sampling to ensure
442 * both MIS strategies converge to the same result. */
443 ray.dD = bsdf_widen_dD(kg, INTEGRATOR_STATE(state, ray, dD), avg_roughness_squared);
444#endif
445 }
446
447 if (ray.self.object != OBJECT_NONE) {
448 ray.P = integrate_surface_ray_offset(kg, sd, ray.P, ray.D);
449 }
450
451 /* Branch off shadow kernel. */
453 kg,
454 state,
455 &ray,
457 ls.group,
458 mnee_vertex_count,
459 is_constant_light_shader);
460
461 if (is_transmission) {
462#ifdef __VOLUME__
463 volume_stack_enter_exit<true>(kg, shadow_state, sd);
464#endif
465 }
466
467 uint32_t shadow_flag = INTEGRATOR_STATE(state, path, flag);
468
469 if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
471 PackedSpectrum pass_glossy_weight;
472
473 if (shadow_flag & PATH_RAY_ANY_PASS) {
474 /* Indirect bounce, use weights from earlier surface or volume bounce. */
476 pass_glossy_weight = INTEGRATOR_STATE(state, path, pass_glossy_weight);
477 }
478 else {
479 /* Direct light, use BSDFs at this bounce. */
480 shadow_flag |= PATH_RAY_SURFACE_PASS;
483 }
484
486 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, pass_glossy_weight) = pass_glossy_weight;
487 }
488
489 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, visibility) = INTEGRATOR_STATE(
490 state, path, visibility);
491 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, flag) = shadow_flag;
492
493 return SHADER_EVAL_OK;
494}
495
496/* Path tracing: bounce off or through surface with new direction. */
498 KernelGlobals kg,
500 ccl_private ShaderData *sd,
501 const ccl_private RNGState *rng_state)
502{
503 /* Sample BSDF or BSSRDF. */
504 if (!(sd->runtime_flag & (SR_BSDF | SR_BSSRDF))) {
505 return LABEL_NONE;
506 }
507
508 float3 rand_bsdf = path_state_rng_3D(kg, rng_state, PRNG_SURFACE_BSDF);
509 const ccl_private ShaderClosure *sc = surface_shader_bsdf_bssrdf_pick(sd, &rand_bsdf);
510
511#ifdef __SUBSURFACE__
512 /* BSSRDF closure, we schedule subsurface intersection kernel. */
513 if (CLOSURE_IS_BSSRDF(sc->type)) {
514 return subsurface_bounce(kg, state, sd, sc);
515 }
516#endif
517 if (CLOSURE_IS_RAY_PORTAL(sc->type)) {
518 return integrate_surface_ray_portal(kg, state, sd, sc);
519 }
520
521 /* BSDF closure, sample direction. */
522 float bsdf_pdf = 0.0f;
523 float unguided_bsdf_pdf = 0.0f;
526 int label;
527
528 float2 bsdf_sampled_roughness = make_float2(1.0f, 1.0f);
529 float bsdf_eta = 1.0f;
530 float mis_pdf = 1.0f;
531
532 float bsdf_avg_roughness_squared = 0.0f;
533
534#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
535 if (kernel_data.integrator.use_surface_guiding &&
536 (kernel_data.kernel_features & KERNEL_FEATURE_PATH_GUIDING))
537 {
538 label = surface_shader_bsdf_guided_sample_closure(kg,
539 state,
540 sd,
541 sc,
542 rand_bsdf,
543 &bsdf_eval,
544 &bsdf_wo,
545 &bsdf_pdf,
546 &mis_pdf,
547 &unguided_bsdf_pdf,
548 &bsdf_sampled_roughness,
549 &bsdf_eta,
550 rng_state,
551 bsdf_avg_roughness_squared);
552
553 if (bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval)) {
554 return LABEL_NONE;
555 }
556
557 INTEGRATOR_STATE_WRITE(state, path, unguided_throughput) *= bsdf_pdf / unguided_bsdf_pdf;
558 }
559 else
560#endif
561 {
563 sd,
564 sc,
565 rand_bsdf,
566 &bsdf_eval,
567 &bsdf_wo,
568 &bsdf_pdf,
569 &bsdf_sampled_roughness,
570 &bsdf_eta,
571 bsdf_avg_roughness_squared);
572
573 if (bsdf_pdf == 0.0f || bsdf_eval_is_zero(&bsdf_eval)) {
574 return LABEL_NONE;
575 }
576 mis_pdf = bsdf_pdf;
577 unguided_bsdf_pdf = bsdf_pdf;
578 }
579
580 if (label & LABEL_TRANSPARENT) {
581 /* Only need to modify start distance for transparent. */
582 INTEGRATOR_STATE_WRITE(state, ray, tmin) = intersection_t_offset(sd->ray_length);
583 }
584 else {
585 /* Setup ray with changed origin and direction. */
586 const float3 D = normalize(bsdf_wo);
589 INTEGRATOR_STATE_WRITE(state, ray, tmin) = 0.0f;
591#ifdef __RAY_DIFFERENTIALS__
593
594 /* Widen ray differences, with same logic as NEE sampling to ensure
595 * both MIS strategies converge to the same result. */
596 const float dD = bsdf_widen_dD(
597 kg, INTEGRATOR_STATE(state, ray, dD), bsdf_avg_roughness_squared);
598 INTEGRATOR_STATE_WRITE(state, ray, dD) = dD;
599#endif
600 }
601
602 /* Update throughput. */
603 const Spectrum bsdf_weight = bsdf_eval_sum(&bsdf_eval) / bsdf_pdf;
604 INTEGRATOR_STATE_WRITE(state, path, throughput) *= bsdf_weight;
605
606 if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_PASSES) {
607 if (INTEGRATOR_STATE(state, path, bounce) == 0) {
609 &bsdf_eval);
610 INTEGRATOR_STATE_WRITE(state, path, pass_glossy_weight) = bsdf_eval_pass_glossy_weight(
611 &bsdf_eval);
612 }
613 }
614
615 /* Update path state */
616 if (!(label & LABEL_TRANSPARENT)) {
617 const float min_ray_pdf = INTEGRATOR_STATE(state, path, min_ray_pdf);
618 INTEGRATOR_STATE_WRITE(state, path, mis_ray_pdf) = mis_pdf;
619 INTEGRATOR_STATE_WRITE(state, path, mis_origin_n) = sd->N;
620 INTEGRATOR_STATE_WRITE(state, path, min_ray_pdf) = fminf(unguided_bsdf_pdf, min_ray_pdf);
621
622#ifdef __LIGHT_LINKING__
623 if (kernel_data.kernel_features & KERNEL_FEATURE_LIGHT_LINKING) {
624 INTEGRATOR_STATE_WRITE(state, path, mis_ray_object) = sd->object;
625 }
626#endif
627 }
628
629 path_state_next(kg, state, label, sd->runtime_flag);
630
632 state,
633 bsdf_weight,
634 bsdf_pdf,
635 sd->N,
636 normalize(bsdf_wo),
637 bsdf_sampled_roughness,
638 bsdf_eta);
639
640 return label;
641}
642
643#ifdef __VOLUME__
644ccl_device_forceinline int integrate_surface_volume_only_bounce(IntegratorState state,
645 ccl_private ShaderData *sd)
646{
647 if (!path_state_volume_next(state)) {
648 return LABEL_NONE;
649 }
650
651 /* Only modify start distance. */
652 INTEGRATOR_STATE_WRITE(state, ray, tmin) = intersection_t_offset(sd->ray_length);
653
655}
656#endif
657
659 const uint32_t path_flag)
660{
661 const float continuation_probability = (path_flag & PATH_RAY_TERMINATE_ON_NEXT_SURFACE) ?
662 0.0f :
664 state, path, continuation_probability));
665 if (continuation_probability == 0.0f) {
666 return true;
667 }
668 if (continuation_probability != 1.0f) {
669 INTEGRATOR_STATE_WRITE(state, path, throughput) /= continuation_probability;
670 }
671
672 return false;
673}
674
675#if defined(__AO__)
676ccl_device_forceinline void integrate_surface_ao(KernelGlobals kg,
678 const ccl_private ShaderData *ccl_restrict sd,
680 rng_state)
681{
682 const PathRayVisibility path_visibility = INTEGRATOR_STATE(state, path, visibility);
683 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
684
685 if (!(kernel_data.kernel_features & KERNEL_FEATURE_AO_ADDITIVE) &&
686 !(path_visibility & PATH_RAY_VISIBILITY_CAMERA))
687 {
688 return;
689 }
690
691 /* Skip AO for paths that were split off for shadow catchers to avoid double-counting. */
692 if (path_flag & PATH_RAY_SHADOW_CATCHER_PASS) {
693 return;
694 }
695
696 const float2 rand_bsdf = path_state_rng_2D(kg, rng_state, PRNG_SURFACE_BSDF);
697
698 float3 ao_N;
699 const Spectrum ao_weight = surface_shader_ao(
700 sd, kernel_data.integrator.ao_additive_factor, &ao_N);
701
702 float3 ao_D;
703 float ao_pdf;
704 sample_cos_hemisphere(ao_N, rand_bsdf, &ao_D, &ao_pdf);
705
706 bool skip_self = true;
707
709 ray.P = shadow_ray_offset(kg, sd, ao_D, &skip_self);
710 ray.D = ao_D;
711 if (skip_self) {
712 ray.P = integrate_surface_ray_offset(kg, sd, ray.P, ray.D);
713 }
714 ray.tmin = 0.0f;
715 ray.tmax = kernel_data.integrator.ao_bounces_distance;
716 ray.time = sd->time;
717 ray.self.object = (skip_self) ? sd->object : OBJECT_NONE;
718 ray.self.prim = (skip_self) ? sd->prim : PRIM_NONE;
719 ray.self.light_object = OBJECT_NONE;
720 ray.self.light_prim = PRIM_NONE;
721 ray.dP = differential_zero_compact();
722 ray.dD = differential_zero_compact();
723
724 /* Branch off shadow kernel. */
727
728# ifdef __VOLUME__
729 /* Copy volume stack and enter/exit volume. */
730 integrator_state_copy_volume_stack_to_shadow(kg, shadow_state, state);
731# endif
732
733 /* Write shadow ray and associated state to global memory. */
734 integrator_state_write_shadow_ray(shadow_state, &ray);
735 integrator_state_write_shadow_ray_self(shadow_state, &ray);
736
737 /* Copy state from main path to shadow path. */
738 const uint16_t bounce = INTEGRATOR_STATE(state, path, bounce);
739 const uint16_t transparent_bounce = INTEGRATOR_STATE(state, path, transparent_bounce);
740 const uint32_t shadow_flag = INTEGRATOR_STATE(state, path, flag) | PATH_RAY_SHADOW_FOR_AO;
741 const Spectrum throughput = INTEGRATOR_STATE(state, path, throughput) * surface_shader_alpha(sd);
742
743 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, render_pixel_index) = INTEGRATOR_STATE(
744 state, path, render_pixel_index);
745 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, rng_offset) = INTEGRATOR_STATE(
746 state, path, rng_offset);
747 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, rng_pixel) = INTEGRATOR_STATE(
748 state, path, rng_pixel);
749 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, sample) = INTEGRATOR_STATE(
750 state, path, sample);
751 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, visibility) = INTEGRATOR_STATE(
752 state, path, visibility);
753 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, flag) = shadow_flag;
754 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, bounce) = bounce;
755 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, transparent_bounce) = transparent_bounce;
756 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, volume_bounds_bounce) = INTEGRATOR_STATE(
757 state, path, volume_bounds_bounce);
758 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, throughput) = throughput;
759
760 if (kernel_data.kernel_features & KERNEL_FEATURE_AO_ADDITIVE) {
761 INTEGRATOR_STATE_WRITE(shadow_state, shadow_path, unshadowed_throughput) = ao_weight;
762 }
763}
764#endif /* defined(__AO__) */
765
766template<uint64_t node_feature_mask>
770
771{
773
774 /* Setup shader data. */
775 ShaderData sd;
777 PROFILING_SHADER(sd.object, sd.shader);
778
779 int continue_path_label = 0;
780
781 const PathRayVisibility path_visibility = INTEGRATOR_STATE(state, path, visibility);
782 const uint32_t path_flag = INTEGRATOR_STATE(state, path, flag);
783
784 /* Skip most work for volume bounding surface. */
785#ifdef __VOLUME__
786 if (!(sd.shader_flag & SD_HAS_ONLY_VOLUME)) {
787#endif
788#ifdef __SUBSURFACE__
789 /* Can skip shader evaluation for BSSRDF exit point without bump mapping. */
790 if (!(path_flag & PATH_RAY_SUBSURFACE) || ((sd.shader_flag & SD_HAS_BSSRDF_BUMP)))
791#endif
792 {
793 /* Evaluate shader. */
796 kg, state, &sd, render_buffer, path_visibility, path_flag);
797 }
798
799 if (sd.runtime_flag & SR_CACHE_MISS) {
800 return LABEL_CACHE_MISS;
801 }
802
803#ifdef __SPECTRAL__
804 if (sd.runtime_flag & SR_BSDF_HAS_DISPERSION) {
805 update_path_throughput_for_dispersion(kg, state, sd.rand_wavelength);
806 }
807#endif
808
809 /* After shader evaluation, in case of texture cache miss. */
811
812#ifdef __SUBSURFACE__
813 if (path_flag & PATH_RAY_SUBSURFACE) {
814 /* When coming from inside subsurface scattering, setup a diffuse
815 * closure to perform lighting at the exit point. */
816 subsurface_shader_data_setup(kg, &sd);
818 }
819 else
820#endif
821 {
822 /* Filter closures. */
823 surface_shader_prepare_closures(kg, state, &sd, path_visibility);
824
825 /* Evaluate holdout. */
827 return LABEL_NONE;
828 }
829
830 /* Write emission. */
831 if (sd.runtime_flag & SR_EMISSION) {
833 }
834
835 /* Perform path termination. Most paths have already been terminated in
836 * the intersect_closest kernel, this is just for emission and for dividing
837 * throughput by the probability at the right moment.
838 *
839 * Also ensure we don't do it twice for SSS at both the entry and exit point. */
840 if (integrate_surface_terminate(state, path_flag)) {
841 return LABEL_NONE;
842 }
843
844 /* Write render passes. */
845#ifdef __PASSES__
847 film_write_data_passes(kg, state, path_flag, &sd, render_buffer);
848#endif
849
850#ifdef __DENOISING_FEATURES__
851 film_write_denoising_features_surface(kg, state, path_flag, &sd, render_buffer);
852#endif
853 }
854
855 /* Load random number state. */
856 RNGState rng_state;
857 path_state_rng_load(state, &rng_state);
858
859#if defined(__PATH_GUIDING__) && PATH_GUIDING_LEVEL >= 4
860 if (kernel_data.kernel_features & KERNEL_FEATURE_PATH_GUIDING) {
861 surface_shader_prepare_guiding(kg, state, &sd, &rng_state);
863 }
864#endif
865 /* Direct light. */
868 kg, state, &sd, &rng_state);
869 if (result == SHADER_EVAL_CACHE_MISS) {
870 return LABEL_CACHE_MISS;
871 }
872
873#if defined(__AO__)
874 /* Ambient occlusion pass. */
875 if (kernel_data.kernel_features & KERNEL_FEATURE_AO) {
877 integrate_surface_ao(kg, state, &sd, &rng_state);
878 }
879#endif
880
882 continue_path_label = integrate_surface_bsdf_bssrdf_bounce(kg, state, &sd, &rng_state);
883#ifdef __VOLUME__
884 }
885 else {
886 if (integrate_surface_terminate(state, path_flag)) {
887 return LABEL_NONE;
888 }
889
890# ifdef __DENOISING_FEATURES__
891 film_write_denoising_features_surface_volume(kg, state, &sd, render_buffer);
892# endif
893
895 continue_path_label = integrate_surface_volume_only_bounce(state, &sd);
896 }
897
898 if (continue_path_label & LABEL_TRANSMIT) {
899 /* Enter/Exit volume. */
900 volume_stack_enter_exit<false>(kg, state, &sd);
901 }
902#endif
903
904 return continue_path_label;
905}
906
907template<DeviceKernel current_kernel>
918
919template<uint64_t node_feature_mask = KERNEL_FEATURE_NODE_MASK_SURFACE &
925{
926 const int continue_path_label = integrate_surface<node_feature_mask>(kg, state, render_buffer);
927 if (continue_path_label == LABEL_CACHE_MISS) {
929 return;
930 }
931
932#ifdef __MNEE__
933 /* Cleanup MNEE flag and shadow path if it was not reused for shadow trace. */
934 if ((kernel_data.kernel_features & KERNEL_FEATURE_MNEE) &&
936 {
938
939 const IntegratorShadowState shadow_state = integrator_state_get_mnee_shadow_state(state);
940 if (INTEGRATOR_STATE(shadow_state, shadow_path, queued_kernel) ==
942 {
945 }
946 }
947#endif
948
949 if (continue_path_label == LABEL_NONE) {
950 integrator_path_terminate(kg, state, render_buffer, current_kernel);
951 return;
952 }
953
954#ifdef __SHADOW_LINKING__
955 /* No need to cast shadow linking rays at a transparent bounce: the lights will be accumulated
956 * via the main path in this case. BSSRDF bounces continue with intersect_subsurface. */
957 if ((continue_path_label & (LABEL_TRANSPARENT | LABEL_SUBSURFACE_SCATTER)) == 0) {
958 if (shadow_linking_schedule_intersection_kernel<current_kernel>(kg, state)) {
959 return;
960 }
961 }
962#endif
963
965}
966
974
#define D
ccl_device_forceinline float bsdf_widen_dD(const KernelGlobals kg, const float prev_dD, const float avg_roughness_squared)
Definition bsdf.h:77
ccl_device Spectrum bsdf_eval(KernelGlobals kg, ccl_private ShaderData *sd, const ccl_private ShaderClosure *sc, const float3 wo, ccl_private float *pdf)
Definition bsdf.h:554
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)
Definition data_passes.h:27
#define kernel_assert(cond)
#define KERNEL_FEATURE_LIGHT_TREE
#define KERNEL_FEATURE_NODE_PORTAL
#define kernel_data
#define KERNEL_FEATURE_AO
#define ccl_restrict
#define ccl_device_forceinline
#define KERNEL_FEATURE_PATH_GUIDING
#define ccl_optional_struct_init
#define kernel_data_fetch(name, index)
#define one_spectrum
#define PRIM_NONE
#define OBJECT_NONE
#define ccl_private
#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 ccl_global
#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])
#define FLT_MAX
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
float3 transform_direction(float3x3 mat, float3 direction)
float3 transform_point(float3x3 mat, float3 point)
float average(float2 a)
const int state
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
@ PATH_MNEE_SAMPLED
@ SR_BSDF_HAS_EVAL
@ SR_EMISSION
@ SR_CACHE_MISS
@ SR_BSDF_HAS_DISPERSION
@ SR_HOLDOUT
@ SR_BSDF
@ SR_BSSRDF
@ SD_HAS_BSSRDF_BUMP
@ SD_HAS_ONLY_VOLUME
@ PRIMITIVE_MOTION_TRIANGLE
@ PRIMITIVE_TRIANGLE
ShaderEvalResult
@ SHADER_EVAL_EMPTY
@ SHADER_EVAL_CACHE_MISS
@ SHADER_EVAL_OK
@ PRNG_LIGHT
@ PRNG_SURFACE_BSDF
@ PATH_RAY_SHADOW_FOR_AO
@ PATH_RAY_SHADOW_CATCHER_PASS
@ PATH_RAY_SUBSURFACE
@ PATH_RAY_SURFACE_PASS
@ PATH_RAY_TRANSPARENT_BACKGROUND
@ PATH_RAY_ANY_PASS
@ PATH_RAY_TERMINATE_ON_NEXT_SURFACE
@ PATH_RAY_VISIBILITY_CAMERA
@ SD_OBJECT_HOLDOUT_MASK
@ SD_OBJECT_TRANSFORM_APPLIED
@ SD_OBJECT_CAUSTICS_CASTER
@ LABEL_CACHE_MISS
@ LABEL_TRANSMIT
@ LABEL_RAY_PORTAL
@ LABEL_NONE
@ LABEL_TRANSPARENT
@ LABEL_SUBSURFACE_SCATTER
@ LIGHT_TRIANGLE
DeviceKernel
@ 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)
Definition math_dual.h:273
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 L
#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])
unsigned short uint16_t
Definition BKE_text.h:80
unsigned int uint32_t
Definition BKE_text.h:81
ccl_device_inline float path_state_rng_light_termination(KernelGlobals kg, const ccl_private RNGState *state)
Definition path_state.h:424
ccl_device_inline void path_state_rng_load(ConstIntegratorState state, ccl_private RNGState *rng_state)
Definition path_state.h:337
ccl_device_inline void path_state_next(KernelGlobals kg, IntegratorState state, const int label, const int runtime_flag)
Definition path_state.h:112
ccl_device_inline float2 path_state_rng_2D(KernelGlobals kg, const ccl_private RNGState *rng_state, const int dimension)
Definition path_state.h:369
ccl_device_inline float3 path_state_rng_3D(KernelGlobals kg, const ccl_private RNGState *rng_state, const int dimension)
Definition path_state.h:377
@ PROFILING_SHADE_SURFACE_SETUP
Definition profiling.h:25
@ PROFILING_SHADE_SURFACE_EVAL
Definition profiling.h:26
@ PROFILING_SHADE_SURFACE_INDIRECT_LIGHT
Definition profiling.h:28
@ PROFILING_SHADE_SURFACE_AO
Definition profiling.h:29
@ PROFILING_SHADE_SURFACE_DIRECT_LIGHT
Definition profiling.h:27
@ PROFILING_SHADE_SURFACE_PASSES
Definition profiling.h:30
#define ccl_device
#define make_float2
#define fminf
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)
Definition shader_data.h:48
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING bsdf_eval_average
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
pass_diffuse_weight
KERNEL_FEATURE_LIGHT_PASSES unlit_throughput
IntegratorShadowStateCPU * IntegratorShadowState
Definition state.h:229
#define INTEGRATOR_STATE_WRITE(state, nested_struct, member)
Definition state.h:235
#define INTEGRATOR_STATE(state, nested_struct, member)
Definition state.h:234
IntegratorStateCPU * IntegratorState
Definition state.h:227
const IntegratorStateCPU * ConstIntegratorState
Definition state.h:228
ccl_device_forceinline void integrator_shadow_path_terminate(IntegratorShadowState state, const DeviceKernel current_kernel)
Definition state_flow.h:287
ccl_device_forceinline void integrator_shadow_path_next(IntegratorShadowState state, const DeviceKernel current_kernel, const DeviceKernel next_kernel)
Definition state_flow.h:279
ccl_device_forceinline void integrator_path_next(IntegratorState state, const DeviceKernel current_kernel, const DeviceKernel next_kernel)
Definition state_flow.h:219
ccl_device_forceinline void integrator_path_terminate(KernelGlobals kg, IntegratorState state, ccl_global float *ccl_restrict render_buffer, const DeviceKernel current_kernel)
Definition state_flow.h:227
ccl_device_forceinline void integrator_path_cache_miss_sorted(IntegratorState, const DeviceKernel)
Definition state_flow.h:244
ccl_device_forceinline IntegratorShadowState integrator_shadow_path_init(ccl_attr_maybe_unused KernelGlobals kg, IntegratorState state, const DeviceKernel next_kernel, const bool is_ao)
Definition state_flow.h:262
ccl_device_forceinline void integrator_state_write_shadow_ray_self(IntegratorShadowState state, const ccl_private Ray *ccl_restrict ray)
Definition state_util.h:98
ccl_device_forceinline void integrator_state_read_ray(ConstIntegratorState state, ccl_private Ray *ccl_restrict ray)
Definition state_util.h:49
ccl_device_forceinline void integrator_state_write_shadow_ray(IntegratorShadowState state, const ccl_private Ray *ccl_restrict ray)
Definition state_util.h:74
ccl_device_forceinline void integrator_state_read_isect(ConstIntegratorState state, ccl_private Intersection *ccl_restrict isect)
Definition state_util.h:179
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)
float3 Spectrum
packed_float3 PackedSpectrum