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::planar
3#ifdef PRECOMPUTE_COVARIANCE_3D
4#import bevy_gaussian_splatting::bindings::{
5 position_visibility,
6 spherical_harmonics,
7 covariance_3d_opacity,
8}
9#else
10#import bevy_gaussian_splatting::bindings::{
11 position_visibility,
12 spherical_harmonics,
13 rotation,
14 rotation_scale_opacity,
15 scale_opacity,
17#endif
19#import bevy_gaussian_splatting::spherical_harmonics::{
20 spherical_harmonics_lookup,
21 srgb_to_linear,
25#ifdef PLANAR_F16
27fn get_color(
28 index: u32,
29 ray_direction: vec3<f32>,
30) -> vec3<f32> {
31 let sh = get_spherical_harmonics(index);
32 let color = spherical_harmonics_lookup(ray_direction, sh);
33 return srgb_to_linear(color);
36fn get_position(index: u32) -> vec3<f32> {
37 return position_visibility[index].xyz;
40fn get_spherical_harmonics(index: u32) -> array<f32, #{SH_COEFF_COUNT}> {
41 var coefficients: array<f32, #{SH_COEFF_COUNT}>;
43 for (var i = 0u; i < #{HALF_SH_COEFF_COUNT}u; i = i + 1u) {
44 let values = unpack2x16float(spherical_harmonics[index][i]);
46 coefficients[i * 2u] = values[0];
47 coefficients[i * 2u + 1u] = values[1];
48 }
50 return coefficients;
53#ifdef PRECOMPUTE_COVARIANCE_3D
54 fn get_cov3d(index: u32) -> array<f32, 6> {
55 let c0 = unpack2x16float(covariance_3d_opacity[index].x);
56 let c1 = unpack2x16float(covariance_3d_opacity[index].y);
57 let c2 = unpack2x16float(covariance_3d_opacity[index].z);
59 var cov3d: array<f32, 6>;
61 cov3d[0] = c0.y;
62 cov3d[1] = c0.x;
63 cov3d[2] = c1.y;
64 cov3d[3] = c1.x;
65 cov3d[4] = c2.y;
66 cov3d[5] = c2.x;
68 return cov3d;
69 }
70#else
71 fn get_rotation(index: u32) -> vec4<f32> {
72 let q0 = unpack2x16float(rotation_scale_opacity[index].x);
73 let q1 = unpack2x16float(rotation_scale_opacity[index].y);
75 return vec4<f32>(
76 q0.yx,
77 q1.yx,
78 );
79 }
81 fn get_scale(index: u32) -> vec3<f32> {
82 let s0 = unpack2x16float(rotation_scale_opacity[index].z);
83 let s1 = unpack2x16float(rotation_scale_opacity[index].w);
85 return vec3<f32>(
86 s0.yx,
87 s1.y,
88 );
89 }
90#endif
92fn get_opacity(index: u32) -> f32 {
93#ifdef PRECOMPUTE_COVARIANCE_3D
94 return unpack2x16float(covariance_3d_opacity[index].w).y;
95#else
96 return unpack2x16float(rotation_scale_opacity[index].w).x;
97#endif
100fn get_visibility(index: u32) -> f32 {
101 return position_visibility[index].w;
103#endif
106#ifdef PLANAR_F32
107fn get_color(
108 index: u32,
109 ray_direction: vec3<f32>,
110) -> vec3<f32> {
111 let sh = get_spherical_harmonics(index);
112 let color = spherical_harmonics_lookup(ray_direction, sh);
113 return srgb_to_linear(color);
116fn get_position(index: u32) -> vec3<f32> {
117 return position_visibility[index].xyz;
120fn get_spherical_harmonics(index: u32) -> array<f32, #{SH_COEFF_COUNT}> {
121 return spherical_harmonics[index];
124fn get_rotation(index: u32) -> vec4<f32> {
125 return rotation[index];
128fn get_scale(index: u32) -> vec3<f32> {
129 return scale_opacity[index].xyz;
132fn get_opacity(index: u32) -> f32 {
133 return scale_opacity[index].w;
136fn get_visibility(index: u32) -> f32 {
137 return position_visibility[index].w;
139#endif
Contents