From f41765adcd61658bcc88ba7a4066d935d5d1e201 Mon Sep 17 00:00:00 2001 From: Matthieu Baumann Date: Wed, 4 Mar 2026 14:34:17 +0100 Subject: [PATCH] Fix commit * HiPS3D in fits black artifact removed * accepts fits ext files when searching for a FITS image to display --- src/core/al-core/src/texture/3d.rs | 13 +++++++++++-- src/core/src/app.rs | 3 +++ src/core/src/renderable/hips/mod.rs | 11 ----------- src/glsl/webgl2/fits/color.glsl | 4 ++-- src/glsl/webgl2/hips/color.glsl | 8 ++++---- src/js/DefaultActionsForContextMenu.js | 1 + 6 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/core/al-core/src/texture/3d.rs b/src/core/al-core/src/texture/3d.rs index e7373767..7fa6b074 100644 --- a/src/core/al-core/src/texture/3d.rs +++ b/src/core/al-core/src/texture/3d.rs @@ -58,11 +58,20 @@ impl Texture3D { pixel_type: F::PIXEL_TYPE, }))); - Ok(Texture3D { + let s = Texture3D { texture, gl: gl.clone(), metadata, - }) + }; + let voxel_count = F::NUM_CHANNELS * (width as usize) * (height as usize) * (depth as usize); + let zeros = vec![0xff; voxel_count as usize]; + s.bind().tex_sub_image_3d_with_opt_u8_array(0, 0, 0, + width, + height, + depth, + Some(&zeros[..]) + ); + Ok(s) } pub fn generate_mipmap(&self) { diff --git a/src/core/src/app.rs b/src/core/src/app.rs index 10595976..8294de66 100644 --- a/src/core/src/app.rs +++ b/src/core/src/app.rs @@ -256,6 +256,9 @@ impl App { // 🚨 VERY IMPORTANT: prevent the closure from being dropped onmessage.forget(); + + gl.blend_func(WebGl2RenderingContext::SRC_ALPHA, WebGl2RenderingContext::ONE_MINUS_SRC_ALPHA); + Ok(App { gl, //ui, diff --git a/src/core/src/renderable/hips/mod.rs b/src/core/src/renderable/hips/mod.rs index d89e2ada..bf798b15 100644 --- a/src/core/src/renderable/hips/mod.rs +++ b/src/core/src/renderable/hips/mod.rs @@ -19,17 +19,6 @@ use wasm_bindgen::JsValue; mod subdivide; -/* -pub(crate) trait HpxTile { - // Getter - // Returns the current time if the texture is not full - fn start_time(&self) -> Time; - - fn time_request(&self) -> Time; - - fn cell(&self) -> &HEALPixCell; -}*/ - pub(crate) trait HpxTileBuffer { type T; type C; diff --git a/src/glsl/webgl2/fits/color.glsl b/src/glsl/webgl2/fits/color.glsl index 37c060ec..7fa29da6 100644 --- a/src/glsl/webgl2/fits/color.glsl +++ b/src/glsl/webgl2/fits/color.glsl @@ -21,7 +21,7 @@ vec4 val2c_f32(float x) { // apply reversed alpha = mix(alpha, 1.0 - alpha, reversed); - vec4 new_color = mix(colormap_f(alpha), vec4(0.0), float(isinf(x))); + vec4 new_color = mix(colormap_f(alpha), vec4(0.0), float(isinf(x) || isnan(x))); return apply_tonal(new_color); } @@ -32,7 +32,7 @@ vec4 val2c(float x) { // apply reversed alpha = mix(alpha, 1.0 - alpha, reversed); - vec4 new_color = mix(colormap_f(alpha), vec4(0.0), float(x == blank || isnan(x))); + vec4 new_color = mix(colormap_f(alpha), vec4(0.0), float(x == blank)); return apply_tonal(new_color); } diff --git a/src/glsl/webgl2/hips/color.glsl b/src/glsl/webgl2/hips/color.glsl index 244b0308..6d50a1ec 100644 --- a/src/glsl/webgl2/hips/color.glsl +++ b/src/glsl/webgl2/hips/color.glsl @@ -74,7 +74,7 @@ vec4 val2c_f32(float x) { // apply reversed alpha = mix(alpha, 1.0 - alpha, reversed); - vec4 new_color = mix(colormap_f(alpha), vec4(0.0), float(isinf(x))); + vec4 new_color = mix(colormap_f(alpha), vec4(0.0), float(isinf(x) || isnan(x))); return apply_tonal(new_color); } @@ -85,7 +85,7 @@ vec4 val2c(float x) { // apply reversed alpha = mix(alpha, 1.0 - alpha, reversed); - vec4 new_color = mix(colormap_f(alpha), vec4(0.0), float(x == blank || isnan(x))); + vec4 new_color = mix(colormap_f(alpha), vec4(0.0), float(x == blank)); return apply_tonal(new_color); } @@ -96,12 +96,12 @@ vec4 uvw2c_f32(vec3 uv) { vec4 uvw2c_i32(vec3 uv) { float val = float(decode_i32(texture(tex, uv).rgba)); - return val2c(val); + return mix(val2c(val), vec4(0.0), float(val == -1.0)); } vec4 uvw2c_i16(vec3 uv) { float val = float(decode_i16(texture(tex, uv).rg)); - return val2c(val); + return mix(val2c(val), vec4(0.0), float(val == -1.0)); } vec4 uvw2c_u8(vec3 uv) { diff --git a/src/js/DefaultActionsForContextMenu.js b/src/js/DefaultActionsForContextMenu.js index ced81ddd..6653524c 100644 --- a/src/js/DefaultActionsForContextMenu.js +++ b/src/js/DefaultActionsForContextMenu.js @@ -129,6 +129,7 @@ export let DefaultActionsForContextMenu = (function () { label: 'FITS image', action(o) { let input = document.createElement('input'); input.type = 'file'; + input.accept = ".fits"; input.onchange = _ => { let files = Array.from(input.files);