1#define_import_path bevy_gaussian_splatting::gaussian_2d 4#import bevy_gaussian_splatting::bindings::{ 8#import bevy_gaussian_splatting::helpers::{ 15 #import bevy_gaussian_splatting::packed::{ 23#else ifdef BUFFER_STORAGE 24 #import bevy_gaussian_splatting::planar::{ 33 #import bevy_gaussian_splatting::texture::{ 44 local_to_pixel: mat3x3<f32>, 49fn get_bounding_box_cov2d( 54 let fitler_size = 0.707106; 56 if extent.x < 1.e-4 || extent.y < 1.e-4 { 57 return vec4<f32>(0.0); 60 let radius = sqrt(extent); 61 let max_radius = vec2<f32>(max( 62 max(radius.x, radius.y), 67 let radius_ndc = vec2<f32>( 68 max_radius / view.viewport.zw, 72 radius_ndc * direction, 77fn compute_cov2d_surfel( 78 gaussian_position: vec3<f32>, 84 let rotation = get_rotation(index); 85 let scale = get_scale(index); 87 let T_r = mat3x3<f32>( 88 gaussian_uniforms.transform[0].xyz, 89 gaussian_uniforms.transform[1].xyz, 90 gaussian_uniforms.transform[2].xyz, 93 let S = get_scale_matrix(scale); 94 let R = get_rotation_matrix(rotation); 96 let L = T_r * transpose(R) * S; 98 let world_from_local = mat3x4<f32>( 100 vec4<f32>(L[1], 0.0), 101 vec4<f32>(gaussian_position, 1.0), 104 let ndc_from_world = transpose(view.clip_from_world); 105 let pixels_from_ndc = intrinsic_matrix(); 107 let T = transpose(world_from_local) * ndc_from_world * pixels_from_ndc; 109 let test = vec3<f32>(cutoff * cutoff, cutoff * cutoff, -1.0); 110 let d = dot(test * T[2], T[2]); 112 output.extent = vec2<f32>(0.0); 116 let f = (1.0 / d) * test; 117 let mean_2d = vec2<f32>( 126 let extent = mean_2d * mean_2d - t; 128 output.local_to_pixel = T; 129 output.mean_2d = mean_2d; 130 output.extent = extent; 134fn surfel_fragment_power( 135 local_to_pixel: mat3x3<f32>, 136 pixel_coord: vec2<f32>, 139 let deltas = mean_2d - pixel_coord; 141 let hu = pixel_coord.x * local_to_pixel[2] - local_to_pixel[0]; 142 let hv = pixel_coord.y * local_to_pixel[2] - local_to_pixel[1]; 144 let p = cross(hu, hv); 149 let sigmas_3d = us * us + vs * vs; 150 let sigmas_2d = 2.0 * (deltas.x * deltas.x + deltas.y * deltas.y); 152 let sigmas = 0.5 * min(sigmas_3d, sigmas_2d);