46inline constexpr std::array<void (*)(MutableSpan<float3>), 4>
47 ANALYTIC_ROTATE_PLUS_PI_HALF_ABOUT_X_TABLE = {
48 [](
const MutableSpan<float3> p) {
50 const float3 t0 = p[0], t1 = p[1], t2 = p[2];
55 [](
const MutableSpan<float3> p) {
57 std::array<float3, 5> s;
59 const float s3 = std::sqrt(3.0f);
62 p[2] = -0.5f * s[2] - (s3 / 2.0f) * s[4];
64 p[4] = -(s3 / 2.0f) * s[2] + 0.5f * s[4];
66 [](
const MutableSpan<float3> p) {
68 std::array<float3, 7> s{};
70 const float s15 = std::sqrt(15.0f);
71 p[0] = -std::sqrt(5.0f / 8.0f) * s[3] + std::sqrt(3.0f / 8.0f) * s[5];
73 p[2] = -std::sqrt(3.0f / 8.0f) * s[3] - std::sqrt(5.0f / 8.0f) * s[5];
74 p[3] = std::sqrt(5.0f / 8.0f) * s[0] + std::sqrt(3.0f / 8.0f) * s[2];
75 p[4] = -0.25f * s[4] - (s15 / 4.0f) * s[6];
76 p[5] = -std::sqrt(3.0f / 8.0f) * s[0] + std::sqrt(5.0f / 8.0f) * s[2];
77 p[6] = -(s15 / 4.0f) * s[4] + 0.25f * s[6];
79 [](
const MutableSpan<float3> p) {
81 std::array<float3, 9> s{};
83 const float s2 = std::sqrt(2.0f);
84 const float s5 = std::sqrt(5.0f);
85 const float s7 = std::sqrt(7.0f);
86 const float s14 = std::sqrt(14.0f);
87 const float s35 = std::sqrt(35.0f);
88 p[0] = -(s14 / 4.0f) * s[5] + (s2 / 4.0f) * s[7];
89 p[1] = -0.75f * s[1] + (s7 / 4.0f) * s[3];
90 p[2] = -(
s2 / 4.0f) * s[5] - (s14 / 4.0f) * s[7];
91 p[3] = (s7 / 4.0f) * s[1] + 0.75f * s[3];
92 p[4] = (3.0f / 8.0f) * s[4] + (s5 / 4.0f) * s[6] + (s35 / 8.0f) * s[8];
93 p[5] = (s14 / 4.0f) * s[0] + (s2 / 4.0f) * s[2];
94 p[6] = (s5 / 4.0f) * s[4] + 0.5f * s[6] - (s7 / 4.0f) * s[8];
95 p[7] = -(
s2 / 4.0f) * s[0] + (s14 / 4.0f) * s[2];
96 p[8] = (s35 / 8.0f) * s[4] - (s7 / 4.0f) * s[6] + 0.125f * s[8];
119 LocalData &tls = all_tls.local();
120 for (const int i : range) {
121 positions[i] = {positions[i].x, -positions[i].z, positions[i].y};
125 rotations[i] = math::Quaternion(M_SQRT1_2 * (rotations[i].w - rotations[i].x),
126 M_SQRT1_2 * (rotations[i].x + rotations[i].w),
127 M_SQRT1_2 * (rotations[i].y - rotations[i].z),
128 M_SQRT1_2 * (rotations[i].z + rotations[i].y));
130 if (sh_degrees == 0) {
134 if (tls.sh_data.is_empty()) {
135 tls.sh_data.reinitialize(sh_attrs.size());
138 MutableSpan<float3> sh_data = tls.sh_data;
139 gsplat::get_spherical_harmonics(sh_attrs, i, sh_data);
140 for (int band = 0; band < sh_degrees; ++band) {
141 ANALYTIC_ROTATE_PLUS_PI_HALF_ABOUT_X_TABLE[band](
142 sh_data.slice(band * (band + 2), 2 * (band + 1) + 1));
144 gsplat::set_spherical_harmonics(sh_attrs, i, sh_data);
constexpr IndexRange()=default
constexpr MutableSpan()=default
constexpr int64_t size() const
int degree_for_dimension(const int dimension)
void convert_axis_to_blender(const MutableSpan< float3 > positions, const MutableSpan< math::Quaternion > rotations, const Span< MutableSpan< float3 > > sh_attrs)
void parallel_for(const IndexRange range, const int64_t grain_size, const Function &function, const TaskSizeHints &size_hints=detail::TaskSizeHints_Static(1))
VecBase< float, 3 > float3
void s2(float4 &a, float4 &b)