Blender V5.3
eevee_nodetree_lib.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022-2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
9#include "draw_model.bsl.hh"
10#include "draw_view.bsl.hh"
11#include "draw_viewlayer.bsl.hh"
12#include "draw_volume.bsl.hh"
15#include "eevee_fast_gi.bsl.hh"
16#include "eevee_hiz.bsl.hh"
22#include "eevee_nodetree.bsl.hh"
24#include "eevee_pipeline.bsl.hh"
28#include "eevee_shadow.bsl.hh"
29#include "eevee_uniform.bsl.hh"
31#include "gpu_shader_codegen_lib.glsl"
34
35namespace eevee {
36
37/* Resource for the raycast node implementation using screen space raytracing. */
43
44}
45
55
81 float ray_depth;
88
90
93 float holdout;
94
98
99 /* Global thickness set after nodetree_thickness evaluation. Otherwise set to 0.0f. */
101
103
104 /* Sampled closure parameters. */
106
108
110 {
111 switch (i) {
112 case 0:
113 return closure_bins[0];
114 case 1:
115 if (pipe.closure_bin_count > 1) [[static_branch]] {
116 return closure_bins[1];
117 }
118 break;
119 case 2:
120 if (pipe.closure_bin_count > 2) [[static_branch]] {
121 return closure_bins[2];
122 }
123 break;
124 }
125 /* Unreachable. */
126 assert(false);
127 return closure_bins[0];
128 }
129
130 ClosureUndetermined closure_get_resolved(const eevee::PipelineConstants &pipe,
131 uchar i,
132 float additional_weight) const
133 {
135 ClosureUndetermined cl = r.data;
136 cl.color *= r.get_final_weight() * additional_weight;
137 return cl;
138 }
139};
140
143
149
153
155
156 [[resource_table]] [[condition(!is_occupancy_pipe)]] UtilityTexture util_tx;
157
158 [[resource_table]] [[condition(use_ambient_occlusion)]] eevee::HiZ hiz;
159
161
164
167 [[resource_table]] [[condition(use_forward_lighting)]]
169
170 [[resource_table]] [[condition(use_forward_lighting && use_transparency)]]
172 [[resource_table]] [[condition(use_forward_lighting && use_transparency)]]
174
177
179 {
181 if (pipe.is_shadow_pipe) {
182 return id.resource_id<64>();
183 }
184 return id.resource_id<1>();
185 }
186
187 uint view_id_get(const ShadingData &sd)
188 {
190 if (pipe.is_shadow_pipe) {
191 return id.view_id<64>();
192 }
193 return id.view_id<1>();
194 }
195
200
202 {
203 return infos.get(resource_id_get(sd));
204 }
205
207 {
208 return view.get(view_id_get(sd));
209 }
210
212 {
213 return {.viewmat = uniforms.uniform_buf.camera.shading_viewmat,
214 .viewinv = uniforms.uniform_buf.camera.shading_viewinv,
215 .winmat = uniforms.uniform_buf.camera.winmat,
216 .wininv = uniforms.uniform_buf.camera.wininv};
217 }
218
220 {
222 return model.get(lrd.light_buf[light_index].resource_id);
223 }
224 return {};
225 }
226};
227
228void closure_weights_reset(KernelGlobals &kg, ShadingData &sd, float closure_rand)
229{
230 sd.closure_bins[0].reset(closure_rand);
231 if (kg.pipe.closure_bin_count > 1) [[static_branch]] {
232 sd.closure_bins[1].reset(closure_rand);
233 }
234 if (kg.pipe.closure_bin_count > 2) [[static_branch]] {
235 sd.closure_bins[2].reset(closure_rand);
236 }
237
238 sd.volume_scattering = float3(0.0f);
239 sd.volume_anisotropy = 0.0f;
240 sd.volume_absorption = float3(0.0f);
241
242 sd.emission = float3(0.0f);
243 sd.transmittance = float3(0.0f);
244 sd.volume_scattering = float3(0.0f);
245 sd.volume_absorption = float3(0.0f);
246 sd.holdout = 0.0f;
247 sd.closure_reflection_bin = true;
248
251 }
252}
253
254template<typename T> void closure_base_copy(ClosureUndetermined &cl, T in_cl)
255{
256 cl.color = in_cl.color;
257 cl.N = in_cl.N;
258 cl.type = closure_type_get(in_cl);
259}
260
261template void closure_base_copy<ClosureDiffuse>(ClosureUndetermined &, ClosureDiffuse);
262template void closure_base_copy<ClosureSubsurface>(ClosureUndetermined &, ClosureSubsurface);
263template void closure_base_copy<ClosureTranslucent>(ClosureUndetermined &, ClosureTranslucent);
264template void closure_base_copy<ClosureReflection>(ClosureUndetermined &, ClosureReflection);
265template void closure_base_copy<ClosureRefraction>(ClosureUndetermined &, ClosureRefraction);
266template void closure_base_copy<ClosureThinRefraction>(ClosureUndetermined &,
267 ClosureThinRefraction);
268
269/* Single BSDFs. */
270Closure closure_eval(KernelGlobals &kg, ShadingData &sd, ClosureDiffuse diffuse)
271{
272 if (kg.pipe.use_diffuse) [[static_branch]] {
273 ClosureUndetermined cl;
274 closure_base_copy(cl, diffuse);
276 [[static_branch]]
277 {
278 /* Use second slot so we can have diffuse + translucent without noise. */
279 closure_select(sd.closure_bins[1], cl);
280 }
281 else {
282 /* Either is single closure or use same bin as transmission bin. */
283 closure_select(sd.closure_bins[0], cl);
284 }
285 }
286 return Closure(0);
287}
288
289Closure closure_eval(KernelGlobals &kg, ShadingData &sd, ClosureSubsurface subsurface)
290{
291 if (kg.pipe.use_sss) [[static_branch]] {
292 ClosureUndetermined cl;
293 closure_base_copy(cl, subsurface);
294 cl.data.rgb = subsurface.sss_radius;
295 /* Transmission Closures are always in first bin. */
296 closure_select(sd.closure_bins[0], cl);
297 }
298 return Closure(0);
299}
300
301Closure closure_eval(KernelGlobals &kg, ShadingData &sd, ClosureTranslucent translucent)
302{
304 ClosureUndetermined cl;
305 closure_base_copy(cl, translucent);
306 /* Transmission Closures are always in first bin. */
307 closure_select(sd.closure_bins[0], cl);
308 }
309 return Closure(0);
310}
311
312Closure closure_eval(KernelGlobals &kg, ShadingData &sd, ClosureReflection reflection)
313{
314 if (kg.pipe.use_reflection) [[static_branch]] {
315 ClosureUndetermined cl;
316 closure_base_copy(cl, reflection);
317 cl.data.r = reflection.roughness;
318 if (kg.pipe.use_clearcoat) [[static_branch]] {
319 /* Alternate between two bins on a per closure basis.
320 * Allow clearcoat layer without noise.
321 * Choosing the bin with the least weight can choose a
322 * different bin for the same closure and
323 * produce issue with ray-tracing denoiser.
324 * Always start with the second bin, this one doesn't
325 * overlap with other closure. */
326 if (kg.pipe.closure_bin_count == 2) [[static_branch]] {
327 /* Multiple reflection closures. */
328 if (sd.closure_reflection_bin) {
329 closure_select(sd.closure_bins[1], cl);
330 }
331 else {
332 closure_select(sd.closure_bins[0], cl);
333 }
334 }
335 else if (kg.pipe.closure_bin_count == 3) [[static_branch]] {
336 /* Multiple reflection closures and one other closure. */
337 if (sd.closure_reflection_bin) {
338 closure_select(sd.closure_bins[2], cl);
339 }
340 else {
341 closure_select(sd.closure_bins[1], cl);
342 }
343 }
344 else {
345 /* Clearcoat should always have at least 2 bins. */
346 assert(0);
347 }
349 }
350 else {
351 if (kg.pipe.closure_bin_count == 1) [[static_branch]] {
352 /* Only one reflection closure is present in the whole tree. */
353 closure_select(sd.closure_bins[0], cl);
354 }
355 else if (kg.pipe.closure_bin_count == 2) [[static_branch]] {
356 /* Only one reflection and one other closure. */
357 closure_select(sd.closure_bins[1], cl);
358 }
359 else if (kg.pipe.closure_bin_count == 3) [[static_branch]] {
360 /* Only one reflection and two other closures. */
361 closure_select(sd.closure_bins[2], cl);
362 }
363 }
364 }
365
366 return Closure(0);
367}
368
369Closure closure_eval(KernelGlobals &kg, ShadingData &sd, ClosureRefraction refraction)
370{
371 if (kg.pipe.use_refraction) [[static_branch]] {
372 ClosureUndetermined cl;
373 closure_base_copy(cl, refraction);
374 cl.data.r = refraction.roughness;
375 cl.data.g = refraction.ior;
376 /* Transmission Closures are always in first bin. */
377 closure_select(sd.closure_bins[0], cl);
378 }
379 return Closure(0);
380}
381
382Closure closure_eval(KernelGlobals &kg, ShadingData &sd, ClosureThinRefraction refraction)
383{
384 if (kg.pipe.use_refraction) [[static_branch]] {
385 ClosureUndetermined cl;
386 closure_base_copy(cl, refraction);
387 cl.data.r = refraction.roughness;
388 /* Transmission Closures are always in first bin. */
389 closure_select(sd.closure_bins[0], cl);
390 }
391 return Closure(0);
392}
393
394Closure closure_eval(KernelGlobals & /*kg*/, ShadingData &sd, ClosureEmission emission)
395{
396 sd.emission += emission.emission;
397 return Closure(0);
398}
399
400Closure closure_eval(KernelGlobals & /*kg*/, ShadingData &sd, ClosureTransparency transparency)
401{
402 sd.transmittance += transparency.transmittance;
403 sd.holdout += transparency.holdout;
404 return Closure(0);
405}
406
407Closure closure_eval(KernelGlobals & /*kg*/, ShadingData &sd, ClosureVolumeScatter volume_scatter)
408{
409 sd.volume_scattering += volume_scatter.scattering;
410 sd.volume_anisotropy += volume_scatter.anisotropy;
411 return Closure(0);
412}
413
415 ShadingData &sd,
416 ClosureVolumeAbsorption volume_absorption)
417{
418 sd.volume_absorption += volume_absorption.absorption;
419 return Closure(0);
420}
421
422Closure closure_eval(KernelGlobals & /*kg*/, ShadingData & /*sd*/, ClosureHair /*hair*/)
423{
424 /* TODO */
425 return Closure(0);
426}
427
428/* Glass BSDF. */
430 ShadingData &sd,
431 ClosureReflection reflection,
432 ClosureRefraction refraction)
433{
434 closure_eval(kg, sd, reflection);
435 closure_eval(kg, sd, refraction);
436 return Closure(0);
437}
438
439/* Dielectric BSDF. */
441 ShadingData &sd,
442 ClosureDiffuse diffuse,
443 ClosureReflection reflection)
444{
445 closure_eval(kg, sd, diffuse);
446 closure_eval(kg, sd, reflection);
447 return Closure(0);
448}
449
450/* Coat BSDF. */
452 ShadingData &sd,
453 ClosureReflection reflection,
454 ClosureReflection coat)
455{
456 closure_eval(kg, sd, reflection);
457 closure_eval(kg, sd, coat);
458 return Closure(0);
459}
460
461/* Volume BSDF. */
463 ShadingData &sd,
464 ClosureVolumeScatter volume_scatter,
465 ClosureVolumeAbsorption volume_absorption,
466 ClosureEmission emission)
467{
468 closure_eval(kg, sd, volume_scatter);
469 closure_eval(kg, sd, volume_absorption);
470 closure_eval(kg, sd, emission);
471 return Closure(0);
472}
473
474/* Specular BSDF. */
476 ShadingData &sd,
477 ClosureDiffuse diffuse,
478 ClosureReflection reflection,
479 ClosureReflection coat)
480{
481 closure_eval(kg, sd, diffuse);
482 closure_eval(kg, sd, reflection);
483 closure_eval(kg, sd, coat);
484 return Closure(0);
485}
486
487/* Principled BSDF. */
489 ShadingData &sd,
490 ClosureDiffuse diffuse,
491 ClosureReflection reflection,
492 ClosureReflection coat,
493 ClosureRefraction refraction)
494{
495 closure_eval(kg, sd, diffuse);
496 closure_eval(kg, sd, reflection);
497 closure_eval(kg, sd, coat);
498 closure_eval(kg, sd, refraction);
499 return Closure(0);
500}
501
502/* NOP since we are sampling closures. */
504{
505 return Closure(0);
506}
507Closure closure_mix(Closure /*cl1*/, Closure /*cl2*/, float /*fac*/)
508{
509 return Closure(0);
510}
511
513 const ShadingData &sd,
514 float3 normal,
515 float max_distance,
516 const float inverted,
517 const float sample_count)
518{
519#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
522 const eevee::Sampling &samp = kg.sampling;
523 const UtilityTexture &util_tx = kg.util_tx;
524 const eevee::HiZ &hiz = kg.hiz;
525 const eevee::Uniform &uni = kg.uniforms;
526 const draw::View &views = kg.view;
527
528 const ViewMatrices view = views.get(0);
529
530 float3 vP = view.point_world_to_view(sd.P);
531 float3 vN = view.normal_world_to_view(normal);
532
534 noise = fract(noise + samp.rng_3D_get(SAMPLING_AO_U).xyzx);
535
536 float result = eevee::fast_gi::eval<float>(uni,
537 view,
538 uni.raytrace_buf.fast_gi_thickness,
539 hiz.hiz_tx,
540 hiz.hiz_tx /* Dummy. */,
541 hiz.hiz_tx /* Dummy. */,
542 vP,
543 vN,
544 noise,
545 uni.uniform_buf.ao.pixel_size,
546 max_distance,
547 uni.uniform_buf.ao.angle_bias,
548 2,
549 int(sample_count / 2.0f),
550 inverted != 0.0f,
551 true);
552
553 return saturate(result);
554 }
555 }
556#endif
557 return 1.0f;
558}
559
561 const ShadingData &sd,
563 float3 direction,
564 float max_distance,
565 bool self_only,
566 bool &is_hit,
567 bool &self_hit,
568 float &hit_distance,
569 float3 &hit_position,
570 float3 &hit_normal)
571{
572
573 is_hit = false;
574 self_hit = false;
575 hit_distance = max_distance;
576 hit_position = float3(0.0f);
577 hit_normal = float3(0.0f);
578
579 direction = normalize(direction);
580
581 if (kg.pipe.use_raycast) [[static_branch]] {
582 if (!kg.uniforms.pipeline_buf.can_raycast) {
583 /* We can't ray-cast on pre-pass for ray-cast visible objects.
584 * We use a UBO property to avoid compiling more shader variants. */
585 return;
586 }
587
588 float3 ws_start = position;
589 float3 ws_end = position + direction * max_distance;
590 if (!clip_ray(ws_start,
591 ws_end,
592 direction,
593 max_distance,
595 {
596 return;
597 }
598
599 {
600 const eevee::Raycast &raycast = kg.raycast;
601 const ViewMatrices view = kg.view.get(0);
602
603 {
604 /* Offset the start to prevent wrong intersection due to depth precision. */
605 float3 vs_start = view.point_world_to_view(ws_start);
606 float start_depth = view.depth_view_to_screen(vs_start.z);
607 float offset_depth = uintBitsToFloat(floatBitsToUint(start_depth) + 2);
608 float offset_delta = abs(view.depth_screen_to_view(offset_depth) - vs_start.z);
609 ws_start += direction * offset_delta;
610 }
611
612 float noise_offset = kg.sampling.rng_1D_get(SAMPLING_RAYTRACE_W);
613 float jitter = random::interleaved_gradient(sd.frag_co.xy, 1.0f, noise_offset);
614
615 float2 hit_uv = float2(0.0f);
616 uint self_id = kg.resource_id_get(sd) & uint(0xFFFF);
617
618 float result = raytrace_screen_2(view,
619 view.point_world_to_view(ws_start),
620 view.point_world_to_view(ws_end),
621 view.normal_world_to_view(direction),
622 raycast.raycast_depth_tx,
624 64,
625 jitter,
626 raycast.object_id_tx,
627 self_only ? self_id : 0u,
628 hit_uv);
629 if (result >= 0.0f) {
630 is_hit = true;
631 hit_position = ws_start + direction * result;
632 hit_distance = distance(position, hit_position);
633 hit_normal = normalize(texture(raycast.prepass_normal_tx, hit_uv).xyz * 2.0f - 1.0f);
634 int2 hit_texel = int2(hit_uv * float2(textureSize(raycast.object_id_tx, 0)));
635 uint hit_id = texelFetch(raycast.object_id_tx, hit_texel, 0).x;
636 self_hit = self_only || (hit_id == self_id);
637 }
638 }
639 }
640}
641
644
650float f0_from_ior(float eta)
651{
652 return (eta - 1.0f) / (eta + 1.0f);
653}
654
660float F0_from_ior(float eta)
661{
662 return square(f0_from_ior(eta));
663}
664float F0_from_f0(float f0)
665{
666 return square(f0);
667}
668
672template<typename T> float3 F_brdf_single_scatter(float3 f0, float3 f90, T lut)
673{
674 return f0 * lut.scale + f90 * lut.bias;
675}
677 float3,
680 float3,
682
683/* Multi-scattering brdf approximation from
684 * "A Multiple-Scattering Microfacet Model for Real-Time Image-based Lighting"
685 * https://jcgt.org/published/0008/01/03/paper.pdf by Carmelo J. Fdez-Agüera. */
686template<typename T> float3 F_brdf_multi_scatter(float3 f0, float3 f90, T lut)
687{
688 float3 FssEss = F_brdf_single_scatter(f0, f90, lut);
689
690 float Ess = lut.scale + lut.bias;
691 float Ems = 1.0f - Ess;
692 float3 Favg = f0 + (f90 - f0) / 21.0f;
693
694 /* The original paper uses `FssEss * radiance + Fms*Ems * irradiance`, but
695 * "A Journey Through Implementing Multi-scattering BRDFs and Area Lights" by Steve McAuley
696 * suggests to use `FssEss * radiance + Fms*Ems * radiance` which results in comparable quality.
697 * We handle `radiance` outside of this function, so the result simplifies to:
698 * `FssEss + Fms*Ems = FssEss * (1 + Ems*Favg / (1 - Ems*Favg)) = FssEss / (1 - Ems*Favg)`.
699 * This is a simple albedo scaling very similar to the approach used by Cycles:
700 * "Practical multiple scattering compensation for microfacet model". */
701 return FssEss / (1.0f - Ems * Favg);
702}
704 float3,
707 float3,
709
711 float3 F0,
712 float3 F82,
713 float cos_theta,
714 float roughness,
715 bool do_multiscatter,
716 float3 &reflectance)
717{
720 kg.util_tx, cos_theta, roughness);
721
722 reflectance = do_multiscatter ? F_brdf_multi_scatter(F0, float3(1.0f), lut) :
723 F_brdf_single_scatter(F0, float3(1.0f), lut);
724
725 /* Precompute the F82 term factor for the Fresnel model.
726 * In the classic F82 model, the F82 input directly determines the value of the Fresnel
727 * model at ~82 degrees, similar to F0 and F90.
728 * With F82-Tint, on the other hand, the value at 82 degrees is the value of the classic
729 * Schlick model multiplied by the tint input. Therefore, the factor follows by setting
730 * `F82Tint(cosI) = FSchlick(cosI) - b*cosI*(1-cosI)^6` and `F82Tint(acos(1/7)) =
731 * FSchlick(acos(1/7)) * f82_tint` and solving for `b`. */
732 constexpr float f = 6.0f / 7.0f;
733 constexpr float f5 = (f * f) * (f * f) * f;
734 constexpr float f6 = (f * f) * (f * f) * (f * f);
735 float3 F_schlick = mix(F0, float3(1.0f), f5);
736 float3 b = F_schlick * (7.0f / f6) * (1.0f - F82);
737 reflectance -= b * lut.metal_bias;
738 }
739}
740
741/* Computes the reflectance and transmittance based on the tint (`f0`, `f90`, `transmission_tint`)
742 * and the BSDF LUT. */
744 float3 F0,
745 float3 F90,
747 float cos_theta,
748 float roughness,
749 float ior,
750 bool do_multiscatter,
751 float3 &reflectance,
752 float3 &transmittance)
753{
754
755 if (ior == 1.0f) {
756 reflectance = float3(0.0f);
757 transmittance = transmission_tint;
758 return;
759 }
760
761 /* TODO(not_mark): strip namespaces on BSL port. */
763
764 const float f0 = f0_from_ior(ior);
765
767 if (ior > 1.0f) {
768 /* Gradually increase `f90` from 0 to 1 when IOR is in the range of [1.0f, 1.33f], to avoid
769 * harsh transition at `IOR == 1`. */
770 if (all(equal(F90, float3(1.0f)))) {
771 F90 = float3(saturate(2.33f / 0.33f * f0));
772 }
773
775 kg.util_tx, cos_theta, roughness);
777 kg.util_tx, cos_theta, roughness, f0);
778
779 lut.scale = brdf_lut.scale;
780 lut.bias = brdf_lut.bias;
782 }
783 else {
785 }
786 }
787
788 reflectance = F_brdf_single_scatter(F0, F90, lut);
789 transmittance = (float3(1.0f) - F0) * lut.transmission_factor * transmission_tint;
790
791 if (do_multiscatter) {
792 const float real_F0 = F0_from_f0(f0);
793 const float Ess = real_F0 * lut.scale + lut.bias + (1.0f - real_F0) * lut.transmission_factor;
794 const float Ems = 1.0f - Ess;
795 /* Assume that the transmissive tint makes up most of the overall color if it's not zero. */
796 const float3 Favg = all(equal(transmission_tint, float3(0.0f))) ? F0 + (F90 - F0) / 21.0f :
798
799 float3 scale = 1.0f / (1.0f - Ems * Favg);
800 reflectance *= scale;
801 transmittance *= scale;
802 }
803}
804
805/* Computes the reflectance and transmittance based on the BSDF LUT. */
807 KernelGlobals &kg, float cos_theta, float roughness, float ior, bool do_multiscatter)
808{
809 float F0 = F0_from_ior(ior);
810 float3 color = float3(1.0f);
811 float3 reflectance, transmittance;
812 bsdf_lut(kg,
813 float3(F0),
814 color,
815 color,
816 cos_theta,
817 roughness,
818 ior,
819 do_multiscatter,
820 reflectance,
821 transmittance);
822 return float2(reflectance.r, transmittance.r);
823}
824
826 float3 F0,
827 float3 F90,
828 float cos_theta,
829 float roughness,
830 bool do_multiscatter)
831{
834 kg.util_tx, cos_theta, roughness);
835
836 return do_multiscatter ? F_brdf_multi_scatter(F0, F90, lut) :
837 F_brdf_single_scatter(F0, F90, lut);
838 }
839 return float3(0.0f);
840}
841
842/* -------------------------------------------------------------------- */
848
850{
851 const eevee::Uniform &uni = kg.uniforms;
852 return uni.uniform_buf.film.texture_lod_bias;
853}
854
862{
863 const eevee::Uniform &uni = kg.uniforms;
864 return 1.0f / float(uni.uniform_buf.film.scaling_factor);
865}
866
868
869/* -------------------------------------------------------------------- */
876
877#if defined(MAT_DISPLACEMENT_BUMP) || defined(GLSL_CPP_STUBS)
878/* Return new shading normal. */
880{
881 if (!kg.pipe.is_curves) [[static_branch]] {
882 /* This is the filter width for automatic displacement + bump mapping, which is fixed.
883 * NOTE: keep the same as default bump node filter width. */
884 constexpr float bump_filter_width = 0.1f;
885
886 float2 dHd;
887 dF_branch(dot(nodetree_displacement(kg, sd), sd.N + dF_impl(sd.N)), bump_filter_width, dHd);
888
891
892 /* Get surface tangents from normal. */
893 float3 Rx = cross(dPdy, sd.N);
894 float3 Ry = cross(sd.N, dPdx);
895
896 /* Compute surface gradient and determinant. */
897 float det = dot(dPdx, Rx);
898
899 float3 surfgrad = dHd.x * Rx + dHd.y * Ry;
900
901 float facing = FrontFacing ? 1.0f : -1.0f;
902 return normalize(bump_filter_width * abs(det) * sd.N - facing * sign(det) * surfgrad);
903 }
904 else {
905 return sd.N;
906 }
907}
908#endif
909
910void fragment_displacement([[maybe_unused]] KernelGlobals &kg, [[maybe_unused]] ShadingData &sd)
911{
912#ifdef MAT_DISPLACEMENT_BUMP
913 sd.N = displacement_bump(kg, sd);
914#endif
915}
916
918
919/* -------------------------------------------------------------------- */
925
932
934{
935 const ViewMatrices view = kg.view_matrices_get(sd);
936
937 Coordinates coords = {};
938
939 if (false /* Probe. */) {
940 /* Unsupported. It would make the probe camera-dependent. */
941 coords.camera = P;
942 coords.screen.xy = float2(0.5f);
943 }
944 else {
945 const eevee::Uniform &uni = kg.uniforms;
946 const CameraData cam = uni.uniform_buf.camera;
947 const ViewMatrices camera_matrices = kg.camera_matrices_get(sd);
948 if (kg.pipe.is_world) [[static_branch]] {
949 coords.camera = camera_matrices.normal_world_to_view(P);
950 if (is_panoramic(cam.type)) {
951 coords.screen.xy = eevee::camera::uv_from_world(cam, P) * cam.uv_scale + cam.uv_bias;
952 }
953 else {
954 coords.screen.xy = view.point_world_to_screen(P + view.position()).xy;
955 coords.screen.xy = coords.screen.xy * cam.uv_scale + cam.uv_bias;
956 }
957 }
958 else {
959 coords.camera = camera_matrices.point_world_to_view(P);
960 if (is_panoramic(cam.type)) {
961 /* Panoramic camera render through per-face sub-views.
962 * Can't use `view` here because that's only one sub-view, not the camera. */
963 float3 dir = P - cam.viewinv[3].xyz;
964 coords.screen.xy = eevee::camera::uv_from_world(cam, dir) * cam.uv_scale + cam.uv_bias;
965 }
966 else {
967 const ViewMatrices view = kg.view_matrices_get(sd);
968 coords.screen.xy = view.point_world_to_screen(P).xy;
969 coords.screen.xy = coords.screen.xy * cam.uv_scale + cam.uv_bias;
970 }
971 }
972 }
973 coords.camera.z = -coords.camera.z;
974
975 if (kg.pipe.is_world) [[static_branch]] {
976 coords.reflect = N;
977 coords.incoming = -P;
978 }
979 else {
980 coords.reflect = -reflect(view.world_incident_vector(P), N);
981 coords.incoming = view.world_incident_vector(P);
982 }
983 return coords;
984}
985
987
988/* -------------------------------------------------------------------- */
995
996/* Point clouds and curves and splats are not compatible with volume grids.
997 * They will fall back to their own attributes loading. */
998
1000{
1001 if (kg.pipe.is_volume_pipe) [[static_branch]] {
1002 const draw::Volume &vol = kg.volume;
1003 /* Bring the value into standard range without having to modify the grid values */
1004 attr = (attr > 0.01f) ?
1006 0.0f;
1007 }
1008 return attr;
1009}
1011{
1012 if (kg.pipe.is_volume_pipe) [[static_branch]] {
1013 const draw::Volume &vol = kg.volume;
1014 /* Density is premultiplied for interpolation, divide it out here. */
1015 attr.rgb *= safe_rcp(attr.a);
1016 attr.rgb *= vol.drw_volume.color_mul.rgb;
1017 attr.a = 1.0f;
1018 }
1019 return attr;
1020}
1021
1023
1024/* -------------------------------------------------------------------- */
1031
1033 const ShadingData &sd,
1034 float4 /*attr*/,
1035 const uint attr_hash)
1036{
1037 const draw::Attributes &ob_attributes = kg.ob_attr;
1038 return ob_attributes.get(kg.object_infos_get(sd), attr_hash);
1039}
1040
1042{
1043 const draw::ViewLayerAttributes &vl_attributes = kg.vl_attr;
1044 return vl_attributes.get(attr_hash);
1045}
1046
1047void scene_time_uniforms(KernelGlobals &kg, float &seconds, float &frame)
1048{
1049 const eevee::Uniform &uni = kg.uniforms;
1050
1051 seconds = uni.uniform_buf.scene.time;
1052 frame = uni.uniform_buf.scene.frame;
1053}
1054
1056 const ShadingData &sd,
1058{
1060#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1061 const ViewMatrices view = kg.view_matrices_get(sd);
1062 const float3 forward = view.forward();
1063 const float linear_view_z = dot(forward, sd.P) - dot(forward, view.position());
1064 iter.init(
1065 kg.lrd, sd.frag_co.xy, linear_view_z, receiver_light_set_get(kg.object_infos_get(sd)));
1066#endif
1067 }
1068}
1069
1071{
1073#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1074 return iter.next(kg.lrd);
1075#endif
1076 }
1077 return false;
1078}
1079
1081{
1083#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1084 return iter.should_skip(kg.lrd, P);
1085#endif
1086 }
1087 return true;
1088}
1089
1090#if (defined(GPU_FRAGMENT_SHADER) && defined(SRT_CONSTANT_use_lighting_nodes)) || \
1091 defined(GLSL_CPP_STUBS)
1092
1093# define LIGHT_ITER_BEGIN(light_index) \
1094 { \
1095 eevee_light_VisibleLightIterator iter; \
1096 light_iter_init(kg, sd, iter); \
1097 while (light_iter_next(kg, iter)) { \
1098 if (light_iter_should_skip(kg, iter, sd.P)) { \
1099 continue; \
1100 } \
1101 light_index = iter.index;
1102
1103#else
1104
1105/* Avoid double definition warning (GPU_SHADER_CREATE_INFO shenanigans). */
1106# ifdef LIGHT_ITER_BEGIN
1107# undef LIGHT_ITER_BEGIN
1108# endif
1109
1110# define LIGHT_ITER_BEGIN(light_index) \
1111 { \
1112 if (false) {
1113
1114#endif
1115
1116#define LIGHT_ITER_END() \
1117 } \
1118 }
1119
1121 KernelGlobals &kg, const int light_index, float4 &color, float &power, float3 &position)
1122{
1124 const eevee::LightRenderData &lrd = kg.lrd;
1125 const draw::Model &models = kg.model;
1126
1127 LightData light = lrd.light_buf[light_index];
1128
1129 color = float4(light.color, 1.0f);
1130 /* Pre-divide power by PI,
1131 * so users get a closer match to physically correct energy by default. */
1132 power = light.point_power * M_1_PI;
1133 /* Retrieve the data from the draw manager matrix, since Sun lights object_to_world doesn't
1134 * store the actual position. */
1135 position = models.get(light.resource_id).model[3].xyz;
1136 }
1137}
1138
1140 int light_index,
1142 float3 &direction,
1143 float &distance,
1144 float &mask)
1145{
1147 const eevee::LightRenderData &lrd = kg.lrd;
1148
1149 LightData light = lrd.light_buf[light_index];
1150 const bool is_directional = (light.type == LIGHT_SUN) || (light.type == LIGHT_SUN_ORTHO);
1151 LightVector lv = LightVector::get(light, is_directional, position);
1152
1153 direction = lv.L;
1154 distance = lv.dist;
1155 mask = light_attenuation_surface(light, is_directional, lv);
1156 }
1157}
1158
1159template<bool use_diffuse>
1161 const ShadingData &sd,
1162 int light_index,
1164 float3 normal,
1165 float roughness,
1166 float &factor)
1167{
1169 const eevee::LightRenderData &lrd = kg.lrd;
1170 UtilityTexture &util_tx = kg.util_tx;
1171
1172 LightData light = lrd.light_buf[light_index];
1173 const bool is_directional = (light.type == LIGHT_SUN) || (light.type == LIGHT_SUN_ORTHO);
1174 LightVector lv = LightVector::get(light, is_directional, position);
1175 LightShape light_shape_vertices = LightShape::get(light, lv);
1176
1177 const ViewMatrices view = kg.view_matrices_get(sd);
1178 const float3 V = view.world_incident_vector(position);
1179
1180 /* TODO(not_mark): remove, and update tests as this causes precision change. */
1181 eevee::LTCData ltc_data;
1182 if constexpr (use_diffuse) {
1183 ltc_data = eevee::LTCData::identity(normal, V);
1184 }
1185 else {
1186 ltc_data = eevee::LTCData::sample_ltc_lut(util_tx, normal, V, dot(normal, V), roughness);
1187 }
1188 factor = eevee::ltc::evaluate(util_tx.utility_tx, light, light_shape_vertices, lv, ltc_data);
1189
1190 factor *= light.shape_power;
1191 /* Remove the base power (exposed in Light Info).
1192 * The goal is to get a somewhat normalized factor. */
1193 factor /= (light.point_power * M_1_PI);
1194 }
1195}
1196
1198 KernelGlobals &, const ShadingData &, int, float3, float3, float, float &);
1199
1201 KernelGlobals &, const ShadingData &, int, float3, float3, float, float &);
1202
1204 const ShadingData &sd,
1205 const int light_index,
1207 float softness,
1208 float4 &color)
1209{
1211 color = float4(1.0f);
1212
1213#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1214 LightData light = kg.lrd.light_buf[light_index];
1215
1216 if (light.tilemap_index == LIGHT_NO_SHADOW) {
1217 return;
1218 }
1219
1220 int ray_count = kg.uniforms.uniform_buf.shadow.ray_count;
1221 int ray_step_count = kg.uniforms.uniform_buf.shadow.step_count;
1222
1223 ObjectInfos object_infos = kg.object_infos_get(sd);
1224
1225 float shadow = eevee::shadow_eval(kg.srd,
1226 light,
1227 (light.type == LIGHT_SUN) || (light.type == LIGHT_SUN_ORTHO),
1228 false,
1229 false,
1230 sd.frag_co.xy,
1231 sd.thickness,
1232 position,
1233 sd.Ng,
1234 sd.N,
1237 softness,
1238 ray_count,
1239 ray_step_count);
1240
1241 color.rgb = float3(shadow);
1242#endif
1243 }
1244}
1245
1247 const int light_index,
1248 uint attr_hash)
1249{
1250 if (kg.pipe.use_lighting_nodes) [[static_branch]] {
1251 LightData light = kg.lrd.light_buf[light_index];
1252 return kg.ob_attr.get(kg.infos.get(light.resource_id), attr_hash);
1253 }
1254 return float4(0.0f);
1255}
1256
1257bool node_attribute_light_is_sun_impl(KernelGlobals &kg, const int light_index)
1258{
1260 LightData light = kg.lrd.light_buf[light_index];
1261 return is_sun_light(light.type);
1262 }
1263 return false;
1264}
1265
1267{
1269 LightData light = kg.lrd.light_buf[light_index];
1270 return is_point_light(light.type) && !is_spot_light(light.type);
1271 }
1272 return false;
1273}
1274
1275bool node_attribute_light_is_spot_impl(KernelGlobals &kg, const int light_index)
1276{
1278 LightData light = kg.lrd.light_buf[light_index];
1279 return is_spot_light(light.type);
1280 }
1281 return false;
1282}
1283
1284bool node_attribute_light_is_area_impl(KernelGlobals &kg, const int light_index)
1285{
1287 LightData light = kg.lrd.light_buf[light_index];
1288 return is_area_light(light.type);
1289 }
1290 return false;
1291}
1292
1294{
1296 LightData light = kg.lrd.light_buf[light_index];
1297 if (is_sun_light(light.type)) {
1298 return 1e20f;
1299 }
1300 return inversesqrt(light.local.local.influence_radius_invsqr_surface);
1301 }
1302 return 1.0f;
1303}
1304
1306 ShadingData &sd,
1307 const int light_index,
1308 float3 diffuse_light,
1309 float3 diffuse_color,
1310 float3 glossy_light,
1311 float3 glossy_color,
1312 float3 transmission_light,
1313 float3 transmission_color,
1314 float weight,
1315 Closure &result)
1316{
1317#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1319 LightData light = kg.lrd.light_buf[light_index];
1320 float3 diffuse_color_weight = diffuse_color * weight;
1321 float3 glossy_color_weight = glossy_color * weight;
1322 float3 transmission_color_weight = transmission_color * weight;
1323 sd.light_accum.diffuse_light += diffuse_color_weight * diffuse_light *
1324 light.power_factor[LIGHT_DIFFUSE];
1325 sd.light_accum.glossy_light += glossy_color_weight * glossy_light *
1326 light.power_factor[LIGHT_SPECULAR];
1327 sd.light_accum.transmission_light += transmission_color_weight * transmission_light *
1328 light.power_factor[LIGHT_TRANSMISSION];
1329 sd.light_accum.diffuse_color += diffuse_color_weight;
1330 sd.light_accum.glossy_color += glossy_color_weight;
1331 sd.light_accum.transmission_color += transmission_color_weight;
1333 }
1334#endif
1335
1336 result = Closure(0);
1337}
1338
1340
1342 int2 texel,
1343 float4 color,
1344 float value,
1345 uint hash,
1346 float holdout,
1347 eObjectInfoFlag ob_flag)
1348{
1349#if defined(GPU_FRAGMENT_SHADER) || defined(GLSL_CPP_STUBS)
1350 if (kg.pipe.use_aov_output) [[static_branch]] {
1351 const RenderBuffersInfoData &render_pass = kg.uniforms.uniform_buf.render_pass;
1352
1353 uint total_len = render_pass.aovs.color_len + render_pass.aovs.value_len;
1354
1355 /* Search hashes in uint4 packs with 4 comparisons to find the index of a matching AOV hash. */
1356 uint hash_index;
1357 for (hash_index = 0u; hash_index < AOV_MAX && hash_index < total_len; hash_index += 4u) {
1358 bool4 cmp_mask = equal(render_pass.aovs.hash[hash_index >> 2u], uint4(hash));
1359 if (any(cmp_mask)) {
1360 /* Left-reduce `cmp_mask` to find the index of the matching AOV hash. */
1361 hash_index += (cmp_mask[0] ? 0u : (cmp_mask[1] ? 1u : (cmp_mask[2] ? 2u : 3u)));
1362 break;
1363 }
1364 }
1365
1366 /* If a candidate was found by hash, output to texture array layer. */
1367 if (hash_index < total_len) {
1368 /* Object holdout. */
1369 if (flag_test(ob_flag, OBJECT_HOLDOUT)) {
1370 holdout = 1.0f;
1371 }
1372 holdout = saturate(holdout);
1373
1374 /* Value hashes are stored after color hashes, so the index tells us the AOV type. */
1375 bool is_value = hash_index >= uint(render_pass.aovs.color_len);
1376 uint aov_index = hash_index - (is_value ? render_pass.aovs.color_len : 0u);
1377
1378 /* Apply holdout to relevant AOV type. */
1379 float4 out_aov = is_value ? float4(value) : color;
1380 out_aov *= 1.0f - holdout;
1381
1383 if (is_value) {
1384 rp_out.store_value(texel, int(render_pass.value_len + aov_index), out_aov.r);
1385 }
1386 else {
1387 rp_out.store_color(texel, int(render_pass.color_len + aov_index), out_aov);
1388 }
1389 }
1390 }
1391#endif
1392}
#define M_1_PI
ccl_device_inline float cos_theta(const float3 w)
transmission_tint
ccl_device_forceinline float3 dPdx(const ccl_private ShaderData *sd)
ccl_device_forceinline float3 dPdy(const ccl_private ShaderData *sd)
uint receiver_light_set_get(ObjectInfos object_infos)
@ OBJECT_HOLDOUT
#define OBJECT_ID_TEX_SLOT
#define RAYCAST_DEPTH_TEX_SLOT
#define PREPASS_NORMAL_TEX_SLOT
#define UTIL_BLUE_NOISE_LAYER
float light_attenuation_surface(LightData light, const bool is_directional, LightVector lv)
#define LIGHT_NO_SHADOW
void closure_select(Reservoir< ClosureUndetermined > &reservoir, ClosureUndetermined candidate)
ClosureType closure_type_get(ClosureDiffuse)
float3 nodetree_displacement(KernelGlobals &, ShadingData &)
template float3 F_brdf_single_scatter< eevee::lut::GGXBrdfData >(float3, float3, eevee::lut::GGXBrdfData)
float4 node_attribute_light_impl(KernelGlobals &kg, const int light_index, uint attr_hash)
bool light_iter_next(KernelGlobals &kg, eevee::light::VisibleLightIterator &iter)
void fragment_displacement(KernelGlobals &kg, ShadingData &sd)
void output_aov(KernelGlobals &kg, int2 texel, float4 color, float value, uint hash, float holdout, eObjectInfoFlag ob_flag)
float4 attr_load_uniform(KernelGlobals &kg, const ShadingData &sd, float4, const uint attr_hash)
float attr_load_temperature_post(KernelGlobals &kg, float attr)
void raycast_eval(KernelGlobals &kg, const ShadingData &sd, float3 position, float3 direction, float max_distance, bool self_only, bool &is_hit, bool &self_hit, float &hit_distance, float3 &hit_position, float3 &hit_normal)
template float3 F_brdf_multi_scatter< eevee::lut::GGXBrdfData >(float3, float3, eevee::lut::GGXBrdfData)
void scene_time_uniforms(KernelGlobals &kg, float &seconds, float &frame)
float texture_lod_bias_get(KernelGlobals &kg)
void node_shadow_raycast_impl(KernelGlobals &kg, const ShadingData &sd, const int light_index, float3 position, float softness, float4 &color)
Closure closure_mix(Closure, Closure, float)
bool node_attribute_light_is_sun_impl(KernelGlobals &kg, const int light_index)
bool node_attribute_light_is_point_impl(KernelGlobals &kg, const int light_index)
void light_iter_init(KernelGlobals &kg, const ShadingData &sd, eevee::light::VisibleLightIterator &iter)
float derivative_scale_get(KernelGlobals &kg)
Closure closure_add(Closure, Closure)
float F0_from_f0(float f0)
bool node_attribute_light_is_spot_impl(KernelGlobals &kg, const int light_index)
void closure_weights_reset(KernelGlobals &kg, ShadingData &sd, float closure_rand)
void node_light_info_impl(KernelGlobals &kg, const int light_index, float4 &color, float &power, float3 &position)
template float3 F_brdf_multi_scatter< eevee::lut::GGXBsdfData >(float3, float3, eevee::lut::GGXBsdfData)
float3 brdf_lut(KernelGlobals &kg, float3 F0, float3 F90, float cos_theta, float roughness, bool do_multiscatter)
float ambient_occlusion_eval(const KernelGlobals &kg, const ShadingData &sd, float3 normal, float max_distance, const float inverted, const float sample_count)
void node_light_evaluation_impl(KernelGlobals &kg, const ShadingData &sd, int light_index, float3 position, float3 normal, float roughness, float &factor)
float3 F_brdf_multi_scatter(float3 f0, float3 f90, T lut)
void node_light_evaluation_common_impl(KernelGlobals &kg, int light_index, float3 position, float3 &direction, float &distance, float &mask)
void bsdf_lut(KernelGlobals &kg, float3 F0, float3 F90, float3 transmission_tint, float cos_theta, float roughness, float ior, bool do_multiscatter, float3 &reflectance, float3 &transmittance)
bool node_attribute_light_is_area_impl(KernelGlobals &kg, const int light_index)
void brdf_f82_tint_lut(KernelGlobals &kg, float3 F0, float3 F82, float cos_theta, float roughness, bool do_multiscatter, float3 &reflectance)
float3 displacement_bump(KernelGlobals &kg, ShadingData &sd)
void node_light_accumulation_impl(KernelGlobals &kg, ShadingData &sd, const int light_index, float3 diffuse_light, float3 diffuse_color, float3 glossy_light, float3 glossy_color, float3 transmission_light, float3 transmission_color, float weight, Closure &result)
float3 F_brdf_single_scatter(float3 f0, float3 f90, T lut)
float4 attr_load_color_post(KernelGlobals &kg, float4 attr)
void closure_base_copy(ClosureUndetermined &cl, T in_cl)
float4 node_attribute_layer_impl(KernelGlobals &kg, const uint attr_hash)
float F0_from_ior(float eta)
Coordinates coordinate_impl(KernelGlobals &kg, const ShadingData &sd, float3 P, float3 N)
bool light_iter_should_skip(KernelGlobals &kg, eevee::light::VisibleLightIterator &iter, float3 P)
Closure closure_eval(KernelGlobals &kg, ShadingData &sd, ClosureDiffuse diffuse)
float4 closure_to_rgba(KernelGlobals &kg, ShadingData &sd, Closure cl)
float f0_from_ior(float eta)
float node_attribute_light_cutoff_distance_impl(KernelGlobals &kg, const int light_index)
template float3 F_brdf_single_scatter< eevee::lut::GGXBsdfData >(float3, float3, eevee::lut::GGXBsdfData)
bool clip_ray(float3 &start, float3 &end, const float3 direction, const float max_distance, const float4 frustum_planes[6])
float raytrace_screen_2(ViewMatrices view, const float3 vs_origin, const float3 vs_end, const float3 vs_direction, sampler2D depth_tx, const RayTraceData rt_data, const int max_steps, const float jitter, usampler2D ob_id_tx, const uint object_id, float2 &r_hit_uv)
#define assert(assertion)
#define position
#define capacity(const)
#define resource_table
#define sampler(slot)
#define static_branch
#define condition(cond)
T fract(T) RET
bool any(VecOp< bool, D >) RET
T gpu_dfdx(T) RET
VecBase< T, D > reflect(VecOp< T, D >, VecOp< T, D >) RET
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
constexpr T sign(T) RET
constexpr T inversesqrt(T) RET
#define abs
float distance(float, float) RET
VecBase< uint, D > floatBitsToUint(VecOp< float, D >) RET
bool all(VecOp< bool, D >) RET
T gpu_dfdy(T) RET
VecBase< float, D > uintBitsToFloat(VecOp< uint, D >) RET
VecBase< float, 3 > cross(VecOp< float, 3 >, VecOp< float, 3 >) RET
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET
TEX_TEMPLATE DataVec texture(T, FltCoord, float=0.0f) RET
TEX_TEMPLATE DataVec texelFetch(T, IntCoord, int) RET
SamplerBase< float, 2 > sampler2D
TEX_TEMPLATE SizeVec textureSize(T, int) RET
SamplerBase< uint, 2 > usampler2D
unsigned int uchar
float2 packed_float2
VecBase< bool, 4 > bool4
float noise(float p)
float square(float v)
float3x3 scale(float3x3 mat, float2 scale)
float safe_rcp(float a)
bool flag_test(uint flag, uint val)
@ LIGHT_SUN
ccl_device_inline float2 power(const float2 v, const float e)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
ccl_device_inline float3x3 inverted(const float3x3 m)
#define N
#define T
float2 uv_from_world(CameraData cam, float3 P)
template float eval< float >(const Uniform &, const ViewMatrices, ScreenThicknessParameters, sampler2D, sampler2D, sampler2D, float3, float3, float4, float2, float, float, int, int, bool, bool)
float evaluate(sampler2DArray util_tx, LightData light, LightShape shape, LightVector lv, LTCData ltc_data)
float shadow_eval(ShadowRenderData &srd, LightData light, const bool is_directional, const bool is_transmission, bool is_translucent_with_thickness, float2 frag_co, Thickness thickness, float3 P, float3 Ng, float3 N, float terminator_normal_offset, float terminator_geometry_offset, float soft_shadow_scale, int ray_count, int ray_step_count)
float interleaved_gradient(float2 pixel, float seed, float offset)
#define hash
Definition noise_c.cc:156
#define mix
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
#define saturate(a)
Definition smaa.cc:319
ViewMatrices view_matrices_get(const ShadingData &sd)
eevee::RenderPassOutput renderpass_out
uint resource_id_get(const ShadingData &sd)
ViewMatrices camera_matrices_get(const ShadingData &)
ObjectMatrices light_matrices_get(int light_index)
draw::Attributes ob_attr
eevee::LightprobePlaneRenderData lightprobe_planes
ObjectMatrices object_matrices_get(const ShadingData &sd)
eevee::PipelineConstants pipe
eevee::PreviousLayerHiZ previous_layer_hiz
ObjectInfos object_infos_get(const ShadingData &sd)
eevee::PreviousLayerRadiance previous_layer_radiance
eevee::ShadowRenderData srd
eevee::LightEvalIterator light_eval
eevee::LightprobeRenderData lightprobes
draw::ViewCulling view_culling
eevee::LightRenderData lrd
eevee::Sampling sampling
uint view_id_get(const ShadingData &sd)
draw::ViewLayerAttributes vl_attr
static LightShape get(LightData light, LightVector lv)
static LightVector get(LightData light, const bool is_directional, float3 P)
float shadow_terminator_normal_offset
float shadow_terminator_geometry_offset
Reservoir< ClosureUndetermined > closure_get(const eevee::PipelineConstants &pipe, uchar i) const
packed_float3 barycentric_dists
packed_float2 barycentric_coords
packed_float3 transmittance
packed_float3 curve_N
ClosureUndetermined closure_get_resolved(const eevee::PipelineConstants &pipe, uchar i, float additional_weight) const
packed_float3 volume_absorption
packed_float3 curve_T
packed_float3 emission
Reservoir< ClosureUndetermined > closure_bins[3]
LightAccumulation light_accum
packed_float3 curve_B
packed_float3 point_position
packed_float3 volume_scattering
sampler2DArray utility_tx
float4 fetch(float2 texel, float layer) const
struct FrustumPlanes frustum_planes
float3 point_world_to_view(float3 P) const
float3 forward() const
float depth_screen_to_view(float ss_depth) const
float depth_view_to_screen(float v_depth) const
float3 position() const
float3 world_incident_vector(float3 P) const
float3 point_world_to_screen(float3 vP) const
float4 get(ObjectInfos infos, const uint attr_hash) const
uint view_id() const
uint resource_id() const
ObjectInfos get(uint resource_id) const
ObjectMatrices get(uint resource_id) const
ViewCullingData get(uint view_id) const
float4 get(const uint attr_hash) const
ViewMatrices get(uint view_id) const
VolumeInfos & drw_volume
sampler2D hiz_tx
static LTCData identity(float3 N, float3 V)
static LTCData sample_ltc_lut(const UtilityTexture &util_tx, float3 N, float3 V, float cos_theta, float roughness)
const LightData(& light_buf)[]
void store_value(int2 texel, int id, float value)
void store_color(int2 texel, int id, float4 color)
float3 rng_3D_get(const eSamplingDimension dim) const
float rng_1D_get(const eSamplingDimension dim) const
const RayTraceData & raytrace_buf
const UniformData & uniform_buf
const PipelineInfoData & pipeline_buf
bool should_skip(const eevee::LightRenderData &lrd, float3 P)
void init(const eevee::LightRenderData &lrd, float2 pixel, float linear_view_z, uint receiver_light_set)
bool next(const eevee::LightRenderData &lrd)
static GGXBrdfData sample_utility_tx(const UtilityTexture &util_tx, float cos_theta, float roughness)
static GGXBsdfData sample_utility_tx(const UtilityTexture &util_tx, float cos_theta, float roughness, float ior)
static GGXBtdfGt1Data sample_utility_tx(const UtilityTexture &util_tx, float cos_theta, float roughness, float f0)
float x
float y
float z
Definition sky_math.h:136
CCL_NAMESPACE_BEGIN struct Window V