70 N.xy =
N.z >= 0.0f ?
N.xy :
73 N.xy =
N.xy * 0.5f + 0.5f;
83 float t =
clamp(-
N.z, 0.0f, 1.0f);
112 pu.
x = pack.x & 0x3FFFFFu;
113 pu.
y = ((pack.x >> 22) & 0x0003FFu) |
114 ((pack.y & 0x000FFFu) << 10);
115 pu.
z = ((pack.y >> 12) & 0x0FFFFFu) |
116 ((pack.z & 0x000003u) << 20);
129 ru.
x = (pack.z >> 2) & 0x0001FFu;
130 ru.
y = (pack.z >> 11u) & 0x0001FFu;
131 ru.
z = (pack.z >> 20u) & 0x0001FFu;
144 su.
x = ((pack.z >> 29) & 0x000007u) |
145 ((pack.w & 0x00003Fu) << 3);
146 su.
y = (pack.w >> 6) & 0x0001FFu;
147 su.
z = (pack.w >> 15) & 0x0001FFu;
163 uint au = (pack.w >> 24) & 0x0000FFu;
164 float a =
float(au) / 255.0f;
174 return uint3(t, t >> 8, t >> 16) & 0xFFu;
178 return uint3(t >> 8, t >> 16, t >> 24) & 0xFFu;
182 return uint3(t1 >> 24, t2, t2 >> 8) & 0xFFu;
186 return uint3(t1 >> 16, t1 >> 24, t2) & 0xFFu;
208 return float2(-1.0, -1.0);
210 return float2(1.0, -1.0) * winding_order_mult;
212 return float2(-1.0, 1.0) * winding_order_mult;
247 if (axis_0_len == 0.0f && axis_1_len == 0.0f) {
251 axis_0_len =
clamp(axis_0_len, 0.0f, 1.0f);
252 axis_1_len =
clamp(axis_1_len, 0.0f, 1.0f);
255 uint data = uint(
clamp(axis_0_dir.
x, 0.0f, 1.0f) * 1023.0f) |
256 (uint(
clamp(axis_0_len, 0.0f, 1.0f) * 2047.0f) << 10u) |
257 (uint(
clamp(axis_1_len, 0.0f, 1.0f) * 2047.0f) << 21u);
264 float axis_0_dir =
float(data & 0x3FFu) / 1023.0f;
265 float axis_0_len =
float((data >> 10u) & 0x7FFu) / 2047.0f;
266 float axis_1_len =
float((data >> 21u) & 0x7FFu) / 2047.0f;
271 tuple.
axis_0 = axis * axis_0_len;
331 const float tan_fov_x = 1.0f / view.
winmat[0][0];
332 const float tan_fov_y = 1.0f / view.
winmat[1][1];
333 const float lim_x = 1.3f * tan_fov_x;
334 const float lim_y = 1.3f * tan_fov_y;
335 const float focal_x = 0.5f * view.
winmat[0][0];
336 const float focal_y = 0.5f * view.
winmat[1][1];
341 vP.
x =
clamp(vP.
x / vP.
z, -lim_x, lim_x) * vP.
z;
342 vP.
y =
clamp(vP.
y / vP.
z, -lim_y, lim_y) * vP.
z;
348 float3(0.0f, focal_y / vP.
z, -(focal_y * vP.
y) / (vP.
z * vP.
z)),
359 float3(covmat_3d[0][1], covmat_3d[1][1], covmat_3d[1][2]),
360 float3(covmat_3d[0][2], covmat_3d[1][2], covmat_3d[2][2]));
371 float3 covmat_2d_v =
float3(covmat_2d[0][0], covmat_2d[0][1], covmat_2d[1][1]);
381 constexpr float std_dev = 3.0f;
383 const float mid = 0.5f * (covmat_2d_v.
x + covmat_2d_v.
z);
384 const float radius =
length(
float2((covmat_2d_v.
x - covmat_2d_v.
z) * 0.5f, covmat_2d_v.
y));
386 const float lambda_1 = mid + radius;
387 const float lambda_2 =
max(mid - radius, 1e-8f);
390 const float2 axis_0 =
min(std_dev *
sqrt(lambda_1), 1.0) * diag;
406 return R *
float3(1.0f, 0.0f, 0.0f);
409 return R *
float3(0.0f, 1.0f, 0.0f);
411 return R *
float3(0.0f, 0.0f, 1.0f);
413 const float norm = 1.0f / (rotation.x * rotation.x + rotation.y * rotation.y +
414 rotation.z * rotation.z + rotation.w * rotation.w);
416 const float a = rotation.w;
417 const float b = rotation.x;
418 const float c = rotation.y;
419 const float d = rotation.z;
422 return float3(a * a +
b *
b - c * c - d * d, 2.0f * (a * d +
b * c), 2.0f * (
b * d - a * c)) *
426 return float3(2.0f * (
b * c - a * d), a * a -
b *
b + c * c - d * d, 2.0f * (a *
b + c * d)) *
429 return float3(2.0f * (a * c +
b * d), 2.0f * (c * d - a *
b), a * a -
b *
b - c * c + d * d) *
495 Gaussian get_gaussian(uint gs_id)
const
514 if constexpr (
false) {
516 if (prepass_data.
x == 0u) {
524 shape.wP =
object.point_object_to_world(shape.mean);
528 const Gaussian gs = get_gaussian(shape.id);
535 float3 wP =
object.point_object_to_world(gs.mean);
537 float3 wN =
object.normal_object_to_world(lN);
542 shape.mean = gs.mean;
548 float2 ss_delta = shape.shape_offset.x * axes.axis_0 + shape.shape_offset.y * axes.axis_1;
552 shape.hP.xy += ss_delta * shape.hP.w;
591 gs.
wP =
object.point_object_to_world(gs.
mean);
601 return get_splat_implementation(vert_id,
object, view);
SIMD_FORCE_INLINE btScalar norm() const
Return the norm (length) of the vector.
#define DRW_GSPLAT_SHAPE_DATA_TEX_SLOT
#define DRW_GSPLAT_RADIANCE_COMP_TEX_SLOT
#define DRW_GSPLAT_STRIP_TILE_SIZE
#define DRW_GSPLAT_ELLIPSE_COMP_TEX_SLOT
#define DRW_OBJ_DATA_INFO_UBO_SLOT
VecBase< bool, D > greaterThanEqual(VecOp< T, D >, VecOp< T, D >) RET
bool any(VecOp< bool, D >) RET
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
constexpr T inversesqrt(T) RET
float2 unpackSnorm2x16(uint) RET
bool all(VecOp< bool, D >) RET
MatBase< R, C > transpose(MatBase< C, R >) RET
VecBase< bool, D > equal(VecOp< T, D >, VecOp< T, D >) RET
constexpr T clamp(T, U, U) RET
float length(VecOp< float, D >) RET
SamplerBase< uint, 1 > usamplerBuffer
TEX_TEMPLATE DataVec texelFetch(T, IntCoord, int) RET
SamplerBase< float, 1 > samplerBuffer
float cos_from_sin(float s)
float3x3 scale(float3x3 mat, float2 scale)
float2x2 from_scale(float2 scale)
float3x3 quaternion_to_float3x3(Quaternion q)
VecT normalize_and_get_length(VecT vector, float &out_length)
float reduce_add(float2 a)
VecBase< uint32_t, 4 > uint4
MatBase< float, 4, 4 > float4x4
VecBase< float, 2 > float2
VecBase< float, 3 > float3
uint3 slice_tuple_xynz(uint t1, uint t2)
float unpack_gaussian_opacity(uint4 pack)
float3 unpack_normal_octahedral(float2 p)
Quaternion unpack_gaussian_rotation(uint4 pack)
uint get_shape_id(uint vert_id)
uint3 slice_tuple_nxyz(uint t)
bool get_shape_winding_ccw(uint vert_id)
uint3 slice_tuple_xnyz(uint t1, uint t2)
float3 unpack_gaussian_mean(uint4 pack, ScalingRange data_range)
float4 unpack_quaternion_3_to_4(float3 v)
float2 get_shape_offset(uint vert_id)
float3 unpack_gaussian_scale(uint4 pack, ScalingRange data_range)
float2 pack_normal_octahedral(float3 N)
uint3 slice_tuple_xyzn(uint t)
float3x3 get_rot_scale_mat(Quaternion rotation, float3 scale)
float3 project_gaussian(ObjectMatrices object, ViewMatrices view, Gaussian gs)
float evaluate_gaussian(float2 x_min_mu, float opacity)
AxisTuple covmat_to_axes(float3 covmat_2d_v)
float3 get_planar_normal(Quaternion rotation, float3 scale)
float3x3 get_covmat(Quaternion rotation, float3 scale)
double Gaussian(double x, double sigma)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
struct ScalingRange splat_mean_range
struct ScalingRange splat_scale_range
static Quaternion from_float4(float4 v)
float3 scale_from_unit(float3 value) const
bool is_perspective() const
float4 point_world_to_homogenous(float3 P) const
float3 point_homogeneous_to_world(float4 hP) const
float3 world_incident_vector(float3 P) const
static AxisTuple unpack(uint data)
static AxisTuple from(float2 axis_0, float2 axis_1)
static Gaussian unpack(uint gs_id, uint4 data, ScalingRange mean_range, ScalingRange scale_range)
static PointShape culled()
const GSplatInfos & infos
const samplerBuffer radiance_comp_tx
const usamplerBuffer ellipses_comp_tx
float3 get_radiance(uint gs_id) const
float get_opacity(uint gs_id) const
PointShape get_point(uint vert_id, ObjectMatrices object, ViewMatrices view) const
const usamplerBuffer shape_data_tx
SplatShape get_splat(uint vert_id, ObjectMatrices object, ViewMatrices view) const
static SplatShape culled()
CCL_NAMESPACE_BEGIN struct Window V