@@ -48,7 +48,7 @@ layout(std430, set = 2, binding = 0) writeonly buffer DrawIndirect {
4848};
4949
5050layout(std430, set = 2, binding = 1) writeonly buffer Instances {
51- vec4 instances[]; // (N, 12). 3 for ndc position, 1 padding, 4 for scale rot, 4 for color.
51+ vec4 instances[]; // (N, 12). 3 for ndc position, 1 padding, 4 for rot scale , 4 for color.
5252};
5353
5454layout(std430, set = 2, binding = 2) buffer VisiblePointCount {
@@ -130,10 +130,14 @@ void main() {
130130 float D = sqrt((a - b) * (a - b) + 4.f * c * c);
131131 float s0 = sqrt(0.5f * (a + b + D));
132132 float s1 = sqrt(0.5f * (a + b - D));
133- // decompose to R^T S^2 R
133+ // decompose to R S^2 R^T
134134 float sin2t = 2.f * c / D;
135135 float cos2t = (a - b) / D;
136136 float theta = atan(sin2t, cos2t) / 2.f;
137+ float cos_theta = cos(theta);
138+ float sin_theta = sin(theta);
139+ // R*S
140+ mat2 rot_scale = mat2(s0 * cos_theta, s0 * sin_theta, -s1 * sin_theta, s1 * cos_theta);
137141
138142 pos = projection * pos;
139143 pos = pos / pos.w;
@@ -184,6 +188,6 @@ void main() {
184188 float opacity = gaussian_opacity[id];
185189
186190 instances[inverse_id * 3 + 0].xyz = pos.xyz;
187- instances[inverse_id * 3 + 1] = vec4(s0, s1, cos(theta), sin(theta) );
191+ instances[inverse_id * 3 + 1] = vec4(rot_scale[0], rot_scale[1] );
188192 instances[inverse_id * 3 + 2] = vec4(color, opacity);
189193}
0 commit comments