20#define LIGHT_NO_SHADOW -1
73#define LOCAL_LIGHT_COMMON \
76 packed_float3 shadow_position; \
79 float shadow_radius; \
83 float influence_radius_max; \
85 float influence_radius_invsqr_surface; \
86 float influence_radius_invsqr_volume; \
120struct LightAreaData {
142 int2 clipmap_base_offset_neg;
143 int2 clipmap_base_offset_pos;
160#define SAFE_UNION_ACCESS 0
164# define USE_LIGHT_UNION 1
165#elif defined(GPU_BACKEND_METAL) && !SAFE_UNION_ACCESS
167# define USE_LIGHT_UNION 1
170# define USE_LIGHT_UNION 0
204 uint2 light_set_membership;
208 uint2 shadow_set_membership;
242# define CHECK_TYPE_PAIR(a, b)
243# define CHECK_TYPE(a, b)
244# define FLOAT_AS_INT floatBitsToInt
245# define INT_AS_FLOAT intBitsToFloat
246# define TYPECAST_NOOP
249# define FLOAT_AS_INT float_as_int
250# define INT_AS_FLOAT int_as_float
251# define TYPECAST_NOOP
261# if defined(GPU_FRAGMENT_SHADER)
262# define GARBAGE_VALUE sin(gl_FragCoord.x + gl_FragCoord.y)
263# elif defined(GPU_COMPUTE_SHADER)
264# define GARBAGE_VALUE \
265 sin(float(gl_GlobalInvocationID.x + gl_GlobalInvocationID.y + gl_GlobalInvocationID.z))
267# define GARBAGE_VALUE sin(float(gl_VertexID))
274# define GARBAGE_VALUE 0.0f
277# define SAFE_BEGIN(dst_type, src_type, src_, check) \
278 src_type _src = src_; \
280 bool _validity_check = check; \
281 float _garbage = GARBAGE_VALUE;
284# define SAFE_ASSIGN_LIGHT_TYPE_CHECK(_type, _value) \
285 (_validity_check ? (_value) : _type(_garbage))
287# define SAFE_BEGIN(dst_type, src_type, src_, check) \
288 UNUSED_VARS(check); \
289 src_type _src = src_; \
292# define SAFE_ASSIGN_LIGHT_TYPE_CHECK(_type, _value) _value
296# define DATA_MEMBER local
298# define DATA_MEMBER do_not_access_directly
301#define SAFE_READ_BEGIN(dst_type, light, check) \
302 SAFE_BEGIN(dst_type, LightLocalData, light.DATA_MEMBER, check)
303#define SAFE_READ_END() _dst
305#define SAFE_WRITE_BEGIN(src_type, src, check) SAFE_BEGIN(LightLocalData, src_type, src, check)
306#define SAFE_WRITE_END(light) light.DATA_MEMBER = _dst;
308#define ERROR_OFS(a, b) "Offset of " STRINGIFY(a) " mismatch offset of " STRINGIFY(b)
311#define SAFE_ASSIGN(a, reinterpret_fn, in_type, b) \
312 CHECK_TYPE_PAIR(_src.b, in_type(_dst.a)); \
313 CHECK_TYPE_PAIR(_dst.a, reinterpret_fn(_src.b)); \
314 _dst.a = reinterpret_fn(SAFE_ASSIGN_LIGHT_TYPE_CHECK(in_type, _src.b)); \
315 BLI_STATIC_ASSERT(offsetof(decltype(_dst), a) == offsetof(decltype(_src), b), ERROR_OFS(a, b))
317#define SAFE_ASSIGN_FLOAT(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float, b);
318#define SAFE_ASSIGN_FLOAT2(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float2, b);
319#define SAFE_ASSIGN_FLOAT3(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, float3, b);
320#define SAFE_ASSIGN_INT(a, b) SAFE_ASSIGN(a, TYPECAST_NOOP, int, b);
321#define SAFE_ASSIGN_FLOAT_AS_INT(a, b) SAFE_ASSIGN(a, FLOAT_AS_INT, float, b);
322#define SAFE_ASSIGN_INT_AS_FLOAT(a, b) SAFE_ASSIGN(a, INT_AS_FLOAT, int, b);
324#if !USE_LIGHT_UNION || !defined(GPU_SHADER)
328# if !defined(GPU_SHADER)
340 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
341 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
358 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
359 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
384 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_surface, influence_radius_invsqr_surface)
385 SAFE_ASSIGN_FLOAT(influence_radius_invsqr_volume, influence_radius_invsqr_volume)
427# if !defined(GPU_SHADER)
434# define light_local_data_get(light) light.local
435# define light_spot_data_get(light) light.spot
436# define light_area_data_get(light) light.area
437# define light_sun_data_get(light) light.sun
445#undef SAFE_ASSIGN_LIGHT_TYPE_CHECK
448#undef SAFE_ASSIGN_FLOAT
449#undef SAFE_ASSIGN_FLOAT2
450#undef SAFE_ASSIGN_INT
451#undef SAFE_ASSIGN_FLOAT_AS_INT
452#undef SAFE_ASSIGN_INT_AS_FLOAT
458 return light.tilemap_index +
481#define CULLING_MAX_ITEM 65536
483#define CULLING_ZBIN_COUNT 4096
485#define CULLING_TILE_RES 16
#define BLI_STATIC_ASSERT_ALIGN(st, align)
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
#define SAFE_ASSIGN_FLOAT(a, b)
#define SAFE_ASSIGN_INT_AS_FLOAT(a, b)
#define light_area_data_get(light)
#define SAFE_WRITE_END(light)
#define SAFE_ASSIGN_FLOAT3(a, b)
#define SAFE_WRITE_BEGIN(src_type, src, check)
#define light_sun_data_get(light)
#define light_local_data_get(light)
#define light_spot_data_get(light)
#define LOCAL_LIGHT_COMMON
#define SAFE_READ_BEGIN(dst_type, light, check)
#define SAFE_ASSIGN_FLOAT_AS_INT(a, b)
#define SAFE_ASSIGN_FLOAT2(a, b)
#define SAFE_ASSIGN_INT(a, b)
ccl_device_inline float2 power(const float2 v, const float e)
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)
static bool is_sphere_light(eLightType type)
static bool is_area_light(eLightType type)
static int light_local_tilemap_count(LightData light)
static float3 transform_x_axis(Transform t)
static float3 light_position_get(LightData light)
static float3 light_y_axis(LightData light)
static bool is_sun_light(eLightType type)
static int light_tilemap_max_get(LightData light)
static float3 transform_z_axis(Transform t)
static float3 light_z_axis(LightData light)
static bool is_spot_light(eLightType type)
static float3 transform_y_axis(Transform t)
static bool is_oriented_disk_light(eLightType type)
static float3 light_x_axis(LightData light)
static bool is_local_light(eLightType type)
static bool is_point_light(eLightType type)
static float3 transform_location(Transform t)
VecBase< uint32_t, 2 > uint2
VecBase< float, 4 > float4
VecBase< int32_t, 2 > int2
VecBase< float, 2 > float2
VecBase< float, 3 > float3
LOCAL_LIGHT_COMMON float _pad1
LOCAL_LIGHT_COMMON float _pad1