Blender V4.3
eevee_shader_shared.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11#ifndef USE_GPU_SHADER_CREATE_INFO
12# pragma once
13
14# include "BLI_math_bits.h"
15# include "BLI_memory_utils.hh"
16
17# include "DRW_gpu_wrapper.hh"
18
19# include "draw_manager.hh"
20# include "draw_pass.hh"
21
22# include "eevee_defines.hh"
23
24# include "GPU_shader_shared.hh"
25
26namespace blender::eevee {
27
28class ShadowDirectional;
29class ShadowPunctual;
30
31using namespace draw;
32
35#endif
36
37/* __cplusplus is true when compiling with MSL, so ensure we are not inside a shader. */
38#ifdef GPU_SHADER
39# define IS_CPP 0
40#else
41# define IS_CPP 1
42#endif
43
45#ifndef M_PI
46# define EEVEE_PI
47# define M_PI 3.14159265358979323846 /* pi */
48#endif
49
51 /* Ordering by culling order. If cone aperture is shallow, we cull the later view. */
52 Z_NEG = 0u,
53 X_POS = 1u,
54 X_NEG = 2u,
55 Y_POS = 3u,
56 Y_NEG = 4u,
57 Z_POS = 5u,
58};
59
60/* -------------------------------------------------------------------- */
64struct Transform {
65 /* The transform is stored transposed for compactness. */
67#if IS_CPP
68 Transform() = default;
70 : x(tx[0][0], tx[1][0], tx[2][0], tx[3][0]),
71 y(tx[0][1], tx[1][1], tx[2][1], tx[3][1]),
72 z(tx[0][2], tx[1][2], tx[2][2], tx[3][2])
73 {
74 }
75
76 operator float4x4() const
77 {
78 return float4x4(float4(x.x, y.x, z.x, 0.0f),
79 float4(x.y, y.y, z.y, 0.0f),
80 float4(x.z, y.z, z.z, 0.0f),
81 float4(x.w, y.w, z.w, 1.0f));
82 }
83#endif
84};
85
87{
88 return float4x4(float4(t.x.x, t.y.x, t.z.x, 0.0f),
89 float4(t.x.y, t.y.y, t.z.y, 0.0f),
90 float4(t.x.z, t.y.z, t.z.z, 0.0f),
91 float4(t.x.w, t.y.w, t.z.w, 1.0f));
92}
93
95{
96 Transform t;
97 t.x = float4(m[0][0], m[1][0], m[2][0], m[3][0]);
98 t.y = float4(m[0][1], m[1][1], m[2][1], m[3][1]);
99 t.z = float4(m[0][2], m[1][2], m[2][2], m[3][2]);
100 return t;
101}
102
104{
105 return float3(t.x.x, t.y.x, t.z.x);
106}
108{
109 return float3(t.x.y, t.y.y, t.z.y);
110}
112{
113 return float3(t.x.z, t.y.z, t.z.z);
114}
116{
117 return float3(t.x.w, t.y.w, t.z.w);
118}
119
120#if !IS_CPP
121static inline bool transform_equal(Transform a, Transform b)
122{
123 return all(equal(a.x, b.x)) && all(equal(a.y, b.y)) && all(equal(a.z, b.z));
124}
125#endif
126
127static inline float3 transform_point(Transform t, float3 point)
128{
129 return float4(point, 1.0f) * float3x4(t.x, t.y, t.z);
130}
131
132static inline float3 transform_direction(Transform t, float3 direction)
133{
134 return direction * float3x3(float3(t.x.x, t.x.y, t.x.z),
135 float3(t.y.x, t.y.y, t.y.z),
136 float3(t.z.x, t.z.y, t.z.z));
137}
138
140{
141 return float3x3(float3(t.x.x, t.x.y, t.x.z),
142 float3(t.y.x, t.y.y, t.y.z),
143 float3(t.z.x, t.z.y, t.z.z)) *
144 direction;
145}
146
147/* Assumes the transform has unit scale. */
149{
150 return float3x3(float3(t.x.x, t.x.y, t.x.z),
151 float3(t.y.x, t.y.y, t.y.z),
152 float3(t.z.x, t.z.y, t.z.z)) *
153 (point - transform_location(t));
154}
155
158/* -------------------------------------------------------------------- */
214
217/* -------------------------------------------------------------------- */
228
231/* -------------------------------------------------------------------- */
266
271#define SAMPLING_DIMENSION_COUNT 32
272
273/* NOTE(@fclem): Needs to be used in #StorageBuffer because of arrays of scalar. */
276 float dimensions[SAMPLING_DIMENSION_COUNT];
277};
279
280/* Returns total sample count in a web pattern of the given size. */
281static inline int sampling_web_sample_count_get(int web_density, int in_ring_count)
282{
283 return ((in_ring_count * in_ring_count + in_ring_count) / 2) * web_density + 1;
284}
285
286/* Returns lowest possible ring count that contains at least sample_count samples. */
287static inline int sampling_web_ring_count_get(int web_density, int sample_count)
288{
289 /* Inversion of web_sample_count_get(). */
290 float x = 2.0f * (float(sample_count) - 1.0f) / float(web_density);
291 /* Solving polynomial. We only search positive solution. */
292 float discriminant = 1.0f + 4.0f * x;
293 return int(ceilf(0.5f * (sqrtf(discriminant) - 1.0f)));
294}
295
298/* -------------------------------------------------------------------- */
310
311static inline bool is_panoramic(eCameraType type)
312{
313 return type > CAMERA_ORTHO;
314}
315
317 /* View Matrices of the camera, not from any view! */
335 float clip_far;
339 float _pad0;
340 float _pad1;
341 float _pad2;
342
344
345#ifdef __cplusplus
346 /* Small constructor to allow detecting new buffers. */
348#endif
349};
351
352
354/* -------------------------------------------------------------------- */
358#define FILM_PRECOMP_SAMPLE_MAX 16
359
364
370
380
388
468
469static inline float film_filter_weight(float filter_radius, float sample_distance_sqr)
470{
471#if 1 /* Faster */
472 /* Gaussian fitted to Blackman-Harris. */
473 float r = sample_distance_sqr / (filter_radius * filter_radius);
474 const float sigma = 0.284;
475 const float fac = -0.5 / (sigma * sigma);
476 float weight = expf(fac * r);
477#else
478 /* Blackman-Harris filter. */
479 float r = M_TAU * saturate(0.5 + sqrtf(sample_distance_sqr) / (2.0 * filter_radius));
480 float weight = 0.35875 - 0.48829 * cosf(r) + 0.14128 * cosf(2.0 * r) - 0.01168 * cosf(3.0 * r);
481#endif
482 return weight;
483}
484
487/* -------------------------------------------------------------------- */
491/* Theoretical max is 128 as we are using texture array and VRAM usage.
492 * However, the output_aov() function perform a linear search inside all the hashes.
493 * If we find a way to avoid this we could bump this number up. */
494#define AOV_MAX 16
495
497 /* Use uint4 to workaround std140 packing rules.
498 * Only the x value is used. */
501 /* Length of used data. */
508};
510
532
533
535/* -------------------------------------------------------------------- */
539#define VELOCITY_INVALID 512.0
540
546
552
553#ifdef __cplusplus
554 VelocityObjectIndex() : ofs(-1, -1, -1), resource_id(-1){};
555#endif
556};
557BLI_STATIC_ASSERT_ALIGN(VelocityObjectIndex, 16)
558
569
570 int _pad0;
571
572#ifdef __cplusplus
573 VelocityGeometryIndex() : ofs(-1, -1, -1), do_deform(false), len(-1, -1, -1), _pad0(1){};
574#endif
575};
576BLI_STATIC_ASSERT_ALIGN(VelocityGeometryIndex, 16)
577
583
584
586/* -------------------------------------------------------------------- */
590#define MOTION_BLUR_TILE_SIZE 32
591#define MOTION_BLUR_MAX_TILE 512 /* 16384 / MOTION_BLUR_TILE_SIZE */
603
604/* For some reasons some GLSL compilers do not like this struct.
605 * So we declare it as a uint array instead and do indexing ourselves. */
606#ifdef __cplusplus
607struct MotionBlurTileIndirection {
614};
615BLI_STATIC_ASSERT_ALIGN(MotionBlurTileIndirection, 16)
616#endif
617
620/* -------------------------------------------------------------------- */
625 /* During object voxelization, we need to use an infinite projection matrix to avoid clipping
626 * faces. But they cannot be used for recovering the view position from froxel position as they
627 * are not invertible. We store the finite projection matrix and use it for this purpose. */
630 /* Copies of the matrices above but without jittering. Used for re-projection. */
633 /* Previous render sample copy of winmat_stable. */
635 /* Transform from current view space to previous render sample view space. */
637 /* Size of the froxel grid texture. */
639 /* Maximum light intensity during volume lighting evaluation. */
641 /* Inverse of size of the froxel grid. */
643 /* Maximum light intensity during volume lighting evaluation. */
645 /* 2D scaling factor to make froxel squared. */
647 /* Extent and inverse extent of the main shading view (render extent, not film extent). */
650 /* Size in main view pixels of one froxel in XY. */
652 /* Hi-Z LOD to use during volume shadow tagging. */
654 /* Depth to froxel mapping. */
658 /* Previous render sample copy of the depth mapping parameters. */
662 /* Amount of history to blend during the scatter phase. */
664
665 float _pad1;
666};
668
669
671/* -------------------------------------------------------------------- */
675/* 5% error threshold. */
676#define DOF_FAST_GATHER_COC_ERROR 0.05
677#define DOF_GATHER_RING_COUNT 5
678#define DOF_DILATE_RING_COUNT 3
679
714
724
725static inline float coc_radius_from_camera_depth(DepthOfFieldData dof, float depth)
726{
727 depth = (dof.camera_type != CAMERA_ORTHO) ? 1.0f / depth : depth;
728 return dof.coc_mul * depth + dof.coc_bias;
729}
730
731static inline float regular_polygon_side_length(float sides_count)
732{
733 return 2.0f * sinf(M_PI / sides_count);
734}
735
736/* Returns intersection ratio between the radius edge at theta and the regular polygon edge.
737 * Start first corners at theta == 0. */
738static inline float circle_to_polygon_radius(float sides_count, float theta)
739{
740 /* From Graphics Gems from CryENGINE 3 (SIGGRAPH 2013) by Tiago Sousa (slide 36). */
741 float side_angle = (2.0f * M_PI) / sides_count;
742 return cosf(side_angle * 0.5f) /
743 cosf(theta - side_angle * floorf((sides_count * theta + M_PI) / (2.0f * M_PI)));
744}
745
746/* Remap input angle to have homogenous spacing of points along a polygon edge.
747 * Expects theta to be in [0..2pi] range. */
748static inline float circle_to_polygon_angle(float sides_count, float theta)
749{
750 float side_angle = (2.0f * M_PI) / sides_count;
751 float halfside_angle = side_angle * 0.5f;
752 float side = floorf(theta / side_angle);
753 /* Length of segment from center to the middle of polygon side. */
754 float adjacent = circle_to_polygon_radius(sides_count, 0.0f);
755
756 /* This is the relative position of the sample on the polygon half side. */
757 float local_theta = theta - side * side_angle;
758 float ratio = (local_theta - halfside_angle) / halfside_angle;
759
760 float halfside_len = regular_polygon_side_length(sides_count) * 0.5f;
761 float opposite = ratio * halfside_len;
762
763 /* NOTE: atan(y_over_x) has output range [-M_PI_2..M_PI_2]. */
764 float final_local_theta = atanf(opposite / adjacent);
765
766 return side * side_angle + final_local_theta;
767}
768
771/* -------------------------------------------------------------------- */
775/* Number of items we can cull. Limited by how we store CullingZBin. */
776#define CULLING_MAX_ITEM 65536
777/* Fine grained subdivision in the Z direction. Limited by the LDS in z-binning compute shader. */
778#define CULLING_ZBIN_COUNT 4096
779/* Max tile map resolution per axes. */
780#define CULLING_TILE_RES 16
781
810
811
813/* -------------------------------------------------------------------- */
817#define LIGHT_NO_SHADOW -1
818
822 /* Point light. */
825 /* Spot light. */
828 /* Area light. */
830 LIGHT_ELLIPSE = 21u
832
838 /* WORKAROUND: Special value used to tag translucent BSDF with thickness.
839 * Fallback to LIGHT_DIFFUSE. */
841};
842
843static inline bool is_area_light(eLightType type)
844{
845 return type >= LIGHT_RECT;
846}
847
848static inline bool is_point_light(eLightType type)
849{
850 return type >= LIGHT_OMNI_SPHERE && type <= LIGHT_SPOT_DISK;
851}
852
853static inline bool is_spot_light(eLightType type)
854{
855 return type == LIGHT_SPOT_SPHERE || type == LIGHT_SPOT_DISK;
856}
857
858static inline bool is_sphere_light(eLightType type)
859{
860 return type == LIGHT_SPOT_SPHERE || type == LIGHT_OMNI_SPHERE;
861}
862
863static inline bool is_oriented_disk_light(eLightType type)
864{
865 return type == LIGHT_SPOT_DISK || type == LIGHT_OMNI_DISK;
866}
867
868static inline bool is_sun_light(eLightType type)
869{
870 return type < LIGHT_OMNI_SPHERE;
871}
872
873static inline bool is_local_light(eLightType type)
874{
875 return type >= LIGHT_OMNI_SPHERE;
876}
877
878/* Using define because GLSL doesn't have inheritance, and encapsulation forces us to add some
879 * unneeded padding. */
880#define LOCAL_LIGHT_COMMON \
881 \
882 \
883 packed_float3 shadow_position; \
884 float _pad0; \
885 \
886 float shadow_radius; \
887 \
888 float shape_radius; \
889 \
890 float influence_radius_max; \
891 \
892 float influence_radius_invsqr_surface; \
893 float influence_radius_invsqr_volume; \
894 \
895 int tilemaps_count;
896
897/* Untyped local light data. Gets reinterpreted to LightSpotData and LightAreaData.
898 * Allow access to local light common data without casting. */
901
902 float _pad1;
903 float _pad2;
904
906 float _pad4;
907 float _pad5;
908};
910
911/* Despite the name, is also used for omni light. */
925BLI_STATIC_ASSERT(sizeof(LightSpotData) == sizeof(LightLocalData), "Data size must match")
926
927struct LightAreaData {
929
930 float _pad2;
931 float _pad3;
932
934 float2 size;
936 float shadow_scale;
937 float _pad6;
938};
939BLI_STATIC_ASSERT(sizeof(LightAreaData) == sizeof(LightLocalData), "Data size must match")
940
941struct LightSunData {
942 /* Sun direction for shading. Use object_to_world for getting into shadow space. */
943 packed_float3 direction;
944 /* Radius of the sun disk, one unit away from a shading point. */
945 float shape_radius;
946
949 int2 clipmap_base_offset_neg;
950 int2 clipmap_base_offset_pos;
951
953 float shadow_angle;
954 float _pad5;
955 float _pad3;
956 float _pad4;
957
959 float2 clipmap_origin;
961 int clipmap_lod_min;
962 int clipmap_lod_max;
963};
964BLI_STATIC_ASSERT(sizeof(LightSunData) == sizeof(LightLocalData), "Data size must match")
965
966/* Enable when debugging. This is quite costly. */
967#define SAFE_UNION_ACCESS 0
968
969#if IS_CPP
970/* C++ always uses union. */
971# define USE_LIGHT_UNION 1
972#elif defined(GPU_BACKEND_METAL) && !SAFE_UNION_ACCESS
973/* Metal supports union, but force usage of the getters if SAFE_UNION_ACCESS is enabled. */
974# define USE_LIGHT_UNION 1
975#else
976/* Use getter functions on GPU if not supported or if SAFE_UNION_ACCESS is enabled. */
977# define USE_LIGHT_UNION 0
978#endif
979
980struct LightData {
986 Transform object_to_world;
987
993 eLightType type;
994
997 int clip_near;
998 int clip_far;
1000 int tilemap_index;
1001 /* Radius in pixels for shadow filtering. */
1002 float filter_radius;
1003
1004 /* Shadow Map resolution bias. */
1005 float lod_bias;
1006 /* Shadow Map resolution maximum resolution. */
1007 float lod_min;
1008 /* True if the light uses jittered soft shadows. */
1009 bool32_t shadow_jitter;
1010 float _pad2;
1011 uint2 light_set_membership;
1013 /* TODO(fclem): this should be part of #eevee::Light struct. But for some reason it gets cleared
1014 * to zero after each sync cycle. */
1015 uint2 shadow_set_membership;
1016
1017#if USE_LIGHT_UNION
1018 union {
1019 LightLocalData local;
1020 LightSpotData spot;
1021 LightAreaData area;
1022 LightSunData sun;
1023 };
1024#else
1025 /* Use `light_*_data_get(light)` to access typed data. */
1026 LightLocalData do_not_access_directly;
1027#endif
1028};
1030
1031static inline float3 light_x_axis(LightData light)
1032{
1033 return transform_x_axis(light.object_to_world);
1034}
1035static inline float3 light_y_axis(LightData light)
1036{
1037 return transform_y_axis(light.object_to_world);
1038}
1039static inline float3 light_z_axis(LightData light)
1040{
1041 return transform_z_axis(light.object_to_world);
1042}
1044{
1045 return transform_location(light.object_to_world);
1046}
1047
1048#ifdef GPU_SHADER
1049# define CHECK_TYPE_PAIR(a, b)
1050# define CHECK_TYPE(a, b)
1051# define FLOAT_AS_INT floatBitsToInt
1052# define INT_AS_FLOAT intBitsToFloat
1053# define TYPECAST_NOOP
1054
1055#else /* C++ */
1056# define FLOAT_AS_INT float_as_int
1057# define INT_AS_FLOAT int_as_float
1058# define TYPECAST_NOOP
1059#endif
1060
1061/* In addition to the static asserts that verify correct member assignment, also verify access on
1062 * the GPU so that only lights of a certain type can read for the appropriate union member.
1063 * Return cross platform garbage data as some platform can return cleared memory if we early exit.
1064 */
1065#if SAFE_UNION_ACCESS
1066# ifdef GPU_SHADER
1067/* Should result in a beautiful zebra pattern on invalid load. */
1068# if defined(GPU_FRAGMENT_SHADER)
1069# define GARBAGE_VALUE sin(gl_FragCoord.x + gl_FragCoord.y)
1070# elif defined(GPU_COMPUTE_SHADER)
1071# define GARBAGE_VALUE \
1072 sin(float(gl_GlobalInvocationID.x + gl_GlobalInvocationID.y + gl_GlobalInvocationID.z))
1073# else
1074# define GARBAGE_VALUE sin(float(gl_VertexID))
1075# endif
1076
1077/* Can be set to zero if zebra creates out-of-bound accesses and crashes. At least avoid UB. */
1078// # define GARBAGE_VALUE 0.0
1079
1080# else /* C++ */
1081# define GARBAGE_VALUE 0.0f
1082# endif
1083
1084# define SAFE_BEGIN(dst_type, src_type, src_, check) \
1085 src_type _src = src_; \
1086 dst_type _dst; \
1087 bool _validity_check = check; \
1088 float _garbage = GARBAGE_VALUE;
1089
1090/* Assign garbage value if the light type check fails. */
1091# define SAFE_ASSIGN_LIGHT_TYPE_CHECK(_type, _value) \
1092 (_validity_check ? (_value) : _type(_garbage))
1093#else
1094# define SAFE_BEGIN(dst_type, src_type, src_, check) \
1095 UNUSED_VARS(check); \
1096 src_type _src = src_; \
1097 dst_type _dst;
1098
1099# define SAFE_ASSIGN_LIGHT_TYPE_CHECK(_type, _value) _value
1100#endif
1101
1102#if USE_LIGHT_UNION
1103# define DATA_MEMBER local
1104#else
1105# define DATA_MEMBER do_not_access_directly
1106#endif
1107
1108#define SAFE_READ_BEGIN(dst_type, light, check) \
1109 SAFE_BEGIN(dst_type, LightLocalData, light.DATA_MEMBER, check)
1110#define SAFE_READ_END() _dst
1111
1112#define SAFE_WRITE_BEGIN(src_type, src, check) SAFE_BEGIN(LightLocalData, src_type, src, check)
1113#define SAFE_WRITE_END(light) light.DATA_MEMBER = _dst;
1114
1115#define ERROR_OFS(a, b) "Offset of " STRINGIFY(a) " mismatch offset of " STRINGIFY(b)
1116
1117/* This is a dangerous process, make sure to static assert every assignment. */
1118#define SAFE_ASSIGN(a, reinterpret_fn, in_type, b) \
1119 CHECK_TYPE_PAIR(_src.b, in_type(_dst.a)); \
1120 CHECK_TYPE_PAIR(_dst.a, reinterpret_fn(_src.b)); \
1121 _dst.a = reinterpret_fn(SAFE_ASSIGN_LIGHT_TYPE_CHECK(in_type, _src.b)); \
1122 BLI_STATIC_ASSERT(offsetof(decltype(_dst), a) == offsetof(decltype(_src), b), ERROR_OFS(a, b))
1123
1124#define SAFE_ASSIGN_FLOAT(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float, b);
1125#define SAFE_ASSIGN_FLOAT2(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float2, b);
1126#define SAFE_ASSIGN_FLOAT3(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float3, b);
1127#define SAFE_ASSIGN_INT(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, int, b);
1128#define SAFE_ASSIGN_FLOAT_AS_INT(a, b) SAFE_ASSIGN(a, FLOAT_AS_INT, float, b);
1129#define SAFE_ASSIGN_INT_AS_FLOAT(a, b) SAFE_ASSIGN(a, INT_AS_FLOAT, int, b);
1130
1131#if !USE_LIGHT_UNION || IS_CPP
1132
1133/* These functions are not meant to be used in C++ code. They are only defined on the C++ side for
1134 * static assertions. Hide them. */
1135# if IS_CPP
1136namespace do_not_use {
1137# endif
1138
1139static inline LightSpotData light_local_data_get_ex(LightData light, bool check)
1140{
1141 SAFE_READ_BEGIN(LightSpotData, light, check)
1142 SAFE_ASSIGN_FLOAT3(shadow_position, shadow_position)
1143 SAFE_ASSIGN_FLOAT(_pad0, _pad0)
1144 SAFE_ASSIGN_FLOAT(shadow_radius, shadow_radius)
1145 SAFE_ASSIGN_FLOAT(shape_radius, shape_radius)
1146 SAFE_ASSIGN_FLOAT(influence_radius_max, influence_radius_max)
1147 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
1148 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
1149 SAFE_ASSIGN_INT(tilemaps_count, tilemaps_count)
1150 SAFE_ASSIGN_FLOAT(spot_mul, _pad2)
1151 SAFE_ASSIGN_FLOAT2(spot_size_inv, _pad3)
1152 SAFE_ASSIGN_FLOAT(spot_tan, _pad4)
1153 SAFE_ASSIGN_FLOAT(spot_bias, _pad5)
1154 return SAFE_READ_END();
1155}
1156
1158{
1159 SAFE_WRITE_BEGIN(LightSpotData, spot_data, is_local_light(light.type))
1160 SAFE_ASSIGN_FLOAT3(shadow_position, shadow_position)
1161 SAFE_ASSIGN_FLOAT(_pad0, _pad0)
1162 SAFE_ASSIGN_FLOAT(shadow_radius, shadow_radius)
1163 SAFE_ASSIGN_FLOAT(shape_radius, shape_radius)
1164 SAFE_ASSIGN_FLOAT(influence_radius_max, influence_radius_max)
1165 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
1166 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
1167 SAFE_ASSIGN_INT(tilemaps_count, tilemaps_count)
1168 SAFE_ASSIGN_FLOAT(_pad2, spot_mul)
1169 SAFE_ASSIGN_FLOAT2(_pad3, spot_size_inv)
1170 SAFE_ASSIGN_FLOAT(_pad4, spot_tan)
1171 SAFE_ASSIGN_FLOAT(_pad5, spot_bias)
1172 SAFE_WRITE_END(light)
1173 return light;
1174}
1175
1177{
1178 return light_local_data_get_ex(light, is_local_light(light.type));
1179}
1180
1182{
1183 return light_local_data_get_ex(light, is_spot_light(light.type) || is_point_light(light.type));
1184}
1185
1186static inline LightAreaData light_area_data_get(LightData light)
1187{
1188 SAFE_READ_BEGIN(LightAreaData, light, is_area_light(light.type))
1189 SAFE_ASSIGN_FLOAT(shape_radius, shape_radius)
1190 SAFE_ASSIGN_FLOAT(influence_radius_max, influence_radius_max)
1191 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
1192 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
1193 SAFE_ASSIGN_FLOAT3(shadow_position, shadow_position)
1194 SAFE_ASSIGN_FLOAT(shadow_radius, shadow_radius)
1195 SAFE_ASSIGN_INT(tilemaps_count, tilemaps_count)
1196 SAFE_ASSIGN_FLOAT2(size, _pad3)
1197 SAFE_ASSIGN_FLOAT(shadow_scale, _pad4)
1198 return SAFE_READ_END();
1199}
1200
1201static inline LightSunData light_sun_data_get(LightData light)
1202{
1203 SAFE_READ_BEGIN(LightSunData, light, is_sun_light(light.type))
1204 SAFE_ASSIGN_FLOAT3(direction, shadow_position)
1205 SAFE_ASSIGN_FLOAT(shape_radius, _pad0)
1206 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_base_offset_neg.x, shadow_radius)
1207 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_base_offset_neg.y, shape_radius)
1208 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_base_offset_pos.x, influence_radius_max)
1209 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_base_offset_pos.y, influence_radius_invsqr_surface)
1210 SAFE_ASSIGN_FLOAT(shadow_angle, influence_radius_invsqr_volume)
1211 SAFE_ASSIGN_FLOAT2(clipmap_origin, _pad3)
1212 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_lod_min, _pad4)
1213 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_lod_max, _pad5)
1214 return SAFE_READ_END();
1215}
1216
1217static inline LightData light_sun_data_set(LightData light, LightSunData sun_data)
1218{
1219 SAFE_WRITE_BEGIN(LightSunData, sun_data, is_sun_light(light.type))
1220 SAFE_ASSIGN_FLOAT3(shadow_position, direction)
1221 SAFE_ASSIGN_FLOAT(_pad0, shape_radius)
1222 SAFE_ASSIGN_INT_AS_FLOAT(shadow_radius, clipmap_base_offset_neg.x)
1223 SAFE_ASSIGN_INT_AS_FLOAT(shape_radius, clipmap_base_offset_neg.y)
1224 SAFE_ASSIGN_INT_AS_FLOAT(influence_radius_max, clipmap_base_offset_pos.x)
1225 SAFE_ASSIGN_INT_AS_FLOAT(influence_radius_invsqr_surface, clipmap_base_offset_pos.y)
1226 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, shadow_angle)
1227 SAFE_ASSIGN_FLOAT2(_pad3, clipmap_origin)
1228 SAFE_ASSIGN_INT_AS_FLOAT(_pad4, clipmap_lod_min)
1229 SAFE_ASSIGN_INT_AS_FLOAT(_pad5, clipmap_lod_max)
1230 SAFE_WRITE_END(light)
1231 return light;
1232}
1233
1234# if IS_CPP
1235} // namespace do_not_use
1236# endif
1237
1238#endif
1239
1240#if USE_LIGHT_UNION
1241# define light_local_data_get(light) light.local
1242# define light_spot_data_get(light) light.spot
1243# define light_area_data_get(light) light.area
1244# define light_sun_data_get(light) light.sun
1245#endif
1246
1247#undef DATA_MEMBER
1248#undef GARBAGE_VALUE
1249#undef FLOAT_AS_INT
1250#undef TYPECAST_NOOP
1251#undef SAFE_BEGIN
1252#undef SAFE_ASSIGN_LIGHT_TYPE_CHECK
1253#undef ERROR_OFS
1254#undef SAFE_ASSIGN
1255#undef SAFE_ASSIGN_FLOAT
1256#undef SAFE_ASSIGN_FLOAT2
1257#undef SAFE_ASSIGN_INT
1258#undef SAFE_ASSIGN_FLOAT_AS_INT
1259#undef SAFE_ASSIGN_INT_AS_FLOAT
1260
1261static inline int light_tilemap_max_get(LightData light)
1262{
1263 /* This is not something we need in performance critical code. */
1264 if (is_sun_light(light.type)) {
1265 return light.tilemap_index +
1266 (light_sun_data_get(light).clipmap_lod_max - light_sun_data_get(light).clipmap_lod_min);
1267 }
1268 return light.tilemap_index + light_local_data_get(light).tilemaps_count - 1;
1269}
1270
1271/* Return the number of tilemap needed for a local light. */
1272static inline int light_local_tilemap_count(LightData light)
1273{
1274 if (is_spot_light(light.type)) {
1275 return (light_spot_data_get(light).spot_tan > tanf(M_PI / 4.0)) ? 5 : 1;
1276 }
1277 else if (is_area_light(light.type)) {
1278 return 5;
1279 }
1280 else {
1281 return 6;
1282 }
1283}
1284
1287/* -------------------------------------------------------------------- */
1305
1306static inline int2 shadow_cascade_grid_offset(int2 base_offset, int level_relative)
1307{
1308 return (base_offset * level_relative) / (1 << 16);
1309}
1310
1350
1351
1378
1379
1391 /* Transform the shadow is rendered with. Used to detect updates on GPU. */
1393 /* Integer offset of the center of the 16x16 tiles from the origin of the tile space. */
1397};
1399
1417
1436
1437
1455#define ShadowTileDataPacked uint
1456
1459 SHADOW_IS_CACHED = (1u << 27u),
1460 SHADOW_IS_ALLOCATED = (1u << 28u),
1461 SHADOW_DO_UPDATE = (1u << 29u),
1462 SHADOW_IS_RENDERED = (1u << 30u),
1463 SHADOW_IS_USED = (1u << 31u)
1465
1466/* NOTE: Trust the input to be in valid range (max is [3,3,255]).
1467 * If it is in valid range, it should pack to 12bits so that `shadow_tile_pack()` can use it.
1468 * But sometime this is used to encode invalid pages uint3(-1) and it needs to output uint(-1). */
1469static inline uint shadow_page_pack(uint3 page)
1470{
1471 return (page.x << 0u) | (page.y << 2u) | (page.z << 4u);
1472}
1473static inline uint3 shadow_page_unpack(uint data)
1474{
1475 uint3 page;
1476 BLI_STATIC_ASSERT(SHADOW_PAGE_PER_ROW <= 4 && SHADOW_PAGE_PER_COL <= 4, "Update page packing")
1477 page.x = (data >> 0u) & 3u;
1478 page.y = (data >> 2u) & 3u;
1479 BLI_STATIC_ASSERT(SHADOW_MAX_PAGE <= 4096, "Update page packing")
1480 page.z = (data >> 4u) & 255u;
1481 return page;
1482}
1483
1485{
1487 tile.page = shadow_page_unpack(data);
1488 /* -- 12 bits -- */
1489 /* Unused bits. */
1490 /* -- 15 bits -- */
1491 BLI_STATIC_ASSERT(SHADOW_MAX_PAGE <= 4096, "Update page packing")
1492 tile.cache_index = (data >> 15u) & 4095u;
1493 /* -- 27 bits -- */
1494 tile.is_used = (data & SHADOW_IS_USED) != 0;
1495 tile.is_cached = (data & SHADOW_IS_CACHED) != 0;
1496 tile.is_allocated = (data & SHADOW_IS_ALLOCATED) != 0;
1497 tile.is_rendered = (data & SHADOW_IS_RENDERED) != 0;
1498 tile.do_update = (data & SHADOW_DO_UPDATE) != 0;
1499 return tile;
1500}
1501
1503{
1504 uint data;
1505 /* NOTE: Page might be set to invalid values for tracking invalid usages.
1506 * So we have to mask the result. */
1507 data = shadow_page_pack(tile.page) & uint(SHADOW_MAX_PAGE - 1);
1508 data |= (tile.cache_index & 4095u) << 15u;
1509 data |= (tile.is_used ? uint(SHADOW_IS_USED) : 0);
1510 data |= (tile.is_allocated ? uint(SHADOW_IS_ALLOCATED) : 0);
1511 data |= (tile.is_cached ? uint(SHADOW_IS_CACHED) : 0);
1512 data |= (tile.is_rendered ? uint(SHADOW_IS_RENDERED) : 0);
1513 data |= (tile.do_update ? uint(SHADOW_DO_UPDATE) : 0);
1514 return data;
1515}
1516
1533#define ShadowSamplingTilePacked uint
1534
1535/* NOTE: Trust the input to be in valid range [0, (1 << SHADOW_TILEMAP_MAX_CLIPMAP_LOD) - 1].
1536 * Maximum LOD level index we can store is SHADOW_TILEMAP_MAX_CLIPMAP_LOD,
1537 * so we need SHADOW_TILEMAP_MAX_CLIPMAP_LOD bits to store the offset in each dimension.
1538 * Result fits into SHADOW_TILEMAP_MAX_CLIPMAP_LOD * 2 bits. */
1540{
1541 BLI_STATIC_ASSERT(SHADOW_TILEMAP_MAX_CLIPMAP_LOD <= 8, "Update page packing")
1542 return ofs.x | (ofs.y << SHADOW_TILEMAP_MAX_CLIPMAP_LOD);
1543}
1545{
1546 return (uint2(data) >> uint2(0, SHADOW_TILEMAP_MAX_CLIPMAP_LOD)) &
1548}
1549
1551{
1553 tile.page = shadow_page_unpack(data);
1554 /* -- 12 bits -- */
1555 /* Max value is actually SHADOW_TILEMAP_MAX_CLIPMAP_LOD but we mask the bits. */
1556 tile.lod = (data >> 12u) & 15u;
1557 /* -- 16 bits -- */
1558 tile.lod_offset = shadow_lod_offset_unpack(data >> 16u);
1559 /* -- 32 bits -- */
1560 tile.is_valid = data != 0u;
1561#ifndef GPU_SHADER
1562 /* Make tests pass on CPU but it is not required for proper rendering. */
1563 if (tile.lod == 0) {
1564 tile.lod_offset.x = 0;
1565 }
1566#endif
1567 return tile;
1568}
1569
1571{
1572 if (!tile.is_valid) {
1573 return 0u;
1574 }
1575 /* Tag a valid tile of LOD0 valid by setting their offset to 1.
1576 * This doesn't change the sampling and allows to use of all bits for data.
1577 * This makes sure no valid packed tile is 0u. */
1578 if (tile.lod == 0) {
1579 tile.lod_offset.x = 1;
1580 }
1581 uint data = shadow_page_pack(tile.page);
1582 /* Max value is actually SHADOW_TILEMAP_MAX_CLIPMAP_LOD but we mask the bits. */
1583 data |= (tile.lod & 15u) << 12u;
1584 data |= shadow_lod_offset_pack(tile.lod_offset) << 16u;
1585 return data;
1586}
1587
1589{
1591 tile.page = tile_data.page;
1592 tile.lod = lod;
1593 tile.lod_offset = uint2(0, 0); /* Computed during tilemap amend phase. */
1594 /* At this point, it should be the case that all given tiles that have been tagged as used are
1595 * ready for sampling. Otherwise tile_data should be SHADOW_NO_DATA. */
1596 tile.is_valid = tile_data.is_used;
1597 return tile;
1598}
1599
1601 /* Number of shadow rays to shoot for each light. */
1603 /* Number of shadow samples to take for each shadow ray. */
1605 /* Bounding radius for a film pixel at 1 unit from the camera. */
1607 /* Global switch for jittered shadows. */
1609};
1611
1612
1614/* -------------------------------------------------------------------- */
1623
1628
1629/* Sampling coordinates using UV space. */
1631 /* Offset in UV space to the start of the sampling space of the octahedron map. */
1633 /* Scaling of the squared UV space of the octahedron map. */
1634 float scale;
1635 /* Layer of the atlas where the octahedron map is stored. */
1636 float layer;
1637};
1639
1640/* Pixel read/write coordinates using pixel space. */
1642 /* Offset in pixel space to the start of the writing space of the octahedron map.
1643 * Note that the writing space is not the same as the sampling space as we have borders. */
1645 /* Size of the area in pixel that is covered by this probe mip-map. */
1647 /* Layer of the atlas where the octahedron map is stored. */
1649};
1651
1652
1675
1676
1684
1685/* Used for sphere probe spherical harmonics extraction. Output one for each thread-group
1686 * and do a sum afterward. Reduces bandwidth usage. */
1694
1701
1702
1704/* -------------------------------------------------------------------- */
1709 /* Actually stores radiance and world (sky) visibility. Stored normalized. */
1712 /* Accumulated weights per face. */
1715 float _pad0;
1716 float _pad1;
1717};
1719
1749
1800
1810
1825
1827 /* Offset in pixel to the start of the data inside the atlas texture. */
1829};
1831#define IrradianceBrickPacked uint
1832
1834{
1835 uint2 data = (uint2(brick.atlas_coord) & 0xFFFFu) << uint2(0u, 16u);
1836 IrradianceBrickPacked brick_packed = data.x | data.y;
1837 return brick_packed;
1838}
1839
1841{
1842 IrradianceBrick brick;
1843 brick.atlas_coord = (uint2(brick_packed) >> uint2(0u, 16u)) & uint2(0xFFFFu);
1844 return brick;
1845}
1846
1849/* -------------------------------------------------------------------- */
1860
1861
1863/* -------------------------------------------------------------------- */
1878
1879
1881/* -------------------------------------------------------------------- */
1902
1930
1963
1964
1966/* -------------------------------------------------------------------- */
1986
1987
1989/* -------------------------------------------------------------------- */
1993#define SSS_SAMPLE_MAX 64
1994#define SSS_BURLEY_TRUNCATE 16.0
1995#define SSS_BURLEY_TRUNCATE_CDF 0.9963790093708328
1996#define SSS_TRANSMIT_LUT_SIZE 64.0
1997#define SSS_TRANSMIT_LUT_RADIUS 2.0
1998#define SSS_TRANSMIT_LUT_SCALE ((SSS_TRANSMIT_LUT_SIZE - 1.0) / float(SSS_TRANSMIT_LUT_SIZE))
1999#define SSS_TRANSMIT_LUT_BIAS (0.5 / float(SSS_TRANSMIT_LUT_SIZE))
2000#define SSS_TRANSMIT_LUT_STEP_RES 64.0
2001
2004 /* NOTE(fclem) Using float4 for alignment. */
2014};
2016
2017static inline float3 burley_setup(float3 radius, float3 albedo)
2018{
2019 /* TODO(fclem): Avoid constant duplication. */
2020 const float m_1_pi = 0.318309886183790671538;
2021
2022 float3 A = albedo;
2023 /* Diffuse surface transmission, equation (6). */
2024 float3 s = 1.9 - A + 3.5 * ((A - 0.8) * (A - 0.8));
2025 /* Mean free path length adapted to fit ancient Cubic and Gaussian models. */
2026 float3 l = 0.25 * m_1_pi * radius;
2027
2028 return l / s;
2029}
2030
2031static inline float3 burley_eval(float3 d, float r)
2032{
2033 /* Slide 33. */
2034 float3 exp_r_3_d;
2035 /* TODO(fclem): Vectorize. */
2036 exp_r_3_d.x = expf(-r / (3.0 * d.x));
2037 exp_r_3_d.y = expf(-r / (3.0 * d.y));
2038 exp_r_3_d.z = expf(-r / (3.0 * d.z));
2039 float3 exp_r_d = exp_r_3_d * exp_r_3_d * exp_r_3_d;
2040 /* NOTE:
2041 * - Surface albedo is applied at the end.
2042 * - This is normalized diffuse model, so the equation is multiplied
2043 * by 2*pi, which also matches `cdf()`.
2044 */
2045 return (exp_r_d + exp_r_3_d) / (4.0 * d);
2046}
2047
2050/* -------------------------------------------------------------------- */
2066
2072
2073
2082
2083
2085/* -------------------------------------------------------------------- */
2096
2097
2099/* -------------------------------------------------------------------- */
2103/* Combines data from several modules to avoid wasting binding slots. */
2118
2119
2121/* -------------------------------------------------------------------- */
2125#define UTIL_TEX_SIZE 64
2126#define UTIL_BTDF_LAYER_COUNT 16
2127/* Scale and bias to avoid interpolation of the border pixel.
2128 * Remap UVs to the border pixels centers. */
2129#define UTIL_TEX_UV_SCALE ((UTIL_TEX_SIZE - 1.0f) / UTIL_TEX_SIZE)
2130#define UTIL_TEX_UV_BIAS (0.5f / UTIL_TEX_SIZE)
2131
2132#define UTIL_BLUE_NOISE_LAYER 0
2133#define UTIL_SSS_TRANSMITTANCE_PROFILE_LAYER 1
2134#define UTIL_LTC_MAT_LAYER 2
2135#define UTIL_BSDF_LAYER 3
2136#define UTIL_BTDF_LAYER 4
2137#define UTIL_DISK_INTEGRAL_LAYER UTIL_SSS_TRANSMITTANCE_PROFILE_LAYER
2138#define UTIL_DISK_INTEGRAL_COMP 3
2139
2140#ifdef GPU_SHADER
2141
2142# if defined(GPU_FRAGMENT_SHADER)
2143# define UTIL_TEXEL vec2(gl_FragCoord.xy)
2144# elif defined(GPU_COMPUTE_SHADER)
2145# define UTIL_TEXEL vec2(gl_GlobalInvocationID.xy)
2146# else
2147# define UTIL_TEXEL vec2(gl_VertexID, 0)
2148# endif
2149
2150/* Fetch texel. Wrapping if above range. */
2151float4 utility_tx_fetch(sampler2DArray util_tx, float2 texel, float layer)
2152{
2153 return texelFetch(util_tx, int3(int2(texel) % UTIL_TEX_SIZE, layer), 0);
2154}
2155
2156/* Sample at uv position. Filtered & Wrapping enabled. */
2157float4 utility_tx_sample(sampler2DArray util_tx, float2 uv, float layer)
2158{
2159 return textureLod(util_tx, float3(uv, layer), 0.0);
2160}
2161
2162/* Sample at uv position but with scale and bias so that uv space bounds lie on texel centers. */
2163float4 utility_tx_sample_lut(sampler2DArray util_tx, float2 uv, float layer)
2164{
2165 /* Scale and bias coordinates, for correct filtered lookup. */
2167 return textureLod(util_tx, float3(uv, layer), 0.0);
2168}
2169
2170/* Sample GGX BSDF LUT. */
2171float4 utility_tx_sample_bsdf_lut(sampler2DArray util_tx, float2 uv, float layer)
2172{
2173 /* Scale and bias coordinates, for correct filtered lookup. */
2175 layer = layer * UTIL_BTDF_LAYER_COUNT + UTIL_BTDF_LAYER;
2176
2177 float layer_floored;
2178 float interp = modf(layer, layer_floored);
2179
2180 float4 tex_low = textureLod(util_tx, float3(uv, layer_floored), 0.0);
2181 float4 tex_high = textureLod(util_tx, float3(uv, layer_floored + 1.0), 0.0);
2182
2183 /* Manual trilinear interpolation. */
2184 return mix(tex_low, tex_high, interp);
2185}
2186
2187/* Sample LTC or BSDF LUTs with `cos_theta` and `roughness` as inputs. */
2188float4 utility_tx_sample_lut(sampler2DArray util_tx, float cos_theta, float roughness, float layer)
2189{
2190 /* LUTs are parameterized by `sqrt(1.0 - cos_theta)` for more precision near grazing incidence.
2191 */
2192 vec2 coords = vec2(roughness, sqrt(clamp(1.0 - cos_theta, 0.0, 1.0)));
2193 return utility_tx_sample_lut(util_tx, coords, layer);
2194}
2195
2196#endif
2197
2198#ifdef EEVEE_PI
2199# undef M_PI
2200#endif
2201
2204#if IS_CPP
2205
2248} // namespace blender::eevee
2249#endif
#define BLI_STATIC_ASSERT_ALIGN(st, align)
Definition BLI_assert.h:90
#define M_PI
unsigned int uint
#define ENUM_OPERATORS(_type, _max)
#define saturate(a)
int32_t bool32_t
@ GPU_SAMPLER_FILTERING_LINEAR
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ccl_device_inline float cos_theta(const float3 w)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
local_group_size(16, 16) .push_constant(Type b
#define sinf(x)
#define cosf(x)
#define expf(x)
#define tanf(x)
#define ceilf(x)
#define atanf(x)
#define floorf(x)
#define sqrtf(x)
int len
#define SHADOW_PAGE_PER_ROW
#define SHADOW_TILEMAP_MAX_CLIPMAP_LOD
#define SHADOW_PAGE_PER_COL
#define SHADOW_MAX_PAGE
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define SAFE_ASSIGN_FLOAT(a, b)
#define AOV_MAX
#define SAFE_ASSIGN_INT_AS_FLOAT(a, b)
#define IrradianceBrickPacked
#define MOTION_BLUR_MAX_TILE
#define ShadowTileDataPacked
#define light_area_data_get(light)
#define SAFE_WRITE_END(light)
#define SAFE_ASSIGN_FLOAT3(a, b)
#define UTIL_TEX_UV_BIAS
#define UTIL_BTDF_LAYER
#define SAFE_WRITE_BEGIN(src_type, src, check)
#define light_sun_data_get(light)
#define light_local_data_get(light)
#define FILM_PRECOMP_SAMPLE_MAX
#define light_spot_data_get(light)
#define UTIL_BTDF_LAYER_COUNT
#define SAMPLING_DIMENSION_COUNT
#define UTIL_TEX_UV_SCALE
#define LOCAL_LIGHT_COMMON
#define SAFE_READ_BEGIN(dst_type, light, check)
#define ShadowSamplingTilePacked
#define SAFE_ASSIGN_FLOAT_AS_INT(a, b)
#define SAFE_ASSIGN_FLOAT2(a, b)
#define SSS_SAMPLE_MAX
#define SAFE_ASSIGN_INT(a, b)
#define UTIL_TEX_SIZE
#define SAFE_READ_END()
smooth(Type::VEC3, "prev") .smooth(Type CameraData
#define mix(a, b, c)
Definition hash.h:36
ccl_global const KernelWorkTile * tile
ccl_device_inline float2 power(float2 v, float e)
ccl_device_inline float2 interp(const float2 a, const float2 b, float t)
static ulong * next
BLI_STATIC_ASSERT(MBC_BATCH_LEN< 32, "Number of batches exceeded the limit of bit fields")
static LightData light_local_data_set(LightData light, LightSpotData spot_data)
static LightData light_sun_data_set(LightData light, LightSunData sun_data)
static LightSpotData light_local_data_get_ex(LightData light, bool check)
constexpr GPUSamplerState no_filter
static int2 shadow_cascade_grid_offset(int2 base_offset, int level_relative)
static bool is_panoramic(eCameraType type)
static bool is_sphere_light(eLightType type)
static bool is_area_light(eLightType type)
static float film_filter_weight(float filter_radius, float sample_distance_sqr)
static int light_local_tilemap_count(LightData light)
static float3 transform_point_inversed(Transform t, float3 point)
static float3 transform_x_axis(Transform t)
constexpr GPUSamplerState with_filter
static Transform transform_from_matrix(float4x4 m)
static IrradianceBrickPacked irradiance_brick_pack(IrradianceBrick brick)
static float circle_to_polygon_angle(float sides_count, float theta)
static float regular_polygon_side_length(float sides_count)
static ShadowTileDataPacked shadow_tile_pack(ShadowTileData tile)
static float3 transform_direction_transposed(Transform t, float3 direction)
static ShadowSamplingTilePacked shadow_sampling_tile_pack(ShadowSamplingTile tile)
static float3 light_position_get(LightData light)
static float3 light_y_axis(LightData light)
static bool is_sun_light(eLightType type)
static ShadowTileData shadow_tile_unpack(ShadowTileDataPacked data)
static int light_tilemap_max_get(LightData light)
static uint2 shadow_lod_offset_unpack(uint data)
static float3 transform_z_axis(Transform t)
static int sampling_web_ring_count_get(int web_density, int sample_count)
static float3 light_z_axis(LightData light)
static bool is_spot_light(eLightType type)
static float3 transform_y_axis(Transform t)
static uint3 shadow_page_unpack(uint data)
static bool is_oriented_disk_light(eLightType type)
static float3 light_x_axis(LightData light)
static IrradianceBrick irradiance_brick_unpack(IrradianceBrickPacked brick_packed)
static float3 burley_setup(float3 radius, float3 albedo)
static float coc_radius_from_camera_depth(DepthOfFieldData dof, float depth)
static uint shadow_page_pack(uint3 page)
static bool is_local_light(eLightType type)
static float4x4 transform_to_matrix(Transform t)
static float3 burley_eval(float3 d, float r)
static uint shadow_lod_offset_pack(uint2 ofs)
static ShadowSamplingTile shadow_sampling_tile_create(ShadowTileData tile_data, uint lod)
draw::StorageArrayBuffer< uint, 1024, true > RayTraceTileBuf
static bool is_point_light(eLightType type)
static int sampling_web_sample_count_get(int web_density, int in_ring_count)
static float circle_to_polygon_radius(float sides_count, float theta)
static ShadowSamplingTile shadow_sampling_tile_unpack(ShadowSamplingTilePacked data)
static float3 transform_location(Transform t)
T clamp(const T &a, const T &min, const T &max)
T sqrt(const T &a)
VecBase< T, 3 > transform_direction(const MatBase< T, 3, 3 > &mat, const VecBase< T, 3 > &direction)
VecBase< T, 3 > transform_point(const CartesianBasis &basis, const VecBase< T, 3 > &v)
VecBase< uint32_t, 2 > uint2
MatBase< float, 4, 4 > float4x4
MatBase< float, 3, 4 > float3x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< int32_t, 3 > int3
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
unsigned int uint32_t
Definition stdint.h:80
static constexpr GPUSamplerState default_sampler()
ePassStorageType display_storage_type
ReflectionProbeLowFreqLight low_freq_light