Search across packages, versions, files, declarations, and comments. Use multiple terms to narrow results (AND), and add @vertex, @fragment, or @compute to filter by shader stage.
1#define_import_path bevy_gaussian_splatting::gaussian_3d
3#ifdef GAUSSIAN_3D
4#import bevy_gaussian_splatting::bindings::{
5 view,
6 gaussian_uniforms,
7}
8#import bevy_gaussian_splatting::helpers::{
9 cov2d,
10 get_rotation_matrix,
11 get_scale_matrix,
14#ifdef PACKED
15 #ifdef PRECOMPUTE_COVARIANCE_3D
16 #import bevy_gaussian_splatting::packed::{
17 get_cov3d,
18 }
19 #else
20 #import bevy_gaussian_splatting::packed::{
21 get_rotation,
22 get_scale,
23 }
24 #endif
25#else ifdef BUFFER_STORAGE
26 #ifdef PRECOMPUTE_COVARIANCE_3D
27 #import bevy_gaussian_splatting::planar::{
28 get_cov3d,
29 }
30 #else
31 #import bevy_gaussian_splatting::planar::{
32 get_rotation,
33 get_scale,
34 }
35 #endif
36#else ifdef BUFFER_TEXTURE
37 #ifdef PRECOMPUTE_COVARIANCE_3D
38 #import bevy_gaussian_splatting::texture::{
39 get_cov3d,
40 }
41 #else
42 #import bevy_gaussian_splatting::texture::{
43 get_rotation,
44 get_scale,
45 }
46 #endif
47#endif
49fn compute_cov3d(scale: vec3<f32>, rotation: vec4<f32>) -> array<f32, 6> {
50 let S = get_scale_matrix(scale);
52 let T = mat3x3<f32>(
53 gaussian_uniforms.transform[0].xyz,
54 gaussian_uniforms.transform[1].xyz,
55 gaussian_uniforms.transform[2].xyz,
56 );
58 let R = get_rotation_matrix(rotation);
60 let M = S * R;
61 let Sigma = transpose(M) * M;
62 let TS = T * Sigma * transpose(T);
64 return array<f32, 6>(
65 TS[0][0],
66 TS[0][1],
67 TS[0][2],
68 TS[1][1],
69 TS[1][2],
70 TS[2][2],
71 );
74fn compute_cov2d_3dgs(
75 position: vec3<f32>,
76 index: u32,
77) -> vec3<f32> {
78#ifdef PRECOMPUTE_COVARIANCE_3D
79 let cov3d = get_cov3d(index);
80#else
81 let rotation = get_rotation(index);
82 let scale = get_scale(index);
84 let cov3d = compute_cov3d(scale, rotation);
85#endif
87 return cov2d(position, cov3d);
90#endif // GAUSSIAN_3D
Contents