1#define_import_path bevy_gaussian_splatting::surfel 5#import bevy_gaussian_splatting::bindings::{ 9#import bevy_gaussian_splatting::helpers::{ 16#import bevy_gaussian_splatting::packed::{ 27#import bevy_gaussian_splatting::planar::{ 41#import bevy_gaussian_splatting::texture::{ 54 local_to_pixel: mat3x3<f32>, 60fn get_bounding_box_cov2d( 65 let fitler_size = 0.707106; 67 if extent.x < 1.e-4 || extent.y < 1.e-4 { 68 return vec4<f32>(0.0); 71 let radius = sqrt(extent); 72 let max_radius = vec2<f32>(max( 73 max(radius.x, radius.y), 78 let radius_ndc = vec2<f32>( 79 max_radius / view.viewport.zw, 83 radius_ndc * direction, 89fn compute_cov2d_surfel( 90 gaussian_position: vec3<f32>, 96 let rotation = get_rotation(index); 97 let scale = get_scale(index); 99 let T_r = mat3x3<f32>( 100 gaussian_uniforms.transform[0].xyz, 101 gaussian_uniforms.transform[1].xyz, 102 gaussian_uniforms.transform[2].xyz, 105 let S = get_scale_matrix(scale); 106 let R = get_rotation_matrix(rotation); 108 let L = T_r * transpose(R) * S; 110 let world_from_local = mat3x4<f32>( 113 vec4<f32>(gaussian_position, 1.0), 116 let ndc_from_world = transpose(view.clip_from_world); 117 let pixels_from_ndc = intrinsic_matrix(); 119 let T = transpose(world_from_local) * ndc_from_world * pixels_from_ndc; 121 let test = vec3<f32>(cutoff * cutoff, cutoff * cutoff, -1.0); 122 let d = dot(test * T[2], T[2]); 124 output.extent = vec2<f32>(0.0); 128 let f = (1.0 / d) * test; 129 let mean_2d = vec2<f32>( 138 let extent = mean_2d * mean_2d - t; 140 output.local_to_pixel = T; 141 output.mean_2d = mean_2d; 142 output.extent = extent; 146fn surfel_fragment_power( 147 local_to_pixel: mat3x3<f32>, 148 pixel_coord: vec2<f32>, 151 let deltas = mean_2d - pixel_coord; 153 let hu = pixel_coord.x * local_to_pixel.z - local_to_pixel.x; 154 let hv = pixel_coord.y * local_to_pixel.z - local_to_pixel.y; 156 let p = cross(hu, hv); 161 let sigmas_3d = us * us + vs * vs; 162 let sigmas_2d = 2.0 * (deltas.x * deltas.x + deltas.y * deltas.y); 164 let sigmas = 0.5 * min(sigmas_3d, sigmas_2d); 170#endif // GAUSSIAN_SURFEL