Blender V4.5
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
10
11/* __cplusplus is true when compiling with MSL, so ensure we are not inside a shader. */
12#if defined(GPU_SHADER) || defined(GLSL_CPP_STUBS)
13# define IS_CPP 0
14#else
15# define IS_CPP 1
16#endif
17
18#if IS_CPP || defined(GLSL_CPP_STUBS)
19# pragma once
20
21# include "eevee_defines.hh"
22#endif
23
24#if IS_CPP
25# include "BLI_math_bits.h"
26# include "BLI_memory_utils.hh"
27
28# include "DRW_gpu_wrapper.hh"
29
30# include "draw_manager.hh"
31# include "draw_pass.hh"
32
33# include "GPU_shader_shared.hh"
34
35namespace blender::eevee {
36
37class ShadowDirectional;
38class ShadowPunctual;
39
40using namespace draw;
41
44
45#endif
46
47#define EEVEE_PI 3.14159265358979323846 /* pi */
48
49enum eCubeFace : uint32_t {
50 /* Ordering by culling order. If cone aperture is shallow, we cull the later view. */
51 Z_NEG = 0u,
52 X_POS = 1u,
53 X_NEG = 2u,
54 Y_POS = 3u,
55 Y_NEG = 4u,
56 Z_POS = 5u,
57};
58
90
91/* -------------------------------------------------------------------- */
94
95struct Transform {
96 /* The transform is stored transposed for compactness. */
98#if IS_CPP
99 Transform() = default;
101 : x(tx[0][0], tx[1][0], tx[2][0], tx[3][0]),
102 y(tx[0][1], tx[1][1], tx[2][1], tx[3][1]),
103 z(tx[0][2], tx[1][2], tx[2][2], tx[3][2])
104 {
105 }
106
107 operator float4x4() const
108 {
109 return float4x4(float4(x.x, y.x, z.x, 0.0f),
110 float4(x.y, y.y, z.y, 0.0f),
111 float4(x.z, y.z, z.z, 0.0f),
112 float4(x.w, y.w, z.w, 1.0f));
113 }
114#endif
115};
116
118{
119 return float4x4(float4(t.x.x, t.y.x, t.z.x, 0.0f),
120 float4(t.x.y, t.y.y, t.z.y, 0.0f),
121 float4(t.x.z, t.y.z, t.z.z, 0.0f),
122 float4(t.x.w, t.y.w, t.z.w, 1.0f));
123}
124
126{
127 Transform t;
128 t.x = float4(m[0][0], m[1][0], m[2][0], m[3][0]);
129 t.y = float4(m[0][1], m[1][1], m[2][1], m[3][1]);
130 t.z = float4(m[0][2], m[1][2], m[2][2], m[3][2]);
131 return t;
132}
133
135{
136 return float3(t.x.x, t.y.x, t.z.x);
137}
139{
140 return float3(t.x.y, t.y.y, t.z.y);
141}
143{
144 return float3(t.x.z, t.y.z, t.z.z);
145}
147{
148 return float3(t.x.w, t.y.w, t.z.w);
149}
150
151#if !IS_CPP
152static inline bool transform_equal(Transform a, Transform b)
153{
154 return all(equal(a.x, b.x)) && all(equal(a.y, b.y)) && all(equal(a.z, b.z));
155}
156#endif
157
158static inline float3 transform_point(Transform t, float3 point)
159{
160 return float4(point, 1.0f) * float3x4(t.x, t.y, t.z);
161}
162
163static inline float3 transform_direction(Transform t, float3 direction)
164{
165 return direction * float3x3(float3(t.x.x, t.x.y, t.x.z),
166 float3(t.y.x, t.y.y, t.y.z),
167 float3(t.z.x, t.z.y, t.z.z));
168}
169
171{
172 return float3x3(float3(t.x.x, t.x.y, t.x.z),
173 float3(t.y.x, t.y.y, t.y.z),
174 float3(t.z.x, t.z.y, t.z.z)) *
175 direction;
176}
177
178/* Assumes the transform has unit scale. */
180{
181 return float3x3(float3(t.x.x, t.x.y, t.x.z),
182 float3(t.y.x, t.y.y, t.y.z),
183 float3(t.z.x, t.z.y, t.z.z)) *
184 (point - transform_location(t));
185}
186
188
189/* -------------------------------------------------------------------- */
192
245
247
248/* -------------------------------------------------------------------- */
251
259
261
262/* -------------------------------------------------------------------- */
265
300
305#define SAMPLING_DIMENSION_COUNT 32
306
307/* NOTE(@fclem): Needs to be used in #StorageBuffer because of arrays of scalar. */
313
314/* Returns total sample count in a web pattern of the given size. */
315static inline int sampling_web_sample_count_get(int web_density, int in_ring_count)
316{
317 return ((in_ring_count * in_ring_count + in_ring_count) / 2) * web_density + 1;
318}
319
320/* Returns lowest possible ring count that contains at least sample_count samples. */
321static inline int sampling_web_ring_count_get(int web_density, int sample_count)
322{
323 /* Inversion of web_sample_count_get(). */
324 float x = 2.0f * (float(sample_count) - 1.0f) / float(web_density);
325 /* Solving polynomial. We only search positive solution. */
326 float discriminant = 1.0f + 4.0f * x;
327 return int(ceilf(0.5f * (sqrtf(discriminant) - 1.0f)));
328}
329
331
332/* -------------------------------------------------------------------- */
335
344
345static inline bool is_panoramic(eCameraType type)
346{
347 return type > CAMERA_ORTHO;
348}
349
351 /* View Matrices of the camera, not from any view! */
369 float clip_far;
373 float _pad0;
374 float _pad1;
375 float _pad2;
376
378
379#ifdef __cplusplus
380 /* Small constructor to allow detecting new buffers. */
382#endif
383};
384BLI_STATIC_ASSERT_ALIGN(CameraData, 16)
385
386
387
388/* -------------------------------------------------------------------- */
391
392#define FILM_PRECOMP_SAMPLE_MAX 16
393
398
404
414
422
502
503static inline float film_filter_weight(float filter_radius, float sample_distance_sqr)
504{
505#if 1 /* Faster */
506 /* Gaussian fitted to Blackman-Harris. */
507 float r = sample_distance_sqr / (filter_radius * filter_radius);
508 const float sigma = 0.284;
509 const float fac = -0.5 / (sigma * sigma);
510 float weight = expf(fac * r);
511#else
512 /* Blackman-Harris filter. */
513 float r = M_TAU * saturate(0.5 + sqrtf(sample_distance_sqr) / (2.0 * filter_radius));
514 float weight = 0.35875 - 0.48829 * cosf(r) + 0.14128 * cosf(2.0 * r) - 0.01168 * cosf(3.0 * r);
515#endif
516 return weight;
517}
518
520
521/* -------------------------------------------------------------------- */
524
525/* Theoretical max is 128 as we are using texture array and VRAM usage.
526 * However, the output_aov() function perform a linear search inside all the hashes.
527 * If we find a way to avoid this we could bump this number up. */
528#define AOV_MAX 16
529
531 /* Use uint4 to workaround std140 packing rules.
532 * Only the x value is used. */
535 /* Length of used data. */
542};
544
566
567
568
569/* -------------------------------------------------------------------- */
572
573#define VELOCITY_INVALID 512.0
574
575enum eVelocityStep : uint32_t {
579};
580
586
587#ifdef __cplusplus
588 VelocityObjectIndex() : ofs(-1, -1, -1), resource_id(-1){};
589#endif
590};
591BLI_STATIC_ASSERT_ALIGN(VelocityObjectIndex, 16)
592
603
604 int _pad0;
605
606#ifdef __cplusplus
607 VelocityGeometryIndex() : ofs(-1, -1, -1), do_deform(false), len(-1, -1, -1), _pad0(1){};
608#endif
609};
610BLI_STATIC_ASSERT_ALIGN(VelocityGeometryIndex, 16)
611
617
618
619
620/* -------------------------------------------------------------------- */
623
624#define MOTION_BLUR_TILE_SIZE 32
625#define MOTION_BLUR_MAX_TILE 512 /* 16384 / MOTION_BLUR_TILE_SIZE */
637
638/* For some reasons some GLSL compilers do not like this struct.
639 * So we declare it as a uint array instead and do indexing ourselves. */
640#ifdef __cplusplus
641struct MotionBlurTileIndirection {
648};
649BLI_STATIC_ASSERT_ALIGN(MotionBlurTileIndirection, 16)
650#endif
651
653
654/* -------------------------------------------------------------------- */
657
659 /* During object voxelization, we need to use an infinite projection matrix to avoid clipping
660 * faces. But they cannot be used for recovering the view position from froxel position as they
661 * are not invertible. We store the finite projection matrix and use it for this purpose. */
664 /* Copies of the matrices above but without jittering. Used for re-projection. */
667 /* Previous render sample copy of winmat_stable. */
669 /* Transform from current view space to previous render sample view space. */
671 /* Size of the froxel grid texture. */
673 /* Maximum light intensity during volume lighting evaluation. */
675 /* Inverse of size of the froxel grid. */
677 /* Maximum light intensity during volume lighting evaluation. */
679 /* 2D scaling factor to make froxel squared. */
681 /* Extent and inverse extent of the main shading view (render extent, not film extent). */
684 /* Size in main view pixels of one froxel in XY. */
686 /* Hi-Z LOD to use during volume shadow tagging. */
688 /* Depth to froxel mapping. */
692 /* Previous render sample copy of the depth mapping parameters. */
696 /* Amount of history to blend during the scatter phase. */
698
699 float _pad1;
700};
702
703
704
705/* -------------------------------------------------------------------- */
708
709/* 5% error threshold. */
710#define DOF_FAST_GATHER_COC_ERROR 0.05
711#define DOF_GATHER_RING_COUNT 5
712#define DOF_DILATE_RING_COUNT 3
713
748
758
759static inline float coc_radius_from_camera_depth(DepthOfFieldData dof, float depth)
760{
761 depth = (dof.camera_type != CAMERA_ORTHO) ? 1.0f / depth : depth;
762 return dof.coc_mul * depth + dof.coc_bias;
763}
764
765static inline float regular_polygon_side_length(float sides_count)
766{
767 return 2.0f * sinf(EEVEE_PI / sides_count);
768}
769
770/* Returns intersection ratio between the radius edge at theta and the regular polygon edge.
771 * Start first corners at theta == 0. */
772static inline float circle_to_polygon_radius(float sides_count, float theta)
773{
774 /* From Graphics Gems from CryENGINE 3 (SIGGRAPH 2013) by Tiago Sousa (slide 36). */
775 float side_angle = (2.0f * EEVEE_PI) / sides_count;
776 return cosf(side_angle * 0.5f) /
777 cosf(theta - side_angle * floorf((sides_count * theta + EEVEE_PI) / (2.0f * EEVEE_PI)));
778}
779
780/* Remap input angle to have homogenous spacing of points along a polygon edge.
781 * Expects theta to be in [0..2pi] range. */
782static inline float circle_to_polygon_angle(float sides_count, float theta)
783{
784 float side_angle = (2.0f * EEVEE_PI) / sides_count;
785 float halfside_angle = side_angle * 0.5f;
786 float side = floorf(theta / side_angle);
787 /* Length of segment from center to the middle of polygon side. */
788 float adjacent = circle_to_polygon_radius(sides_count, 0.0f);
789
790 /* This is the relative position of the sample on the polygon half side. */
791 float local_theta = theta - side * side_angle;
792 float ratio = (local_theta - halfside_angle) / halfside_angle;
793
794 float halfside_len = regular_polygon_side_length(sides_count) * 0.5f;
795 float opposite = ratio * halfside_len;
796
797 /* NOTE: atan(y_over_x) has output range [-pi/2..pi/2]. */
798 float final_local_theta = atanf(opposite / adjacent);
799
800 return side * side_angle + final_local_theta;
801}
802
804
805/* -------------------------------------------------------------------- */
808
809/* Number of items we can cull. Limited by how we store CullingZBin. */
810#define CULLING_MAX_ITEM 65536
811/* Fine grained subdivision in the Z direction. Limited by the LDS in z-binning compute shader. */
812#define CULLING_ZBIN_COUNT 4096
813/* Max tile map resolution per axes. */
814#define CULLING_TILE_RES 16
815
844
845
846
847/* -------------------------------------------------------------------- */
850
851#define LIGHT_NO_SHADOW -1
852
853enum eLightType : uint32_t {
856 /* Point light. */
859 /* Spot light. */
862 /* Area light. */
865};
866
867enum LightingType : uint32_t {
872 /* WORKAROUND: Special value used to tag translucent BSDF with thickness.
873 * Fall back to LIGHT_DIFFUSE. */
875};
876
877static inline bool is_area_light(eLightType type)
878{
879 return type >= LIGHT_RECT;
880}
881
882static inline bool is_point_light(eLightType type)
883{
884 return type >= LIGHT_OMNI_SPHERE && type <= LIGHT_SPOT_DISK;
885}
886
887static inline bool is_spot_light(eLightType type)
888{
889 return type == LIGHT_SPOT_SPHERE || type == LIGHT_SPOT_DISK;
890}
891
892static inline bool is_sphere_light(eLightType type)
893{
894 return type == LIGHT_SPOT_SPHERE || type == LIGHT_OMNI_SPHERE;
895}
896
897static inline bool is_oriented_disk_light(eLightType type)
898{
899 return type == LIGHT_SPOT_DISK || type == LIGHT_OMNI_DISK;
900}
901
902static inline bool is_sun_light(eLightType type)
903{
904 return type < LIGHT_OMNI_SPHERE;
905}
906
907static inline bool is_local_light(eLightType type)
908{
909 return type >= LIGHT_OMNI_SPHERE;
910}
911
912/* Using define because GLSL doesn't have inheritance, and encapsulation forces us to add some
913 * unneeded padding. */
914#define LOCAL_LIGHT_COMMON \
915 \
916 \
917 packed_float3 shadow_position; \
918 float _pad0; \
919 \
920 float shadow_radius; \
921 \
922 float shape_radius; \
923 \
924 float influence_radius_max; \
925 \
926 float influence_radius_invsqr_surface; \
927 float influence_radius_invsqr_volume; \
928 \
929 int tilemaps_count;
930
931/* Untyped local light data. Gets reinterpreted to LightSpotData and LightAreaData.
932 * Allow access to local light common data without casting. */
935
936 float _pad1;
937 float _pad2;
938
940 float _pad4;
941 float _pad5;
942};
944
945/* Despite the name, is also used for omni light. */
959BLI_STATIC_ASSERT(sizeof(LightSpotData) == sizeof(LightLocalData), "Data size must match")
960
961struct LightAreaData {
963
964 float _pad2;
965 float _pad3;
966
968 float2 size;
970 float shadow_scale;
971 float _pad6;
972};
973BLI_STATIC_ASSERT(sizeof(LightAreaData) == sizeof(LightLocalData), "Data size must match")
974
975struct LightSunData {
976 /* Sun direction for shading. Use object_to_world for getting into shadow space. */
977 packed_float3 direction;
978 /* Radius of the sun disk, one unit away from a shading point. */
979 float shape_radius;
980
983 int2 clipmap_base_offset_neg;
984 int2 clipmap_base_offset_pos;
985
987 float shadow_angle;
988 float _pad5;
989 float _pad3;
990 float _pad4;
991
993 float2 clipmap_origin;
995 int clipmap_lod_min;
996 int clipmap_lod_max;
997};
998BLI_STATIC_ASSERT(sizeof(LightSunData) == sizeof(LightLocalData), "Data size must match")
999
1000/* Enable when debugging. This is quite costly. */
1001#define SAFE_UNION_ACCESS 0
1002
1003#if IS_CPP
1004/* C++ always uses union. */
1005# define USE_LIGHT_UNION 1
1006#elif defined(GPU_BACKEND_METAL) && !SAFE_UNION_ACCESS
1007/* Metal supports union, but force usage of the getters if SAFE_UNION_ACCESS is enabled. */
1008# define USE_LIGHT_UNION 1
1009#else
1010/* Use getter functions on GPU if not supported or if SAFE_UNION_ACCESS is enabled. */
1011# define USE_LIGHT_UNION 0
1012#endif
1013
1014struct LightData {
1020 Transform object_to_world;
1021
1023 float4 power;
1027 eLightType type;
1028
1031 int clip_near;
1032 int clip_far;
1034 int tilemap_index;
1035 /* Radius in pixels for shadow filtering. */
1036 float filter_radius;
1037
1038 /* Shadow Map resolution bias. */
1039 float lod_bias;
1040 /* Shadow Map resolution maximum resolution. */
1041 float lod_min;
1042 /* True if the light uses jittered soft shadows. */
1043 bool32_t shadow_jitter;
1044 float _pad2;
1045 uint2 light_set_membership;
1047 /* TODO(fclem): this should be part of #eevee::Light struct. But for some reason it gets cleared
1048 * to zero after each sync cycle. */
1049 uint2 shadow_set_membership;
1050
1051#if USE_LIGHT_UNION
1052 union {
1053 LightLocalData local;
1054 LightSpotData spot;
1055 LightAreaData area;
1056 LightSunData sun;
1057 };
1058#else
1059 /* Use `light_*_data_get(light)` to access typed data. */
1060 LightLocalData do_not_access_directly;
1061#endif
1062};
1064
1065static inline float3 light_x_axis(LightData light)
1066{
1067 return transform_x_axis(light.object_to_world);
1068}
1069static inline float3 light_y_axis(LightData light)
1070{
1071 return transform_y_axis(light.object_to_world);
1072}
1073static inline float3 light_z_axis(LightData light)
1074{
1075 return transform_z_axis(light.object_to_world);
1076}
1078{
1079 return transform_location(light.object_to_world);
1080}
1081
1082#ifdef GPU_SHADER
1083# define CHECK_TYPE_PAIR(a, b)
1084# define CHECK_TYPE(a, b)
1085# define FLOAT_AS_INT floatBitsToInt
1086# define INT_AS_FLOAT intBitsToFloat
1087# define TYPECAST_NOOP
1088
1089#else /* C++ */
1090# define FLOAT_AS_INT float_as_int
1091# define INT_AS_FLOAT int_as_float
1092# define TYPECAST_NOOP
1093#endif
1094
1095/* In addition to the static asserts that verify correct member assignment, also verify access on
1096 * the GPU so that only lights of a certain type can read for the appropriate union member.
1097 * Return cross platform garbage data as some platform can return cleared memory if we early exit.
1098 */
1099#if SAFE_UNION_ACCESS
1100# ifdef GPU_SHADER
1101/* Should result in a beautiful zebra pattern on invalid load. */
1102# if defined(GPU_FRAGMENT_SHADER)
1103# define GARBAGE_VALUE sin(gl_FragCoord.x + gl_FragCoord.y)
1104# elif defined(GPU_COMPUTE_SHADER)
1105# define GARBAGE_VALUE \
1106 sin(float(gl_GlobalInvocationID.x + gl_GlobalInvocationID.y + gl_GlobalInvocationID.z))
1107# else
1108# define GARBAGE_VALUE sin(float(gl_VertexID))
1109# endif
1110
1111/* Can be set to zero if zebra creates out-of-bound accesses and crashes. At least avoid UB. */
1112// # define GARBAGE_VALUE 0.0
1113
1114# else /* C++ */
1115# define GARBAGE_VALUE 0.0f
1116# endif
1117
1118# define SAFE_BEGIN(dst_type, src_type, src_, check) \
1119 src_type _src = src_; \
1120 dst_type _dst; \
1121 bool _validity_check = check; \
1122 float _garbage = GARBAGE_VALUE;
1123
1124/* Assign garbage value if the light type check fails. */
1125# define SAFE_ASSIGN_LIGHT_TYPE_CHECK(_type, _value) \
1126 (_validity_check ? (_value) : _type(_garbage))
1127#else
1128# define SAFE_BEGIN(dst_type, src_type, src_, check) \
1129 UNUSED_VARS(check); \
1130 src_type _src = src_; \
1131 dst_type _dst;
1132
1133# define SAFE_ASSIGN_LIGHT_TYPE_CHECK(_type, _value) _value
1134#endif
1135
1136#if USE_LIGHT_UNION
1137# define DATA_MEMBER local
1138#else
1139# define DATA_MEMBER do_not_access_directly
1140#endif
1141
1142#define SAFE_READ_BEGIN(dst_type, light, check) \
1143 SAFE_BEGIN(dst_type, LightLocalData, light.DATA_MEMBER, check)
1144#define SAFE_READ_END() _dst
1145
1146#define SAFE_WRITE_BEGIN(src_type, src, check) SAFE_BEGIN(LightLocalData, src_type, src, check)
1147#define SAFE_WRITE_END(light) light.DATA_MEMBER = _dst;
1148
1149#define ERROR_OFS(a, b) "Offset of " STRINGIFY(a) " mismatch offset of " STRINGIFY(b)
1150
1151/* This is a dangerous process, make sure to static assert every assignment. */
1152#define SAFE_ASSIGN(a, reinterpret_fn, in_type, b) \
1153 CHECK_TYPE_PAIR(_src.b, in_type(_dst.a)); \
1154 CHECK_TYPE_PAIR(_dst.a, reinterpret_fn(_src.b)); \
1155 _dst.a = reinterpret_fn(SAFE_ASSIGN_LIGHT_TYPE_CHECK(in_type, _src.b)); \
1156 BLI_STATIC_ASSERT(offsetof(decltype(_dst), a) == offsetof(decltype(_src), b), ERROR_OFS(a, b))
1157
1158#define SAFE_ASSIGN_FLOAT(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float, b);
1159#define SAFE_ASSIGN_FLOAT2(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float2, b);
1160#define SAFE_ASSIGN_FLOAT3(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float3, b);
1161#define SAFE_ASSIGN_INT(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, int, b);
1162#define SAFE_ASSIGN_FLOAT_AS_INT(a, b) SAFE_ASSIGN(a, FLOAT_AS_INT, float, b);
1163#define SAFE_ASSIGN_INT_AS_FLOAT(a, b) SAFE_ASSIGN(a, INT_AS_FLOAT, int, b);
1164
1165#if !USE_LIGHT_UNION || IS_CPP
1166
1167/* These functions are not meant to be used in C++ code. They are only defined on the C++ side for
1168 * static assertions. Hide them. */
1169# if IS_CPP
1170namespace do_not_use {
1171# endif
1172
1173static inline LightSpotData light_local_data_get_ex(LightData light, bool check)
1174{
1175 SAFE_READ_BEGIN(LightSpotData, light, check)
1176 SAFE_ASSIGN_FLOAT3(shadow_position, shadow_position)
1177 SAFE_ASSIGN_FLOAT(_pad0, _pad0)
1178 SAFE_ASSIGN_FLOAT(shadow_radius, shadow_radius)
1179 SAFE_ASSIGN_FLOAT(shape_radius, shape_radius)
1180 SAFE_ASSIGN_FLOAT(influence_radius_max, influence_radius_max)
1181 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
1182 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
1183 SAFE_ASSIGN_INT(tilemaps_count, tilemaps_count)
1184 SAFE_ASSIGN_FLOAT(spot_mul, _pad2)
1185 SAFE_ASSIGN_FLOAT2(spot_size_inv, _pad3)
1186 SAFE_ASSIGN_FLOAT(spot_tan, _pad4)
1187 SAFE_ASSIGN_FLOAT(spot_bias, _pad5)
1188 return SAFE_READ_END();
1189}
1190
1192{
1193 SAFE_WRITE_BEGIN(LightSpotData, spot_data, is_local_light(light.type))
1194 SAFE_ASSIGN_FLOAT3(shadow_position, shadow_position)
1195 SAFE_ASSIGN_FLOAT(_pad0, _pad0)
1196 SAFE_ASSIGN_FLOAT(shadow_radius, shadow_radius)
1197 SAFE_ASSIGN_FLOAT(shape_radius, shape_radius)
1198 SAFE_ASSIGN_FLOAT(influence_radius_max, influence_radius_max)
1199 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
1200 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
1201 SAFE_ASSIGN_INT(tilemaps_count, tilemaps_count)
1202 SAFE_ASSIGN_FLOAT(_pad2, spot_mul)
1203 SAFE_ASSIGN_FLOAT2(_pad3, spot_size_inv)
1204 SAFE_ASSIGN_FLOAT(_pad4, spot_tan)
1205 SAFE_ASSIGN_FLOAT(_pad5, spot_bias)
1206 SAFE_WRITE_END(light)
1207 return light;
1208}
1209
1211{
1212 return light_local_data_get_ex(light, is_local_light(light.type));
1213}
1214
1216{
1217 return light_local_data_get_ex(light, is_spot_light(light.type) || is_point_light(light.type));
1218}
1219
1220static inline LightAreaData light_area_data_get(LightData light)
1221{
1222 SAFE_READ_BEGIN(LightAreaData, light, is_area_light(light.type))
1223 SAFE_ASSIGN_FLOAT(shape_radius, shape_radius)
1224 SAFE_ASSIGN_FLOAT(influence_radius_max, influence_radius_max)
1225 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
1226 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
1227 SAFE_ASSIGN_FLOAT3(shadow_position, shadow_position)
1228 SAFE_ASSIGN_FLOAT(shadow_radius, shadow_radius)
1229 SAFE_ASSIGN_INT(tilemaps_count, tilemaps_count)
1230 SAFE_ASSIGN_FLOAT2(size, _pad3)
1231 SAFE_ASSIGN_FLOAT(shadow_scale, _pad4)
1232 return SAFE_READ_END();
1233}
1234
1235static inline LightSunData light_sun_data_get(LightData light)
1236{
1237 SAFE_READ_BEGIN(LightSunData, light, is_sun_light(light.type))
1238 SAFE_ASSIGN_FLOAT3(direction, shadow_position)
1239 SAFE_ASSIGN_FLOAT(shape_radius, _pad0)
1240 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_base_offset_neg.x, shadow_radius)
1241 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_base_offset_neg.y, shape_radius)
1242 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_base_offset_pos.x, influence_radius_max)
1243 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_base_offset_pos.y, influence_radius_invsqr_surface)
1244 SAFE_ASSIGN_FLOAT(shadow_angle, influence_radius_invsqr_volume)
1245 SAFE_ASSIGN_FLOAT2(clipmap_origin, _pad3)
1246 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_lod_min, _pad4)
1247 SAFE_ASSIGN_FLOAT_AS_INT(clipmap_lod_max, _pad5)
1248 return SAFE_READ_END();
1249}
1250
1251static inline LightData light_sun_data_set(LightData light, LightSunData sun_data)
1252{
1253 SAFE_WRITE_BEGIN(LightSunData, sun_data, is_sun_light(light.type))
1254 SAFE_ASSIGN_FLOAT3(shadow_position, direction)
1255 SAFE_ASSIGN_FLOAT(_pad0, shape_radius)
1256 SAFE_ASSIGN_INT_AS_FLOAT(shadow_radius, clipmap_base_offset_neg.x)
1257 SAFE_ASSIGN_INT_AS_FLOAT(shape_radius, clipmap_base_offset_neg.y)
1258 SAFE_ASSIGN_INT_AS_FLOAT(influence_radius_max, clipmap_base_offset_pos.x)
1259 SAFE_ASSIGN_INT_AS_FLOAT(influence_radius_invsqr_surface, clipmap_base_offset_pos.y)
1260 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, shadow_angle)
1261 SAFE_ASSIGN_FLOAT2(_pad3, clipmap_origin)
1262 SAFE_ASSIGN_INT_AS_FLOAT(_pad4, clipmap_lod_min)
1263 SAFE_ASSIGN_INT_AS_FLOAT(_pad5, clipmap_lod_max)
1264 SAFE_WRITE_END(light)
1265 return light;
1266}
1267
1268# if IS_CPP
1269} // namespace do_not_use
1270# endif
1271
1272#endif
1273
1274#if USE_LIGHT_UNION
1275# define light_local_data_get(light) light.local
1276# define light_spot_data_get(light) light.spot
1277# define light_area_data_get(light) light.area
1278# define light_sun_data_get(light) light.sun
1279#endif
1280
1281#undef DATA_MEMBER
1282#undef GARBAGE_VALUE
1283#undef FLOAT_AS_INT
1284#undef TYPECAST_NOOP
1285#undef SAFE_BEGIN
1286#undef SAFE_ASSIGN_LIGHT_TYPE_CHECK
1287#undef ERROR_OFS
1288#undef SAFE_ASSIGN
1289#undef SAFE_ASSIGN_FLOAT
1290#undef SAFE_ASSIGN_FLOAT2
1291#undef SAFE_ASSIGN_INT
1292#undef SAFE_ASSIGN_FLOAT_AS_INT
1293#undef SAFE_ASSIGN_INT_AS_FLOAT
1294
1295static inline int light_tilemap_max_get(LightData light)
1296{
1297 /* This is not something we need in performance critical code. */
1298 if (is_sun_light(light.type)) {
1299 return light.tilemap_index +
1300 (light_sun_data_get(light).clipmap_lod_max - light_sun_data_get(light).clipmap_lod_min);
1301 }
1302 return light.tilemap_index + light_local_data_get(light).tilemaps_count - 1;
1303}
1304
1305/* Return the number of tilemap needed for a local light. */
1306static inline int light_local_tilemap_count(LightData light)
1307{
1308 if (is_spot_light(light.type)) {
1309 return (light_spot_data_get(light).spot_tan > tanf(EEVEE_PI / 4.0)) ? 5 : 1;
1310 }
1311 if (is_area_light(light.type)) {
1312 return 5;
1313 }
1314 return 6;
1315}
1316
1318
1319/* -------------------------------------------------------------------- */
1331
1337
1338static inline int2 shadow_cascade_grid_offset(int2 base_offset, int level_relative)
1339{
1340 return (base_offset * level_relative) / (1 << 16);
1341}
1342
1382
1383
1410
1411
1423 /* Transform the shadow is rendered with. Used to detect updates on GPU. */
1425 /* Integer offset of the center of the 16x16 tiles from the origin of the tile space. */
1429};
1431
1449
1468
1469
1486
1487#define ShadowTileDataPacked uint
1488
1489enum eShadowFlag : uint32_t {
1491 SHADOW_IS_CACHED = (1u << 27u),
1492 SHADOW_IS_ALLOCATED = (1u << 28u),
1493 SHADOW_DO_UPDATE = (1u << 29u),
1494 SHADOW_IS_RENDERED = (1u << 30u),
1495 SHADOW_IS_USED = (1u << 31u)
1496};
1497
1498/* NOTE: Trust the input to be in valid range (max is [3,3,255]).
1499 * If it is in valid range, it should pack to 12bits so that `shadow_tile_pack()` can use it.
1500 * But sometime this is used to encode invalid pages uint3(-1) and it needs to output uint(-1). */
1501static inline uint shadow_page_pack(uint3 page)
1502{
1503 return (page.x << 0u) | (page.y << 2u) | (page.z << 4u);
1504}
1506{
1507 uint3 page;
1508 BLI_STATIC_ASSERT(SHADOW_PAGE_PER_ROW <= 4 && SHADOW_PAGE_PER_COL <= 4, "Update page packing")
1509 page.x = (data >> 0u) & 3u;
1510 page.y = (data >> 2u) & 3u;
1511 BLI_STATIC_ASSERT(SHADOW_MAX_PAGE <= 4096, "Update page packing")
1512 page.z = (data >> 4u) & 255u;
1513 return page;
1514}
1515
1517{
1520 /* -- 12 bits -- */
1521 /* Unused bits. */
1522 /* -- 15 bits -- */
1523 BLI_STATIC_ASSERT(SHADOW_MAX_PAGE <= 4096, "Update page packing")
1524 tile.cache_index = (data >> 15u) & 4095u;
1525 /* -- 27 bits -- */
1526 tile.is_used = (data & SHADOW_IS_USED) != 0;
1527 tile.is_cached = (data & SHADOW_IS_CACHED) != 0;
1528 tile.is_allocated = (data & SHADOW_IS_ALLOCATED) != 0;
1529 tile.is_rendered = (data & SHADOW_IS_RENDERED) != 0;
1530 tile.do_update = (data & SHADOW_DO_UPDATE) != 0;
1531 return tile;
1532}
1533
1535{
1536 uint data;
1537 /* NOTE: Page might be set to invalid values for tracking invalid usages.
1538 * So we have to mask the result. */
1540 data |= (tile.cache_index & 4095u) << 15u;
1541 data |= (tile.is_used ? uint(SHADOW_IS_USED) : 0);
1542 data |= (tile.is_allocated ? uint(SHADOW_IS_ALLOCATED) : 0);
1543 data |= (tile.is_cached ? uint(SHADOW_IS_CACHED) : 0);
1544 data |= (tile.is_rendered ? uint(SHADOW_IS_RENDERED) : 0);
1545 data |= (tile.do_update ? uint(SHADOW_DO_UPDATE) : 0);
1546 return data;
1547}
1548
1564
1565#define ShadowSamplingTilePacked uint
1566
1567/* NOTE: Trust the input to be in valid range [0, (1 << SHADOW_TILEMAP_MAX_CLIPMAP_LOD) - 1].
1568 * Maximum LOD level index we can store is SHADOW_TILEMAP_MAX_CLIPMAP_LOD,
1569 * so we need SHADOW_TILEMAP_MAX_CLIPMAP_LOD bits to store the offset in each dimension.
1570 * Result fits into SHADOW_TILEMAP_MAX_CLIPMAP_LOD * 2 bits. */
1572{
1573 BLI_STATIC_ASSERT(SHADOW_TILEMAP_MAX_CLIPMAP_LOD <= 8, "Update page packing")
1574 return ofs.x | (ofs.y << SHADOW_TILEMAP_MAX_CLIPMAP_LOD);
1575}
1581
1583{
1586 /* -- 12 bits -- */
1587 /* Max value is actually SHADOW_TILEMAP_MAX_CLIPMAP_LOD but we mask the bits. */
1588 tile.lod = (data >> 12u) & 15u;
1589 /* -- 16 bits -- */
1590 tile.lod_offset = shadow_lod_offset_unpack(data >> 16u);
1591 /* -- 32 bits -- */
1592 tile.is_valid = data != 0u;
1593#ifndef GPU_SHADER
1594 /* Make tests pass on CPU but it is not required for proper rendering. */
1595 if (tile.lod == 0) {
1596 tile.lod_offset.x = 0;
1597 }
1598#endif
1599 return tile;
1600}
1601
1603{
1604 if (!tile.is_valid) {
1605 return 0u;
1606 }
1607 /* Tag a valid tile of LOD0 valid by setting their offset to 1.
1608 * This doesn't change the sampling and allows to use of all bits for data.
1609 * This makes sure no valid packed tile is 0u. */
1610 if (tile.lod == 0) {
1611 tile.lod_offset.x = 1;
1612 }
1614 /* Max value is actually SHADOW_TILEMAP_MAX_CLIPMAP_LOD but we mask the bits. */
1615 data |= (tile.lod & 15u) << 12u;
1616 data |= shadow_lod_offset_pack(tile.lod_offset) << 16u;
1617 return data;
1618}
1619
1621{
1623 tile.page = tile_data.page;
1624 tile.lod = lod;
1625 tile.lod_offset = uint2(0, 0); /* Computed during tilemap amend phase. */
1626 /* At this point, it should be the case that all given tiles that have been tagged as used are
1627 * ready for sampling. Otherwise tile_data should be SHADOW_NO_DATA. */
1628 tile.is_valid = tile_data.is_used;
1629 return tile;
1630}
1631
1633 /* Number of shadow rays to shoot for each light. */
1635 /* Number of shadow samples to take for each shadow ray. */
1637 /* Bounding radius for a film pixel at 1 unit from the camera. */
1639 /* Global switch for jittered shadows. */
1641};
1643
1644
1645
1646/* -------------------------------------------------------------------- */
1649
1655
1656enum LightProbeShape : uint32_t {
1659};
1660
1661/* Sampling coordinates using UV space. */
1663 /* Offset in UV space to the start of the sampling space of the octahedron map. */
1665 /* Scaling of the squared UV space of the octahedron map. */
1666 float scale;
1667 /* Layer of the atlas where the octahedron map is stored. */
1668 float layer;
1669};
1671
1672/* Pixel read/write coordinates using pixel space. */
1674 /* Offset in pixel space to the start of the writing space of the octahedron map.
1675 * Note that the writing space is not the same as the sampling space as we have borders. */
1677 /* Size of the area in pixel that is covered by this probe mip-map. */
1679 /* Layer of the atlas where the octahedron map is stored. */
1681};
1683
1684
1707
1708
1716
1717/* Used for sphere probe spherical harmonics extraction. Output one for each thread-group
1718 * and do a sum afterward. Reduces bandwidth usage. */
1726
1733
1734
1735
1736/* -------------------------------------------------------------------- */
1739
1741 /* Actually stores radiance and world (sky) visibility. Stored normalized. */
1744 /* Accumulated weights per face. */
1747 float _pad0;
1748 float _pad1;
1749};
1751
1781
1832
1842
1857
1859 /* Offset in pixel to the start of the data inside the atlas texture. */
1861};
1862
1863#define IrradianceBrickPacked uint
1864
1866{
1867 uint2 data = (uint2(brick.atlas_coord) & 0xFFFFu) << uint2(0u, 16u);
1868 IrradianceBrickPacked brick_packed = data.x | data.y;
1869 return brick_packed;
1870}
1871
1873{
1874 IrradianceBrick brick;
1875 brick.atlas_coord = (uint2(brick_packed) >> uint2(0u, 16u)) & uint2(0xFFFFu);
1876 return brick;
1877}
1878
1880
1881/* -------------------------------------------------------------------- */
1884
1892
1893
1894
1895/* -------------------------------------------------------------------- */
1898
1910
1911
1912
1913/* -------------------------------------------------------------------- */
1916
1934
1962
1995
1996
1997
1998/* -------------------------------------------------------------------- */
2001
2018
2019
2020
2021/* -------------------------------------------------------------------- */
2024
2025#define SSS_SAMPLE_MAX 64
2026#define SSS_BURLEY_TRUNCATE 16.0
2027#define SSS_BURLEY_TRUNCATE_CDF 0.9963790093708328
2028#define SSS_TRANSMIT_LUT_SIZE 64.0
2029#define SSS_TRANSMIT_LUT_RADIUS 2.0
2030#define SSS_TRANSMIT_LUT_SCALE ((SSS_TRANSMIT_LUT_SIZE - 1.0) / float(SSS_TRANSMIT_LUT_SIZE))
2031#define SSS_TRANSMIT_LUT_BIAS (0.5 / float(SSS_TRANSMIT_LUT_SIZE))
2032#define SSS_TRANSMIT_LUT_STEP_RES 64.0
2033
2036 /* NOTE(fclem) Using float4 for alignment. */
2046};
2048
2049static inline float3 burley_setup(float3 radius, float3 albedo)
2050{
2051 /* TODO(fclem): Avoid constant duplication. */
2052 const float m_1_pi = 0.318309886183790671538;
2053
2054 float3 A = albedo;
2055 /* Diffuse surface transmission, equation (6). */
2056 float3 s = 1.9 - A + 3.5 * ((A - 0.8) * (A - 0.8));
2057 /* Mean free path length adapted to fit ancient Cubic and Gaussian models. */
2058 float3 l = 0.25 * m_1_pi * radius;
2059
2060 return l / s;
2061}
2062
2063static inline float3 burley_eval(float3 d, float r)
2064{
2065 /* Slide 33. */
2066 float3 exp_r_3_d;
2067 /* TODO(fclem): Vectorize. */
2068 exp_r_3_d.x = expf(-r / (3.0 * d.x));
2069 exp_r_3_d.y = expf(-r / (3.0 * d.y));
2070 exp_r_3_d.z = expf(-r / (3.0 * d.z));
2071 float3 exp_r_d = exp_r_3_d * exp_r_3_d * exp_r_3_d;
2072 /* NOTE:
2073 * - Surface albedo is applied at the end.
2074 * - This is normalized diffuse model, so the equation is multiplied
2075 * by 2*pi, which also matches `cdf()`.
2076 */
2077 return (exp_r_d + exp_r_3_d) / (4.0 * d);
2078}
2079
2081
2082/* -------------------------------------------------------------------- */
2085
2099
2105
2106
2115
2116
2117
2118/* -------------------------------------------------------------------- */
2121
2129
2130
2131
2132/* -------------------------------------------------------------------- */
2135
2136/* Combines data from several modules to avoid wasting binding slots. */
2151
2152
2153
2154/* -------------------------------------------------------------------- */
2157
2158#define UTIL_TEX_SIZE 64
2159#define UTIL_BTDF_LAYER_COUNT 16
2160/* Scale and bias to avoid interpolation of the border pixel.
2161 * Remap UVs to the border pixels centers. */
2162#define UTIL_TEX_UV_SCALE ((UTIL_TEX_SIZE - 1.0f) / UTIL_TEX_SIZE)
2163#define UTIL_TEX_UV_BIAS (0.5f / UTIL_TEX_SIZE)
2164
2165#define UTIL_BLUE_NOISE_LAYER 0
2166#define UTIL_SSS_TRANSMITTANCE_PROFILE_LAYER 1
2167#define UTIL_LTC_MAT_LAYER 2
2168#define UTIL_BSDF_LAYER 3
2169#define UTIL_BTDF_LAYER 4
2170#define UTIL_DISK_INTEGRAL_LAYER UTIL_SSS_TRANSMITTANCE_PROFILE_LAYER
2171#define UTIL_DISK_INTEGRAL_COMP 3
2172
2173#ifdef GPU_SHADER
2174
2175# if defined(GPU_FRAGMENT_SHADER)
2176# define UTIL_TEXEL float2(gl_FragCoord.xy)
2177# elif defined(GPU_COMPUTE_SHADER)
2178# define UTIL_TEXEL float2(gl_GlobalInvocationID.xy)
2179# elif defined(GPU_VERTEX_SHADER)
2180# define UTIL_TEXEL float2(gl_VertexID, 0)
2181# elif defined(GPU_LIBRARY_SHADER)
2182# define UTIL_TEXEL float2(0)
2183# endif
2184
2185/* Fetch texel. Wrapping if above range. */
2186float4 utility_tx_fetch(sampler2DArray util_tx, float2 texel, float layer)
2187{
2188 return texelFetch(util_tx, int3(int2(texel) % UTIL_TEX_SIZE, layer), 0);
2189}
2190
2191/* Sample at uv position. Filtered & Wrapping enabled. */
2192float4 utility_tx_sample(sampler2DArray util_tx, float2 uv, float layer)
2193{
2194 return textureLod(util_tx, float3(uv, layer), 0.0);
2195}
2196
2197/* Sample at uv position but with scale and bias so that uv space bounds lie on texel centers. */
2198float4 utility_tx_sample_lut(sampler2DArray util_tx, float2 uv, float layer)
2199{
2200 /* Scale and bias coordinates, for correct filtered lookup. */
2202 return textureLod(util_tx, float3(uv, layer), 0.0);
2203}
2204
2205/* Sample GGX BSDF LUT. */
2206float4 utility_tx_sample_bsdf_lut(sampler2DArray util_tx, float2 uv, float layer)
2207{
2208 /* Scale and bias coordinates, for correct filtered lookup. */
2210 layer = layer * UTIL_BTDF_LAYER_COUNT + UTIL_BTDF_LAYER;
2211
2212 float layer_floored;
2213 float interp = modf(layer, layer_floored);
2214
2215 float4 tex_low = textureLod(util_tx, float3(uv, layer_floored), 0.0);
2216 float4 tex_high = textureLod(util_tx, float3(uv, layer_floored + 1.0), 0.0);
2217
2218 /* Manual trilinear interpolation. */
2219 return mix(tex_low, tex_high, interp);
2220}
2221
2222/* Sample LTC or BSDF LUTs with `cos_theta` and `roughness` as inputs. */
2223float4 utility_tx_sample_lut(sampler2DArray util_tx, float cos_theta, float roughness, float layer)
2224{
2225 /* LUTs are parameterized by `sqrt(1.0 - cos_theta)` for more precision near grazing incidence.
2226 */
2227 float2 coords = float2(roughness, sqrt(clamp(1.0 - cos_theta, 0.0, 1.0)));
2228 return utility_tx_sample_lut(util_tx, coords, layer);
2229}
2230
2231#endif
2232
2233#ifdef EEVEE_PI
2234# undef EEVEE_PI
2235#endif
2236
2238
2239#if IS_CPP
2240
2283} // namespace blender::eevee
2284#endif
#define BLI_STATIC_ASSERT_ALIGN(st, align)
Definition BLI_assert.h:86
unsigned int uint
#define ENUM_OPERATORS(_type, _max)
int32_t bool32_t
@ GPU_SAMPLER_FILTERING_LINEAR
BMesh const char void * data
ATTR_WARN_UNUSED_RESULT const BMLoop * l
#define A
ccl_device_inline float cos_theta(const float3 w)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition btDbvt.cpp:52
#define sinf(x)
#define cosf(x)
#define expf(x)
#define tanf(x)
#define ceilf(x)
#define atanf(x)
#define floorf(x)
#define sqrtf(x)
#define SHADOW_PAGE_PER_ROW
#define SHADOW_TILEMAP_MAX_CLIPMAP_LOD
#define SHADOW_PAGE_PER_COL
#define SHADOW_MAX_PAGE
#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 EEVEE_PI
#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()
TEX_TEMPLATE DataVec texelFetch(T, IntCoord, int) RET
TEX_TEMPLATE DataVec textureLod(T, FltCoord, float) RET
#define modf
SamplerBase< float, 2, false, true > sampler2DArray
bool all(VecOp< bool, D >) RET
#define sqrt
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET
#define mix(a, b, c)
Definition hash.h:35
const ccl_global KernelWorkTile * tile
ccl_device_inline float interp(const float a, const float b, const float t)
Definition math_base.h:502
ccl_device_inline float2 power(const float2 v, const float e)
static ulong * next
BLI_STATIC_ASSERT(MBC_BATCH_LEN< 64, "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)
draw::UniformBuffer< MotionBlurData > MotionBlurDataBuf
draw::StorageArrayBuffer< LightData, LIGHT_CHUNK > LightDataBuf
constexpr GPUSamplerState no_filter
draw::StorageBuffer< ShadowPagesInfoData > ShadowPagesInfoDataBuf
draw::UniformBuffer< DepthOfFieldData > DepthOfFieldDataBuf
draw::StorageArrayBuffer< ShadowTileDataPacked, SHADOW_MAX_TILE, true > ShadowTileDataBuf
static int2 shadow_cascade_grid_offset(int2 base_offset, int level_relative)
static bool is_panoramic(eCameraType type)
draw::StorageArrayBuffer< ShadowTileMapClip, SHADOW_MAX_TILEMAP, true > ShadowTileMapClipBuf
draw::StorageArrayBuffer< uint, CULLING_ZBIN_COUNT, true > LightCullingZbinBuf
draw::StorageArrayBuffer< float, LIGHT_CHUNK, true > LightCullingZdistBuf
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)
draw::StorageBuffer< DrawCommand, true > DrawIndirectBuf
draw::StorageArrayBuffer< uint2, SHADOW_MAX_PAGE, true > ShadowPageCacheBuf
static int light_local_tilemap_count(LightData light)
static float3 transform_point_inversed(Transform t, float3 point)
draw::StorageArrayBuffer< PlanarProbeDisplayData > PlanarProbeDisplayDataBuf
draw::StorageArrayBuffer< uint, LIGHT_CHUNK, true > LightCullingTileBuf
draw::StorageArrayBuffer< ShadowRenderView, SHADOW_VIEW_MAX, true > ShadowRenderViewBuf
static float3 transform_x_axis(Transform t)
draw::StorageArrayBuffer< uint, 1024, true > ClosureTileBuf
constexpr GPUSamplerState with_filter
draw::StorageBuffer< SamplingData > SamplingDataBuf
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)
draw::StorageBuffer< LightCullingData > LightCullingDataBuf
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)
draw::StorageBuffer< SurfelListInfoData > SurfelListInfoBuf
static float3 light_y_axis(LightData light)
draw::StorageArrayBuffer< uint, LIGHT_CHUNK, true > LightCullingKeyBuf
static bool is_sun_light(eLightType type)
static ShadowTileData shadow_tile_unpack(ShadowTileDataPacked data)
draw::StorageArrayBuffer< Surfel, 64 > SurfelBuf
static int light_tilemap_max_get(LightData light)
static uint2 shadow_lod_offset_unpack(uint data)
draw::StorageBuffer< MotionBlurTileIndirection, true > MotionBlurTileIndirectionBuf
static float3 transform_z_axis(Transform t)
draw::StorageArrayBuffer< ScatterRect, 16, true > DepthOfFieldScatterListBuf
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)
draw::StorageArrayBuffer< SphereProbeDisplayData > SphereProbeDisplayDataBuf
draw::StorageArrayBuffer< VelocityIndex, 16 > VelocityIndexBuf
draw::UniformArrayBuffer< PlanarProbeData, PLANAR_PROBE_MAX > PlanarProbeDataBuf
static uint3 shadow_page_unpack(uint data)
draw::UniformArrayBuffer< VolumeProbeData, IRRADIANCE_GRID_MAX > VolumeProbeDataBuf
static bool is_oriented_disk_light(eLightType type)
draw::StorageBuffer< AOVsInfoData > AOVsInfoDataBuf
draw::StorageArrayBuffer< float4, 16, true > VelocityGeometryBuf
static float3 light_x_axis(LightData light)
static IrradianceBrick irradiance_brick_unpack(IrradianceBrickPacked brick_packed)
draw::StorageBuffer< CaptureInfoData > CaptureInfoBuf
draw::StorageArrayBuffer< SurfelRadiance, 64 > SurfelRadianceBuf
draw::StorageArrayBuffer< float2, 16 > CryptomatteObjectBuf
draw::UniformBuffer< UniformData > UniformDataBuf
draw::StorageArrayBuffer< float4x4, 16 > VelocityObjectBuf
RayTraceTileBuf SubsurfaceTileBuf
static float3 burley_setup(float3 radius, float3 albedo)
static float coc_radius_from_camera_depth(DepthOfFieldData dof, float depth)
draw::UniformBuffer< CameraData > CameraDataBuf
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)
draw::StorageBuffer< ShadowStatistics > ShadowStatisticsBuf
draw::UniformBuffer< ClipPlaneData > ClipPlaneBuf
draw::StorageVectorBuffer< ShadowTileMapData, SHADOW_MAX_TILEMAP > ShadowTileMapDataBuf
static ShadowSamplingTile shadow_sampling_tile_create(ShadowTileData tile_data, uint lod)
draw::StorageArrayBuffer< uint, 1024, true > RayTraceTileBuf
draw::UniformArrayBuffer< SphereProbeData, SPHERE_PROBE_MAX > SphereProbeDataBuf
static bool is_point_light(eLightType type)
static int sampling_web_sample_count_get(int web_density, int in_ring_count)
draw::StorageVectorBuffer< IrradianceBrickPacked, 16 > IrradianceBrickBuf
static float circle_to_polygon_radius(float sides_count, float theta)
static ShadowSamplingTile shadow_sampling_tile_unpack(ShadowSamplingTilePacked data)
draw::StorageBuffer< DispatchCommand > DispatchIndirectBuf
draw::StorageVectorBuffer< uint, SHADOW_MAX_PAGE > ShadowPageHeapBuf
static float3 transform_location(Transform t)
T clamp(const T &a, const T &min, const T &max)
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
VecBase< uint32_t, 4 > uint4
VecBase< uint32_t, 3 > uint3
MatBase< float, 4, 4 > float4x4
MatBase< float, 3, 4 > float3x4
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< int32_t, 3 > int3
MatBase< float, 3, 3 > float3x3
VecBase< float, 3 > float3
#define saturate(a)
Definition smaa.cc:315
static constexpr GPUSamplerState default_sampler()
float4 y
Definition transform.h:23
float4 x
Definition transform.h:23
float4 z
Definition transform.h:23
ePassStorageType display_storage_type
FilmSample samples[FILM_PRECOMP_SAMPLE_MAX]
float dimensions[SAMPLING_DIMENSION_COUNT]
ReflectionProbeLowFreqLight low_freq_light
SurfelRadiance radiance_indirect[2]