Blender V5.3
cycles/kernel/light/sample.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
8
10#include "kernel/light/light.h"
11#include "kernel/types.h"
12
13#ifdef __LIGHT_TREE__
14# include "kernel/light/tree.h"
15#endif
16
18
19#include "kernel/sample/mis.h"
20
22
23/* Evaluate constant factors for a direct light sample. */
25 const int shader_id,
26 const int prim,
27 const bool is_light,
29{
30 eval = one_spectrum();
31 const bool is_constant = surface_shader_constant_emission(kg, shader_id, &eval);
32
33 if (is_light) {
34 const ccl_global KernelLight *klight = &kernel_data_fetch(lights, prim);
35 eval *= rgb_to_spectrum(
36 make_float3(klight->strength[0], klight->strength[1], klight->strength[2]));
37 }
38
39 return is_constant;
40}
41
42/* Evaluate shader on light. Not supported for background and triangle lights, that happens
43 * in shade_surface and shader_background. */
47 const int light_id,
48 const float3 ray_P,
49 const float3 ray_D,
50 const float t,
51 const float time,
52 ccl_private Spectrum &r_eval)
53{
54 const ccl_global KernelLight *klight = &kernel_data_fetch(lights, light_id);
55
56 /* setup shading at emitter */
57 Spectrum eval = zero_spectrum();
58
59 if (!surface_shader_constant_emission(kg, klight->shader_id, &eval)) {
60 /* Setup shader data and call surface_shader_eval once, better
61 * for GPU coherence and compile times. */
63
64 ShaderDataTinyStorage emission_sd_storage;
65 ccl_private ShaderData *emission_sd = AS_SHADER_DATA(&emission_sd_storage);
66
67 const float3 P = (t == FLT_MAX) ? -ray_D : ray_P + ray_D * t;
68 float3 Ng = zero_float3();
69 float2 uv = zero_float2();
70 light_normal_uv_from_position(kg, klight, P, ray_D, Ng, uv);
71
73 emission_sd,
74 P,
75 Ng,
76 -ray_D,
77 klight->shader_id,
78 klight->object_id,
79 light_id,
80 uv.x,
81 uv.y,
82 t,
83 time,
84 false,
85 true);
86
87 PROFILING_SHADER(emission_sd->object, emission_sd->shader);
89
90 /* No proper path flag, we're evaluating this for all closures. that's
91 * weak but we'd have to do multiple evaluations otherwise. */
93 kg, state, emission_sd, nullptr, PATH_RAY_VISIBILITY_NONE, PATH_RAY_EMISSION);
94 if (emission_sd->runtime_flag & SR_CACHE_MISS) {
96 }
97
98 /* Evaluate closures. */
99 eval = surface_shader_emission(emission_sd);
100 }
101
102 {
103 const ccl_global KernelLight *klight = &kernel_data_fetch(lights, light_id);
104 eval *= rgb_to_spectrum(
105 make_float3(klight->strength[0], klight->strength[1], klight->strength[2]));
106 }
107
108 r_eval = eval;
109
110 return SHADER_EVAL_OK;
111}
112
113/* Early path termination of shadow rays. */
116{
117 return (kernel_data.integrator.light_inv_rr_threshold > 0.0f) ?
118 reduce_max(fabs(eval)) * kernel_data.integrator.light_inv_rr_threshold :
119 1.0f;
120}
121
124 const float rand_terminate)
125{
126 if (bsdf_eval_is_zero(eval)) {
127 return true;
128 }
129
130 const float probability = light_sample_terminate_probability(kg, bsdf_eval_sum(eval));
131 if (probability < 1.0f) {
132 if (rand_terminate >= probability) {
133 return true;
134 }
135 bsdf_eval_mul(eval, 1.0f / probability);
136 }
137
138 return false;
139}
140
142 ccl_private Spectrum &light_eval,
143 const float bsdf_eval,
144 const float rand_terminate)
145{
146 /* Same logic as above, but where bsdf_eval is already part of the throughput so
147 * we only need to modify the light eval while still taking into account bsdf eval
148 * for the termination probability. */
149 if (is_zero(light_eval)) {
150 return true;
151 }
152
153 const float probability = light_sample_terminate_probability(kg, light_eval * bsdf_eval);
154 if (probability < 1.0f) {
155 if (rand_terminate >= probability) {
156 return true;
157 }
158 light_eval /= probability;
159 }
160
161 return false;
162}
163
164/* This function should be used to compute a modified ray start position for
165 * rays leaving from a surface. The algorithm slightly distorts flat surface
166 * of a triangle. Surface is lifted by amount h along normal n in the incident
167 * point. */
168
170 KernelGlobals kg, const ccl_private ShaderData *ccl_restrict sd, const float3 Ng)
171{
172 float3 V[3];
173 float3 N[3];
174
175 if (sd->type == PRIMITIVE_MOTION_TRIANGLE) {
177 }
178 else {
181 }
182
183 const float u = 1.0f - sd->u - sd->v;
184 const float v = sd->u;
185 const float w = sd->v;
186 const float3 P = V[0] * u + V[1] * v + V[2] * w; /* Local space */
187 float3 n = N[0] * u + N[1] * v + N[2] * w; /* We get away without normalization */
188
189 if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
190 object_dir_transform(kg, sd, &n); /* Normal x scale, to world space */
191 }
192
193 /* Parabolic approximation */
194 const float a = dot(N[2] - N[0], V[0] - V[2]);
195 const float b = dot(N[2] - N[1], V[1] - V[2]);
196 const float c = dot(N[1] - N[0], V[1] - V[0]);
197 float h = a * u * (u - 1) + (a + b + c) * u * v + b * v * (v - 1);
198
199 /* Check flipped normals */
200 if (dot(n, Ng) > 0) {
201 /* Local linear envelope */
202 float h0 = max(max(dot(V[1] - V[0], N[0]), dot(V[2] - V[0], N[0])), 0.0f);
203 float h1 = max(max(dot(V[0] - V[1], N[1]), dot(V[2] - V[1], N[1])), 0.0f);
204 float h2 = max(max(dot(V[0] - V[2], N[2]), dot(V[1] - V[2], N[2])), 0.0f);
205 h0 = max(dot(V[0] - P, N[0]) + h0, 0.0f);
206 h1 = max(dot(V[1] - P, N[1]) + h1, 0.0f);
207 h2 = max(dot(V[2] - P, N[2]) + h2, 0.0f);
208 h = max(min(min(h0, h1), h2), h * 0.5f);
209 }
210 else {
211 float h0 = max(max(dot(V[0] - V[1], N[0]), dot(V[0] - V[2], N[0])), 0.0f);
212 float h1 = max(max(dot(V[1] - V[0], N[1]), dot(V[1] - V[2], N[1])), 0.0f);
213 float h2 = max(max(dot(V[2] - V[0], N[2]), dot(V[2] - V[1], N[2])), 0.0f);
214 h0 = max(dot(P - V[0], N[0]) + h0, 0.0f);
215 h1 = max(dot(P - V[1], N[1]) + h1, 0.0f);
216 h2 = max(dot(P - V[2], N[2]) + h2, 0.0f);
217 h = min(-min(min(h0, h1), h2), h * 0.5f);
218 }
219
220 return n * h;
221}
222
223/* Ray offset to avoid shadow terminator artifact. */
224
226 const ccl_private ShaderData *ccl_restrict sd,
227 const float3 L,
228 ccl_private bool *r_skip_self)
229{
230 float3 P = sd->P;
231
232 if ((sd->type & PRIMITIVE_TRIANGLE) && (sd->shader & SHADER_SMOOTH_NORMAL)) {
233 const float offset_cutoff =
234 kernel_data_fetch(objects, sd->object).shadow_terminator_geometry_offset;
235 /* Do ray offset (heavy stuff) only for close to be terminated triangles:
236 * offset_cutoff = 0.1f means that 10-20% of rays will be affected. Also
237 * make a smooth transition near the threshold. */
238 if (offset_cutoff > 0.0f) {
239 float NL = dot(sd->N, L);
240 const bool transmit = (NL < 0.0f);
241 if (NL < 0) {
242 NL = -NL;
243 }
244
245 const float3 Ng = (transmit ? -sd->Ng : sd->Ng);
246 const float NgL = dot(Ng, L);
247
248 const float offset_amount = (NL < offset_cutoff) ?
249 clamp(2.0f - (NgL + NL) / offset_cutoff, 0.0f, 1.0f) :
250 clamp(1.0f - NgL / offset_cutoff, 0.0f, 1.0f);
251
252 if (offset_amount > 0.0f) {
253 P += shadow_ray_smooth_surface_offset(kg, sd, Ng) * offset_amount;
254
255 /* Only skip self intersections if light direction and geometric normal point in the same
256 * direction, otherwise we're meant to hit this surface. */
257 *r_skip_self = (NgL > 0.0f);
258 }
259 }
260 }
261
262 return P;
263}
264
267 const float3 P,
268 ccl_private Ray *ray,
269 const bool skip_self)
270{
271 /* Setup ray. */
272 ray->P = P;
273 ray->tmin = 0.0f;
274
275 if (ls->t == FLT_MAX) {
276 /* Distant light. */
277 ray->D = ls->D;
278 ray->tmax = ls->t;
279 }
280 else {
281 /* Other lights, avoid self-intersection. */
282 ray->D = ls->P - P;
283 ray->D = safe_normalize_len(ray->D, &ray->tmax);
284 }
285
286 if ((ls->shader & SHADER_CAST_SHADOW) == 0) {
287 /* Signal to not cast shadow ray.
288 * Relies on the intersection_ray_valid() rejecting the ray early on. */
289 ray->tmin = FLT_MAX;
290 }
291
292 ray->dP = differential_make_compact(sd->dP);
293 ray->dD = differential_zero_compact();
294 ray->time = sd->time;
295
296 /* Fill in intersection surface and light details. */
297 ray->self.object = (skip_self) ? sd->object : OBJECT_NONE;
298 ray->self.prim = (skip_self) ? sd->prim : PRIM_NONE;
299 ray->self.light_object = ls->object;
300 ray->self.light_prim = ls->prim;
301}
302
303/* Create shadow ray towards light sample. */
305 KernelGlobals kg,
306 const ccl_private ShaderData *ccl_restrict sd,
308 ccl_private Ray *ray)
309{
310 bool skip_self = true;
311 const float3 P = shadow_ray_offset(kg, sd, ls->D, &skip_self);
312 shadow_ray_setup(sd, ls, P, ray, skip_self);
313}
314
315/* Create shadow ray towards light sample. */
317 const ccl_private ShaderData *ccl_restrict sd,
319 const float3 P,
320 ccl_private Ray *ray)
321{
322 shadow_ray_setup(sd, ls, P, ray, false);
323}
324
325/* Multiple importance sampling weights. */
326
328 const float forward_pdf,
329 const float nee_pdf)
330{
331#ifdef WITH_CYCLES_DEBUG
332 if (kernel_data.integrator.direct_light_sampling_type == DIRECT_LIGHT_SAMPLING_FORWARD) {
333 return 1.0f;
334 }
335 if (kernel_data.integrator.direct_light_sampling_type == DIRECT_LIGHT_SAMPLING_NEE) {
336 return 0.0f;
337 }
338#else
339 (void)kg;
340#endif
341 return power_heuristic(forward_pdf, nee_pdf);
342}
343
345 const float nee_pdf,
346 const float forward_pdf)
347{
348#ifdef WITH_CYCLES_DEBUG
349 if (kernel_data.integrator.direct_light_sampling_type == DIRECT_LIGHT_SAMPLING_FORWARD) {
350 /* Return 0.0f to only account for the contribution in forward path tracing, unless when the
351 * light can not be forward sampled, in which case return 1.0f so it converges to the same
352 * result. */
353 return (forward_pdf == 0.0f);
354 }
355 if (kernel_data.integrator.direct_light_sampling_type == DIRECT_LIGHT_SAMPLING_NEE) {
356 return 1.0f;
357 }
358#else
359 (void)kg;
360#endif
361 return power_heuristic(nee_pdf, forward_pdf);
362}
363
364/* Next event estimation sampling.
365 *
366 * Sample a position on a light in the scene, from a position on a surface or
367 * from a volume segment.
368 *
369 * Uses either a flat distribution or light tree. */
370
372 const float3 rand,
373 const float time,
374 const float3 P,
375 const float3 D,
376 const float t,
377 const int object_receiver,
378 const int bounce,
379 const uint32_t path_flag,
381{
382 const int runtime_flags = SR_BSDF_HAS_TRANSMISSION;
383
384#ifdef __LIGHT_TREE__
385 if (kernel_data.integrator.use_light_tree) {
386 if (!light_tree_sample<true>(kg, rand.z, P, D, t, object_receiver, runtime_flags, ls)) {
387 return false;
388 }
389 }
390 else
391#endif
392 {
393 if (!light_distribution_sample(kg, rand.z, ls)) {
394 return false;
395 }
396 }
397
398 /* Sample position on the selected light. */
399 return light_sample<true>(
400 kg, rand, time, P, D, object_receiver, runtime_flags, bounce, path_flag, ls);
401}
402
404 const float3 rand,
405 const float time,
406 const float3 P,
407 const float3 N,
408 const int object_receiver,
409 const int runtime_flags,
410 const int bounce,
411 const uint32_t path_flag,
413{
414 /* Randomly select a light. */
415#ifdef __LIGHT_TREE__
416 if (kernel_data.integrator.use_light_tree) {
417 if (!light_tree_sample<false>(kg, rand.z, P, N, 0.0f, object_receiver, runtime_flags, ls)) {
418 return false;
419 }
420 }
421 else
422#endif
423 {
424 if (!light_distribution_sample(kg, rand.z, ls)) {
425 return false;
426 }
427 }
428
429 /* Sample position on the selected light. */
430 return light_sample<false>(
431 kg, rand, time, P, N, object_receiver, runtime_flags, bounce, path_flag, ls);
432}
433
434/* Update light sample with new shading point position for MNEE. The position on the light is fixed
435 * except for directional light. */
438 const float3 P,
439 const float3 N,
440 const uint32_t path_flag)
441{
442 const ccl_global KernelLight *klight = &kernel_data_fetch(lights, ls->prim);
443
444 if (ls->type == LIGHT_POINT) {
445 point_light_mnee_sample_update(klight, ls, P, N, path_flag);
446 }
447 else if (ls->type == LIGHT_SPOT) {
448 spot_light_mnee_sample_update(kg, klight, ls, P, N, path_flag);
449 }
450 else if (ls->type == LIGHT_AREA) {
451 area_light_mnee_sample_update(klight, ls, P);
452 }
453 else {
454 /* Keep previous values. */
455 }
456
457 /* Re-apply already computed selection pdf. */
458 ls->pdf *= ls->pdf_selection;
459}
460
461/* Forward sampling.
462 *
463 * Multiple importance sampling weights for hitting surface, light or background
464 * through indirect light ray.
465 *
466 * The BSDF or phase pdf from the previous bounce was stored in mis_ray_pdf and
467 * is used for balancing with the light sampling pdf. */
468
470 KernelGlobals kg,
472 const PathRayVisibility path_visibility,
473 const uint32_t path_flag,
474 const ccl_private ShaderData *sd)
475{
476 bool has_mis = !(path_flag & PATH_RAY_MIS_SKIP) &&
477 (sd->shader_flag &
478 ((sd->runtime_flag & SR_BACKFACING) ? SD_MIS_BACK : SD_MIS_FRONT));
479
480#ifdef __HAIR__
481 has_mis &= (sd->type & PRIMITIVE_TRIANGLE);
482#endif
483
484 if (!has_mis) {
485 return 1.0f;
486 }
487
488 const float bsdf_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf);
489 const float t = sd->ray_length;
490 float pdf = triangle_light_pdf(kg, sd, t);
491
492 /* Light selection pdf. */
493#ifdef __LIGHT_TREE__
494 if (kernel_data.integrator.use_light_tree) {
495 const float3 ray_P = INTEGRATOR_STATE(state, ray, P);
496 const float dt = INTEGRATOR_STATE(state, ray, previous_dt);
497 const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n);
498
499 const uint lookup_offset = kernel_data_fetch(object_lookup_offset, sd->object);
500 const uint prim_offset = kernel_data_fetch(object_prim_offset, sd->object);
501 const uint triangle = kernel_data_fetch(triangle_to_tree,
502 sd->prim - prim_offset + lookup_offset);
503
504 pdf *= light_tree_pdf(kg,
505 ray_P,
506 N,
507 dt,
508 path_visibility,
509 path_flag,
510 sd->object,
511 triangle,
513 }
514 else
515#endif
516 {
517 /* Handled in triangle_light_pdf for efficiency. */
518 }
519
520 return light_sample_mis_weight_forward(kg, bsdf_pdf, pdf);
521}
522
524 KernelGlobals kg,
526 const PathRayVisibility path_visibility,
527 const uint32_t path_flag,
528 const int object_id,
529 const float light_sample_pdf,
530 const float3 P)
531{
532 if (path_flag & PATH_RAY_MIS_SKIP) {
533 return 1.0f;
534 }
535
536 const float mis_ray_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf);
537 float pdf = light_sample_pdf;
538
539 /* Light selection pdf. */
540#ifdef __LIGHT_TREE__
541 if (kernel_data.integrator.use_light_tree) {
542 const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n);
543 const float dt = INTEGRATOR_STATE(state, ray, previous_dt);
544 pdf *= light_tree_pdf(kg,
545 P,
546 N,
547 dt,
548 path_visibility,
549 path_flag,
550 0,
551 kernel_data_fetch(light_to_tree, object_id),
553 }
554 else
555#endif
556 {
558 }
559
560 return light_sample_mis_weight_forward(kg, mis_ray_pdf, pdf);
561}
562
564 KernelGlobals kg,
566 const PathRayVisibility path_visibility,
567 const uint32_t path_flag,
568 const int object_id,
569 const float light_sample_pdf)
570{
571 const float3 ray_P = INTEGRATOR_STATE(state, ray, P);
573 kg, state, path_visibility, path_flag, object_id, light_sample_pdf, ray_P);
574}
575
577 KernelGlobals kg,
579 const PathRayVisibility path_visibility,
580 const uint32_t path_flag)
581{
582 /* Check if background light exists or if we should skip PDF. */
583 if (!kernel_data.background.use_mis || (path_flag & PATH_RAY_MIS_SKIP)) {
584 return 1.0f;
585 }
586
587 const float3 ray_P = INTEGRATOR_STATE(state, ray, P);
588 const float3 ray_D = INTEGRATOR_STATE(state, ray, D);
589 const float mis_ray_pdf = INTEGRATOR_STATE(state, path, mis_ray_pdf);
590
591 float pdf = background_light_pdf(kg, ray_P, ray_D);
592
593 /* Light selection pdf. */
594#ifdef __LIGHT_TREE__
595 if (kernel_data.integrator.use_light_tree) {
596 const float3 N = INTEGRATOR_STATE(state, path, mis_origin_n);
597 const float dt = INTEGRATOR_STATE(state, ray, previous_dt);
598 const uint light = kernel_data_fetch(light_to_tree, kernel_data.background.object_index);
599 pdf *= light_tree_pdf(kg,
600 ray_P,
601 N,
602 dt,
603 path_visibility,
604 path_flag,
605 0,
606 light,
608 }
609 else
610#endif
611 {
613 }
614
615 return light_sample_mis_weight_forward(kg, mis_ray_pdf, pdf);
616}
617
#define D
ccl_device_forceinline void area_light_mnee_sample_update(const ccl_global KernelLight *klight, ccl_private LightSample *ls, const float3 P)
Definition area.h:374
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
btScalar max
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
ccl_device_inline bool light_sample_terminate(KernelGlobals kg, ccl_private BsdfEval *ccl_restrict eval, const float rand_terminate)
ccl_device_forceinline void light_sample_update(KernelGlobals kg, ccl_private LightSample *ls, const float3 P, const float3 N, const uint32_t path_flag)
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_inline float light_sample_mis_weight_forward(KernelGlobals kg, const float forward_pdf, const float nee_pdf)
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 void light_sample_to_volume_shadow_ray(const ccl_private ShaderData *ccl_restrict sd, const ccl_private LightSample *ccl_restrict ls, const float3 P, ccl_private Ray *ray)
ccl_device_inline float light_sample_mis_weight_nee(KernelGlobals kg, const float nee_pdf, const float forward_pdf)
ccl_device_inline float light_sample_mis_weight_forward_background(KernelGlobals kg, IntegratorState state, const PathRayVisibility path_visibility, const uint32_t path_flag)
ccl_device_inline float light_sample_terminate_probability(KernelGlobals kg, ccl_private Spectrum eval)
ccl_device_inline void shadow_ray_setup(const ccl_private ShaderData *ccl_restrict sd, const ccl_private LightSample *ccl_restrict ls, const float3 P, ccl_private Ray *ray, const bool skip_self)
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_lamp(KernelGlobals kg, IntegratorState state, const PathRayVisibility path_visibility, const uint32_t path_flag, const int object_id, const float light_sample_pdf, const float3 P)
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 float3 shadow_ray_smooth_surface_offset(KernelGlobals kg, const ccl_private ShaderData *ccl_restrict sd, const float3 Ng)
ccl_device_inline bool light_sample_from_volume_segment(KernelGlobals kg, const float3 rand, const float time, const float3 P, const float3 D, const float t, const int object_receiver, const int bounce, const uint32_t path_flag, ccl_private LightSample *ls)
ccl_device_inline float light_sample_mis_weight_forward_distant(KernelGlobals kg, IntegratorState state, const PathRayVisibility path_visibility, const uint32_t path_flag, const int object_id, const float light_sample_pdf)
ccl_device_noinline_cpu ShaderEvalResult light_sample_shader_eval_forward(KernelGlobals kg, IntegratorState state, const int light_id, const float3 ray_P, const float3 ray_D, const float t, const float time, ccl_private Spectrum &r_eval)
#define NL
#define kernel_assert(cond)
#define kernel_data
#define ccl_restrict
#define ccl_device_forceinline
#define kernel_data_fetch(name, index)
#define AS_SHADER_DATA(shader_data_tiny_storage)
#define one_spectrum
#define PRIM_NONE
#define zero_spectrum
#define OBJECT_NONE
#define ccl_private
#define ccl_device_noinline_cpu
#define ccl_device_inline
#define ccl_global
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
ccl_device_forceinline float differential_make_compact(const float dD)
ccl_device_forceinline float differential_zero_compact()
ccl_device_inline float light_distribution_pdf_lamp(KernelGlobals kg)
CCL_NAMESPACE_BEGIN ccl_device int light_distribution_sample(KernelGlobals kg, const float rand)
ccl_device_inline void triangle_vertices_and_normals(KernelGlobals kg, ccl_private const ShaderData *sd, float3 P[3], float3 N[3])
#define FLT_MAX
float dot(VecOp< float, D >, VecOp< float, D >) RET
constexpr T clamp(T, U, U) RET
bool is_zero(float3x3 a)
float reduce_max(float2 a)
const int state
ccl_device_inline void object_dir_transform(KernelGlobals kg, const ccl_private ShaderData *sd, ccl_private float3 *D)
ccl_device float background_light_pdf(KernelGlobals kg, const float3 P, float3 direction)
ccl_device void light_normal_uv_from_position(KernelGlobals kg, const ccl_global KernelLight *klight, const float3 P, const float3 D, ccl_private float3 &Ng, ccl_private float2 &uv)
ccl_device_inline bool light_sample(KernelGlobals kg, const int lamp, const float2 rand, const float3 P, const float3 N, const int runtime_flags, const uint32_t path_flag, ccl_private LightSample *ls)
ccl_device_inline int light_link_receiver_forward(KernelGlobals kg, IntegratorState state)
uint32_t PathRayVisibility
@ SR_BSDF_HAS_TRANSMISSION
@ SR_BACKFACING
@ SR_CACHE_MISS
@ SD_MIS_BACK
@ SD_MIS_FRONT
@ PRIMITIVE_MOTION_TRIANGLE
@ PRIMITIVE_TRIANGLE
ShaderData ShaderDataTinyStorage
@ DIRECT_LIGHT_SAMPLING_NEE
@ DIRECT_LIGHT_SAMPLING_FORWARD
ShaderEvalResult
@ SHADER_EVAL_CACHE_MISS
@ SHADER_EVAL_OK
@ PATH_RAY_EMISSION
@ PATH_RAY_MIS_SKIP
@ PATH_RAY_VISIBILITY_NONE
@ SD_OBJECT_TRANSFORM_APPLIED
@ SHADER_SMOOTH_NORMAL
@ SHADER_CAST_SHADOW
@ LIGHT_AREA
@ LIGHT_SPOT
@ LIGHT_POINT
ccl_device_inline Spectrum rgb_to_spectrum(const float3 rgb)
ccl_device_forceinline void point_light_mnee_sample_update(const ccl_global KernelLight *klight, ccl_private LightSample *ls, const float3 P, const float3 N, const uint32_t path_flag)
ccl_device_forceinline float triangle_light_pdf(KernelGlobals kg, const ccl_private ShaderData *sd, const float t)
ccl_device_inline bool bsdf_eval_is_zero(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 dual3 fabs(const ccl_private dual3 &a)
Definition math_dual.h:241
CCL_NAMESPACE_BEGIN ccl_device_inline float2 zero_float2()
Definition math_float2.h:13
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
Definition math_float3.h:17
ccl_device_inline float3 safe_normalize_len(const float3 a, ccl_private float *t)
#define N
#define L
#define PROFILING_INIT_FOR_SHADER(kg, event)
#define PROFILING_EVENT(event)
#define PROFILING_SHADER(object, shader)
ccl_device float power_heuristic(const float a, const float b)
Definition mis.h:26
ccl_device_inline void motion_triangle_vertices_and_normals(KernelGlobals kg, const ccl_private ShaderData *sd, float3 verts[3], float3 normals[3])
@ PROFILING_SHADE_LIGHT_SETUP
Definition profiling.h:42
@ PROFILING_SHADE_LIGHT_EVAL
Definition profiling.h:43
#define ccl_device
ccl_device_inline void shader_setup_from_sample(KernelGlobals kg, ccl_private ShaderData *ccl_restrict sd, const float3 P, const float3 Ng, const float3 I, const int shader, const int object, const int prim, const float u, const float v, const float t, const float time, const bool object_space, const bool is_lamp)
#define min(a, b)
Definition sort.cc:38
ccl_device_forceinline void spot_light_mnee_sample_update(KernelGlobals kg, const ccl_global KernelLight *klight, ccl_private LightSample *ls, const float3 P, const float3 N, const uint32_t path_flag)
Definition spot.h:163
#define INTEGRATOR_STATE(state, nested_struct, member)
Definition state.h:234
IntegratorStateCPU * IntegratorState
Definition state.h:227
float x
float y
float z
Definition sky_math.h:136
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_emission(const ccl_private ShaderData *sd)
ccl_device bool surface_shader_constant_emission(KernelGlobals kg, const int shader, ccl_private Spectrum *eval)
ccl_device_inline bool is_light(const ccl_global KernelLightTreeEmitter *kemitter)
Definition tree.h:69
ccl_device bool light_tree_sample(KernelGlobals kg, const float rand, const float3 P, float3 N_or_D, float t, const int object_receiver, const int runtime_flags, ccl_private LightSample *ls)
Definition tree.h:743
ccl_device float light_tree_pdf(KernelGlobals kg, float3 P, float3 N, const float dt, const uint32_t path_flag, const int object_emitter, const uint index_emitter, const int object_receiver)
Definition tree.h:814
float3 Spectrum
CCL_NAMESPACE_BEGIN struct Window V