1#define_import_path bevy_gaussian_splatting::gaussian_2d 5#import bevy_gaussian_splatting::bindings::{ 9#import bevy_gaussian_splatting::helpers::{ 16 #import bevy_gaussian_splatting::packed::{ 24#else ifdef BUFFER_STORAGE 25 #import bevy_gaussian_splatting::planar::{ 34 #import bevy_gaussian_splatting::texture::{ 46 local_to_pixel: mat3x3<f32>, 52fn get_bounding_box_cov2d( 57 let fitler_size = 0.707106; 59 if extent.x < 1.e-4 || extent.y < 1.e-4 { 60 return vec4<f32>(0.0); 63 let radius = sqrt(extent); 64 let max_radius = vec2<f32>(max( 65 max(radius.x, radius.y), 70 let radius_ndc = vec2<f32>( 71 max_radius / view.viewport.zw, 75 radius_ndc * direction, 81fn compute_cov2d_surfel( 82 gaussian_position: vec3<f32>, 88 let rotation = get_rotation(index); 89 let scale = get_scale(index); 91 let T_r = mat3x3<f32>( 92 gaussian_uniforms.transform[0].xyz, 93 gaussian_uniforms.transform[1].xyz, 94 gaussian_uniforms.transform[2].xyz, 97 let S = get_scale_matrix(scale); 98 let R = get_rotation_matrix(rotation); 100 let L = T_r * transpose(R) * S; 102 let world_from_local = mat3x4<f32>( 103 vec4<f32>(L[0], 0.0), 104 vec4<f32>(L[1], 0.0), 105 vec4<f32>(gaussian_position, 1.0), 108 let ndc_from_world = transpose(view.clip_from_world); 109 let pixels_from_ndc = intrinsic_matrix(); 111 let T = transpose(world_from_local) * ndc_from_world * pixels_from_ndc; 113 let test = vec3<f32>(cutoff * cutoff, cutoff * cutoff, -1.0); 114 let d = dot(test * T[2], T[2]); 116 output.extent = vec2<f32>(0.0); 120 let f = (1.0 / d) * test; 121 let mean_2d = vec2<f32>( 130 let extent = mean_2d * mean_2d - t; 132 output.local_to_pixel = T; 133 output.mean_2d = mean_2d; 134 output.extent = extent; 138fn surfel_fragment_power( 139 local_to_pixel: mat3x3<f32>, 140 pixel_coord: vec2<f32>, 143 let deltas = mean_2d - pixel_coord; 145 let hu = pixel_coord.x * local_to_pixel[2] - local_to_pixel[0]; 146 let hv = pixel_coord.y * local_to_pixel[2] - local_to_pixel[1]; 148 let p = cross(hu, hv); 153 let sigmas_3d = us * us + vs * vs; 154 let sigmas_2d = 2.0 * (deltas.x * deltas.x + deltas.y * deltas.y); 156 let sigmas = 0.5 * min(sigmas_3d, sigmas_2d);