mirror of
https://github.com/cds-astro/aladin-lite.git
synced 2025-12-12 07:40:26 -08:00
additionnal commit for solving #246
This commit is contained in:
@@ -26,7 +26,7 @@ hips_pixel_scale = 2.236E-4
|
||||
hips_initial_ra = 085.30251
|
||||
hips_initial_dec = -02.25468
|
||||
hips_initial_fov = 2
|
||||
moc_sky_fraction = 0.001302
|
||||
moc_sky_fraction = 1.0
|
||||
hips_copyright = CNRS/Unistra
|
||||
obs_ack = The Digitized Sky Surveys were produced at the Space Telescope Science Institute under U.S. Government grant NAG W-2166. The images of these surveys are based on photographic data obtained using the Oschin Schmidt Telescope on Palomar Mountain and the UK Schmidt Telescope. The plates were processed into the present compressed digital form with the permission of these institutions. The National Geographic Society - Palomar Observatory Sky Atlas (POSS-I) was made by the California Institute of Technology with grants from the National Geographic Society. The Second Palomar Observatory Sky Survey (POSS-II) was made by the California Institute of Technology with funds from the National Science Foundation, the National Geographic Society, the Sloan Foundation, the Samuel Oschin Foundation, and the Eastman Kodak Corporation. The Oschin Schmidt Telescope is operated by the California Institute of Technology and Palomar Observatory. The UK Schmidt Telescope was operated by the Royal Observatory Edinburgh, with funding from the UK Science and Engineering Research Council (later the UK Particle Physics and Astronomy Research Council), until 1988 June, and thereafter by the Anglo-Australian Observatory. The blue plates of the southern Sky Atlas and its Equatorial Extension (together known as the SERC-J), as well as the Equatorial Red (ER), and the Second Epoch [red] Survey (SES) were all taken with the UK Schmidt. Supplemental funding for sky-survey work at the ST ScI is provided by the European Southern Observatory.
|
||||
prov_progenitor = STScI
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import A from '../src/js/A.js';
|
||||
let aladin;
|
||||
A.init.then(() => {
|
||||
aladin = A.aladin('#aladin-lite-div', {cooFrame: "icrs", log: false});
|
||||
aladin = A.aladin('#aladin-lite-div', {cooFrame: "icrs", log: false, backgroundColor: 'red'});
|
||||
|
||||
aladin.displayFITS(
|
||||
//'https://fits.gsfc.nasa.gov/samples/FOCx38i0101t_c0f.fits', // url of the fits file
|
||||
|
||||
@@ -3,7 +3,7 @@ name = "aladin-lite"
|
||||
description = "Aladin Lite v3 introduces a new graphical engine written in Rust with the use of WebGL"
|
||||
license = "BSD-3-Clause"
|
||||
repository = "https://github.com/cds-astro/aladin-lite"
|
||||
version = "3.6.0-beta"
|
||||
version = "3.6.1-beta"
|
||||
authors = [ "baumannmatthieu0@gmail.com", "matthieu.baumann@astro.unistra.fr",]
|
||||
edition = "2018"
|
||||
|
||||
@@ -47,7 +47,7 @@ optional = true
|
||||
|
||||
[dependencies.healpix]
|
||||
package = "cdshealpix"
|
||||
version = "0.7.0"
|
||||
version = "0.7.3"
|
||||
|
||||
[dependencies.moclib]
|
||||
package = "moc"
|
||||
|
||||
@@ -22,7 +22,6 @@ use crate::{
|
||||
};
|
||||
use al_api::moc::MOCOptions;
|
||||
use crate::math::angle::ToAngle;
|
||||
use al_core::image::format::ChannelType;
|
||||
use wcs::WCS;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
@@ -506,7 +505,7 @@ impl App {
|
||||
|
||||
pub(crate) fn set_moc_options(&mut self, options: MOCOptions) -> Result<(), JsValue> {
|
||||
self.moc
|
||||
.set_options(options, &mut self.camera, &self.projection, &mut self.shaders)
|
||||
.set_options(options)
|
||||
.ok_or_else(|| JsValue::from_str("MOC not found"))?;
|
||||
self.request_redraw = true;
|
||||
|
||||
@@ -705,7 +704,7 @@ impl App {
|
||||
tile_copied = true;
|
||||
match hips {
|
||||
HiPS::D2(hips) => {
|
||||
hips.add_tile(&tile.cell, Some(img), tile.time_req)?
|
||||
hips.add_tile(&tile.cell, img, tile.time_req)?
|
||||
}
|
||||
HiPS::D3(hips) => hips.add_tile(
|
||||
&tile.cell,
|
||||
@@ -716,16 +715,6 @@ impl App {
|
||||
}
|
||||
self.time_start_blending = Time::now();
|
||||
},
|
||||
// In case of JPEG tile missing, add it to the HiPS because it must be drawn as black
|
||||
None if cfg.get_format().get_channel() == ChannelType::RGB8U => {
|
||||
self.request_redraw = true;
|
||||
match hips {
|
||||
HiPS::D2(hips) => {
|
||||
hips.add_tile::<ImageType>(&tile.cell, None, tile.time_req)?
|
||||
}
|
||||
HiPS::D3(_) => (),
|
||||
}
|
||||
},
|
||||
_ => ()
|
||||
};
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ impl HiPS2DBuffer {
|
||||
let mutex_locked = image.borrow();
|
||||
let images = mutex_locked.as_ref().unwrap_abort();
|
||||
for (idx, image) in images.iter().enumerate() {
|
||||
self.push(&HEALPixCell(depth_tile, idx as u64), Some(image), time_req)?;
|
||||
self.push(&HEALPixCell(depth_tile, idx as u64), image, time_req)?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +272,7 @@ impl HiPS2DBuffer {
|
||||
pub fn push<I: Image>(
|
||||
&mut self,
|
||||
cell: &HEALPixCell,
|
||||
image: Option<I>,
|
||||
image: I,
|
||||
time_request: Time,
|
||||
) -> Result<(), JsValue> {
|
||||
if !self.contains_tile(cell) {
|
||||
@@ -331,16 +331,14 @@ impl HiPS2DBuffer {
|
||||
&mut self.base_textures[idx as usize]
|
||||
};
|
||||
|
||||
if let Some(image) = image {
|
||||
send_to_gpu(
|
||||
cell,
|
||||
texture,
|
||||
image,
|
||||
&self.texture_2d_array,
|
||||
&mut self.config,
|
||||
)?;
|
||||
}
|
||||
|
||||
send_to_gpu(
|
||||
cell,
|
||||
texture,
|
||||
image,
|
||||
&self.texture_2d_array,
|
||||
&mut self.config,
|
||||
)?;
|
||||
|
||||
texture.append(
|
||||
cell, // The tile cell
|
||||
&self.config,
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
pub mod buffer;
|
||||
pub mod texture;
|
||||
|
||||
use crate::app::BLENDING_ANIM_DURATION;
|
||||
use crate::renderable::hips::HpxTile;
|
||||
use al_api::hips::ImageExt;
|
||||
use al_api::hips::ImageMetadata;
|
||||
use al_core::colormap::Colormap;
|
||||
use al_core::colormap::Colormaps;
|
||||
use al_core::image::format::ChannelType;
|
||||
use cgmath::Vector3;
|
||||
|
||||
use crate::downloader::query;
|
||||
|
||||
@@ -14,6 +16,7 @@ use al_core::image::Image;
|
||||
|
||||
use al_core::shader::Shader;
|
||||
use al_core::webgl_ctx::GlWrapper;
|
||||
use cgmath::Vector4;
|
||||
|
||||
use al_core::VecData;
|
||||
use al_core::VertexArrayObject;
|
||||
@@ -50,24 +53,40 @@ use cgmath::Matrix;
|
||||
use wasm_bindgen::JsValue;
|
||||
use web_sys::WebGl2RenderingContext;
|
||||
|
||||
pub struct TextureToDraw<'a, 'b> {
|
||||
pub starting_texture: &'a HpxTexture2D,
|
||||
pub ending_texture: &'a HpxTexture2D,
|
||||
pub cell: &'b HEALPixCell,
|
||||
pub struct HpxDrawData<'a> {
|
||||
pub uv_0: TileUVW,
|
||||
pub uv_1: TileUVW,
|
||||
pub start_time: f32,
|
||||
pub cell: &'a HEALPixCell,
|
||||
}
|
||||
|
||||
impl<'a, 'b> TextureToDraw<'a, 'b> {
|
||||
fn new(
|
||||
starting_texture: &'a HpxTexture2D,
|
||||
ending_texture: &'a HpxTexture2D,
|
||||
cell: &'b HEALPixCell,
|
||||
) -> TextureToDraw<'a, 'b> {
|
||||
TextureToDraw {
|
||||
starting_texture,
|
||||
ending_texture,
|
||||
impl<'a> HpxDrawData<'a> {
|
||||
fn from_texture(
|
||||
starting_texture: &HpxTexture2D,
|
||||
ending_texture: &HpxTexture2D,
|
||||
cell: &'a HEALPixCell,
|
||||
) -> Self {
|
||||
let uv_0 = TileUVW::new(cell, starting_texture);
|
||||
let uv_1 = TileUVW::new(cell, ending_texture);
|
||||
let start_time = ending_texture.start_time().as_millis();
|
||||
|
||||
Self {
|
||||
uv_0,
|
||||
uv_1,
|
||||
start_time,
|
||||
cell,
|
||||
}
|
||||
}
|
||||
|
||||
fn new(cell: &'a HEALPixCell) -> Self {
|
||||
let uv_0 = TileUVW([Vector3::new(-1.0, -1.0, -1.0); 4]);
|
||||
let uv_1 = TileUVW([Vector3::new(-1.0, -1.0, -1.0); 4]);
|
||||
let start_time = BLENDING_ANIM_DURATION.as_millis();
|
||||
|
||||
Self {
|
||||
cell, uv_0, uv_1, start_time
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_raster_shader<'a>(
|
||||
@@ -435,8 +454,8 @@ impl HiPS2D {
|
||||
|
||||
for cell in &self.hpx_cells_in_view {
|
||||
// filter textures that are not in the moc
|
||||
let cell = if let Some(moc) = self.footprint_moc.as_ref() {
|
||||
if moc.intersects_cell(&cell) || channel == ChannelType::RGB8U {
|
||||
let cell_in_cov = if let Some(moc) = self.footprint_moc.as_ref() {
|
||||
if moc.intersects_cell(&cell) {
|
||||
// Rasterizer does not render tiles that are not in the MOC
|
||||
// This is not a problem for transparency rendered HiPses (FITS or PNG)
|
||||
// but JPEG tiles do have black when no pixels data is found
|
||||
@@ -449,33 +468,33 @@ impl HiPS2D {
|
||||
Some(&cell)
|
||||
};
|
||||
|
||||
if let Some(cell) = cell {
|
||||
let texture_to_draw = if self.buffer.contains(cell) {
|
||||
let hpx_cell = if let Some(cell) = cell_in_cov {
|
||||
if self.buffer.contains(cell) {
|
||||
if let Some(ending_cell_in_tex) = self.buffer.get(cell) {
|
||||
if let Some(parent_cell) = self.buffer.get_nearest_parent(cell) {
|
||||
if let Some(starting_cell_in_tex) = self.buffer.get(&parent_cell) {
|
||||
Some(TextureToDraw::new(
|
||||
Some(HpxDrawData::from_texture(
|
||||
starting_cell_in_tex,
|
||||
ending_cell_in_tex,
|
||||
cell,
|
||||
))
|
||||
} else {
|
||||
// no blending here
|
||||
Some(TextureToDraw::new(
|
||||
Some(HpxDrawData::from_texture(
|
||||
ending_cell_in_tex,
|
||||
ending_cell_in_tex,
|
||||
cell,
|
||||
))
|
||||
}
|
||||
} else {
|
||||
Some(TextureToDraw::new(
|
||||
Some(HpxDrawData::from_texture(
|
||||
ending_cell_in_tex,
|
||||
ending_cell_in_tex,
|
||||
cell,
|
||||
))
|
||||
}
|
||||
} else {
|
||||
None
|
||||
unreachable!()
|
||||
}
|
||||
} else {
|
||||
if let Some(parent_cell) = self.buffer.get_nearest_parent(cell) {
|
||||
@@ -486,116 +505,126 @@ impl HiPS2D {
|
||||
if let Some(starting_cell_in_tex) =
|
||||
self.buffer.get(&grand_parent_cell)
|
||||
{
|
||||
Some(TextureToDraw::new(
|
||||
Some(HpxDrawData::from_texture(
|
||||
starting_cell_in_tex,
|
||||
ending_cell_in_tex,
|
||||
cell,
|
||||
))
|
||||
} else {
|
||||
// no blending
|
||||
Some(TextureToDraw::new(
|
||||
Some(HpxDrawData::from_texture(
|
||||
ending_cell_in_tex,
|
||||
ending_cell_in_tex,
|
||||
cell,
|
||||
))
|
||||
}
|
||||
} else {
|
||||
Some(TextureToDraw::new(
|
||||
Some(HpxDrawData::from_texture(
|
||||
ending_cell_in_tex,
|
||||
ending_cell_in_tex,
|
||||
cell,
|
||||
))
|
||||
}
|
||||
} else {
|
||||
unreachable!();
|
||||
unreachable!()
|
||||
}
|
||||
} else {
|
||||
None
|
||||
// No ancestor has been found in the buffer to draw.
|
||||
// We might want to check if the HiPS channel is JPEG to mock a cell that will be drawn in black
|
||||
if channel == ChannelType::RGB8U {
|
||||
Some(HpxDrawData::new(cell))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(TextureToDraw {
|
||||
cell,
|
||||
starting_texture,
|
||||
ending_texture,
|
||||
}) = texture_to_draw
|
||||
{
|
||||
let uv_0 = TileUVW::new(cell, starting_texture);
|
||||
let uv_1 = TileUVW::new(cell, ending_texture);
|
||||
let d01s = uv_0[TileCorner::BottomRight].x - uv_0[TileCorner::BottomLeft].x;
|
||||
let d02s = uv_0[TileCorner::TopLeft].y - uv_0[TileCorner::BottomLeft].y;
|
||||
let d01e = uv_1[TileCorner::BottomRight].x - uv_1[TileCorner::BottomLeft].x;
|
||||
let d02e = uv_1[TileCorner::TopLeft].y - uv_1[TileCorner::BottomLeft].y;
|
||||
|
||||
let start_time = ending_texture.start_time().as_millis();
|
||||
|
||||
let num_subdivision =
|
||||
super::subdivide::num_hpxcell_subdivision(cell, camera, projection);
|
||||
|
||||
let n_segments_by_side: usize = 1 << (num_subdivision as usize);
|
||||
let n_segments_by_side_f32 = n_segments_by_side as f32;
|
||||
|
||||
let n_vertices_per_segment = n_segments_by_side + 1;
|
||||
|
||||
let mut pos = Vec::with_capacity((n_segments_by_side + 1) * 4);
|
||||
|
||||
let grid_lonlat =
|
||||
healpix::nested::grid(cell.depth(), cell.idx(), n_segments_by_side as u16);
|
||||
let grid_lonlat_iter = grid_lonlat.iter();
|
||||
|
||||
for (idx, &(lon, lat)) in grid_lonlat_iter.enumerate() {
|
||||
let i: usize = idx / n_vertices_per_segment;
|
||||
let j: usize = idx % n_vertices_per_segment;
|
||||
|
||||
let hj0 = (j as f32) / n_segments_by_side_f32;
|
||||
let hi0 = (i as f32) / n_segments_by_side_f32;
|
||||
|
||||
let uv_start = [
|
||||
uv_0[TileCorner::BottomLeft].x + hj0 * d01s,
|
||||
uv_0[TileCorner::BottomLeft].y + hi0 * d02s,
|
||||
uv_0[TileCorner::BottomLeft].z,
|
||||
];
|
||||
|
||||
let uv_end = [
|
||||
uv_1[TileCorner::BottomLeft].x + hj0 * d01e,
|
||||
uv_1[TileCorner::BottomLeft].y + hi0 * d02e,
|
||||
uv_1[TileCorner::BottomLeft].z,
|
||||
];
|
||||
|
||||
self.uv_start.extend(uv_start);
|
||||
self.uv_end.extend(uv_end);
|
||||
self.time_tile_received.push(start_time);
|
||||
|
||||
let xyz = crate::math::lonlat::radec_to_xyz(lon.to_angle(), lat.to_angle());
|
||||
pos.push([xyz.x as f32, xyz.y as f32, xyz.z as f32]);
|
||||
//pos.push([lon as f32, lat as f32]);
|
||||
}
|
||||
|
||||
let patch_indices_iter = DefaultPatchIndexIter::new(
|
||||
&(0..=n_segments_by_side),
|
||||
&(0..=n_segments_by_side),
|
||||
n_vertices_per_segment,
|
||||
)
|
||||
.flatten()
|
||||
.map(|indices| {
|
||||
[
|
||||
indices.0 + off_indices,
|
||||
indices.1 + off_indices,
|
||||
indices.2 + off_indices,
|
||||
]
|
||||
})
|
||||
.flatten();
|
||||
self.idx_vertices.extend(patch_indices_iter);
|
||||
|
||||
off_indices += pos.len() as u16;
|
||||
|
||||
// Replace options with an arbitrary vertex
|
||||
let position_iter = pos
|
||||
.into_iter()
|
||||
//.map(|ndc| ndc.unwrap_or([0.0, 0.0]))
|
||||
.flatten();
|
||||
self.position.extend(position_iter);
|
||||
}
|
||||
} else {
|
||||
// No ancestor has been found in the buffer to draw.
|
||||
// We might want to check if the HiPS channel is JPEG to mock a cell that will be drawn in black
|
||||
if channel == ChannelType::RGB8U {
|
||||
Some(HpxDrawData::new(cell))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
if let Some(HpxDrawData {
|
||||
cell,
|
||||
uv_0,
|
||||
uv_1,
|
||||
start_time
|
||||
}) = hpx_cell {
|
||||
let d01s = uv_0[TileCorner::BottomRight].x - uv_0[TileCorner::BottomLeft].x;
|
||||
let d02s = uv_0[TileCorner::TopLeft].y - uv_0[TileCorner::BottomLeft].y;
|
||||
let d01e = uv_1[TileCorner::BottomRight].x - uv_1[TileCorner::BottomLeft].x;
|
||||
let d02e = uv_1[TileCorner::TopLeft].y - uv_1[TileCorner::BottomLeft].y;
|
||||
|
||||
|
||||
let num_subdivision =
|
||||
super::subdivide::num_hpxcell_subdivision(cell, camera, projection);
|
||||
|
||||
let n_segments_by_side: usize = 1 << (num_subdivision as usize);
|
||||
let n_segments_by_side_f32 = n_segments_by_side as f32;
|
||||
|
||||
let n_vertices_per_segment = n_segments_by_side + 1;
|
||||
|
||||
let mut pos = Vec::with_capacity((n_segments_by_side + 1) * 4);
|
||||
|
||||
let grid_lonlat =
|
||||
healpix::nested::grid(cell.depth(), cell.idx(), n_segments_by_side as u16);
|
||||
let grid_lonlat_iter = grid_lonlat.iter();
|
||||
|
||||
for (idx, &(lon, lat)) in grid_lonlat_iter.enumerate() {
|
||||
let i: usize = idx / n_vertices_per_segment;
|
||||
let j: usize = idx % n_vertices_per_segment;
|
||||
|
||||
let hj0 = (j as f32) / n_segments_by_side_f32;
|
||||
let hi0 = (i as f32) / n_segments_by_side_f32;
|
||||
|
||||
let uv_start = [
|
||||
uv_0[TileCorner::BottomLeft].x + hj0 * d01s,
|
||||
uv_0[TileCorner::BottomLeft].y + hi0 * d02s,
|
||||
uv_0[TileCorner::BottomLeft].z,
|
||||
];
|
||||
|
||||
let uv_end = [
|
||||
uv_1[TileCorner::BottomLeft].x + hj0 * d01e,
|
||||
uv_1[TileCorner::BottomLeft].y + hi0 * d02e,
|
||||
uv_1[TileCorner::BottomLeft].z,
|
||||
];
|
||||
|
||||
self.uv_start.extend(uv_start);
|
||||
self.uv_end.extend(uv_end);
|
||||
self.time_tile_received.push(start_time);
|
||||
|
||||
let xyz = crate::math::lonlat::radec_to_xyz(lon.to_angle(), lat.to_angle());
|
||||
pos.push([xyz.x as f32, xyz.y as f32, xyz.z as f32]);
|
||||
}
|
||||
|
||||
let patch_indices_iter = DefaultPatchIndexIter::new(
|
||||
&(0..=n_segments_by_side),
|
||||
&(0..=n_segments_by_side),
|
||||
n_vertices_per_segment,
|
||||
)
|
||||
.flatten()
|
||||
.map(|indices| {
|
||||
[
|
||||
indices.0 + off_indices,
|
||||
indices.1 + off_indices,
|
||||
indices.2 + off_indices,
|
||||
]
|
||||
})
|
||||
.flatten();
|
||||
self.idx_vertices.extend(patch_indices_iter);
|
||||
|
||||
off_indices += pos.len() as u16;
|
||||
|
||||
// Replace options with an arbitrary vertex
|
||||
let position_iter = pos
|
||||
.into_iter()
|
||||
//.map(|ndc| ndc.unwrap_or([0.0, 0.0]))
|
||||
.flatten();
|
||||
self.position.extend(position_iter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -642,7 +671,7 @@ impl HiPS2D {
|
||||
pub fn add_tile<I: Image>(
|
||||
&mut self,
|
||||
cell: &HEALPixCell,
|
||||
image: Option<I>,
|
||||
image: I,
|
||||
time_request: Time,
|
||||
) -> Result<(), JsValue> {
|
||||
self.buffer.push(&cell, image, time_request)
|
||||
@@ -708,6 +737,7 @@ impl HiPS2D {
|
||||
.attach_uniforms_from(color)
|
||||
.attach_uniform("model", &w2v)
|
||||
.attach_uniform("current_time", &utils::get_current_time())
|
||||
.attach_uniform("no_tile_color", &(if config.get_format().get_channel() == ChannelType::RGB8U { Vector4::new(0.0, 0.0, 0.0, 1.0) } else { Vector4::new(0.0, 0.0, 0.0, 0.0) }))
|
||||
.attach_uniform("opacity", opacity)
|
||||
.attach_uniforms_from(colormaps);
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ impl<T> Deref for UV<T> {
|
||||
use super::d2::texture::HpxTexture2D;
|
||||
use crate::healpix::cell::HEALPixCell;
|
||||
use crate::renderable::hips::HpxTile;
|
||||
pub struct TileUVW([Vector3<f32>; 4]);
|
||||
pub struct TileUVW(pub [Vector3<f32>; 4]);
|
||||
impl TileUVW {
|
||||
// The texture cell passed must be a child of texture
|
||||
pub fn new(cell: &HEALPixCell, texture: &HpxTexture2D) -> TileUVW {
|
||||
|
||||
@@ -107,9 +107,6 @@ impl MOCRenderer {
|
||||
pub fn set_options(
|
||||
&mut self,
|
||||
options: MOCOptions,
|
||||
camera: &mut CameraViewPort,
|
||||
projection: &ProjectionType,
|
||||
shaders: &mut ShaderManager,
|
||||
) -> Option<MOCOptions> {
|
||||
let name = options.get_uuid();
|
||||
|
||||
|
||||
@@ -219,31 +219,24 @@ impl Layers {
|
||||
// Check whether a hips to plot is allsky
|
||||
// if neither are, we draw a font
|
||||
// if there are, we do not draw nothing
|
||||
let mut background_color = None;
|
||||
for layer in self.layers.iter() {
|
||||
let mut idx_start_layer = -1;
|
||||
|
||||
for (idx, layer) in self.layers.iter().enumerate() {
|
||||
let meta = self.meta.get(layer).unwrap_abort();
|
||||
let cdid = self.ids.get(layer).unwrap_abort();
|
||||
|
||||
if let Some(hips) = self.hipses.get(cdid) {
|
||||
let allsky = hips.is_allsky();
|
||||
let opaque = meta.opacity == 1.0;
|
||||
|
||||
background_color = match (allsky, opaque) {
|
||||
(true, true) => None,
|
||||
_ => Some(self.background_color),
|
||||
};
|
||||
} else {
|
||||
// image fits case. We render a background
|
||||
background_color = Some(self.background_color);
|
||||
}
|
||||
|
||||
if background_color.is_some() {
|
||||
break;
|
||||
// Check if a HiPS is fully opaque so that we cannot see the background
|
||||
// In that case, no need to draw a background because a HiPS will fully cover it
|
||||
let full_covering_hips = (hips.get_config().get_format().get_channel() == ChannelType::RGB8U || hips.is_allsky()) && meta.opacity == 1.0;
|
||||
if full_covering_hips {
|
||||
idx_start_layer = idx as i32;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Need to render transparency font
|
||||
if let Some(background_color) = &background_color {
|
||||
if idx_start_layer == -1 {
|
||||
let vao = if raytracing {
|
||||
raytracer.get_vao()
|
||||
} else {
|
||||
@@ -254,7 +247,7 @@ impl Layers {
|
||||
get_backgroundcolor_shader(&self.gl, shaders)?
|
||||
.bind(&self.gl)
|
||||
.attach_uniforms_from(camera)
|
||||
.attach_uniform("color", &background_color)
|
||||
.attach_uniform("color", &self.background_color)
|
||||
.bind_vertex_array_object_ref(vao)
|
||||
.draw_elements_with_i32(
|
||||
WebGl2RenderingContext::TRIANGLES,
|
||||
@@ -262,28 +255,12 @@ impl Layers {
|
||||
WebGl2RenderingContext::UNSIGNED_SHORT,
|
||||
0,
|
||||
);
|
||||
|
||||
// The background (index -1) has been drawn, we can draw the first HiPS
|
||||
idx_start_layer = 0;
|
||||
}
|
||||
|
||||
// Pre loop over the layers to see if a HiPS is entirely covering those behind
|
||||
// so that we do not have to render those
|
||||
let mut idx_start_layer = 0;
|
||||
for (idx_layer, layer) in self.layers.iter().enumerate().skip(1) {
|
||||
let meta = self.meta.get(layer).expect("Meta should be found");
|
||||
|
||||
let id = self.ids.get(layer).expect("Url should be found");
|
||||
if let Some(hips) = self.hipses.get_mut(id) {
|
||||
let hips_cfg = hips.get_config();
|
||||
|
||||
let fully_covering_hips = (hips.is_allsky()
|
||||
|| hips_cfg.get_format().get_channel() == ChannelType::RGB8U)
|
||||
&& meta.opacity == 1.0;
|
||||
if fully_covering_hips {
|
||||
idx_start_layer = idx_layer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let layers_to_render = &self.layers[idx_start_layer..];
|
||||
let layers_to_render = &self.layers[(idx_start_layer as usize)..];
|
||||
for layer in layers_to_render {
|
||||
let draw_opt = self.meta.get(layer).expect("Meta should be found");
|
||||
if draw_opt.visible() {
|
||||
@@ -293,7 +270,6 @@ impl Layers {
|
||||
match hips {
|
||||
HiPS::D2(hips) => {
|
||||
hips.update(camera, projection);
|
||||
// 2. Draw it if its opacity is not null
|
||||
hips.draw(shaders, colormaps, camera, raytracer, draw_opt, projection)?;
|
||||
}
|
||||
HiPS::D3(hips) => {
|
||||
|
||||
@@ -22,9 +22,7 @@ vec3 reverse_uv(vec3 uv) {
|
||||
return uv;
|
||||
}
|
||||
|
||||
vec4 get_color_from_texture(vec3 UV) {
|
||||
vec4 color = get_pixels(UV);
|
||||
|
||||
vec4 apply_color_settings(vec4 color) {
|
||||
color.r = transfer_func(H, color.r, min_value, max_value);
|
||||
color.g = transfer_func(H, color.g, min_value, max_value);
|
||||
color.b = transfer_func(H, color.b, min_value, max_value);
|
||||
@@ -35,6 +33,12 @@ vec4 get_color_from_texture(vec3 UV) {
|
||||
return apply_tonal(color);
|
||||
}
|
||||
|
||||
vec4 get_color_from_texture(vec3 UV) {
|
||||
vec4 color = get_pixels(UV);
|
||||
|
||||
return apply_color_settings(color);
|
||||
}
|
||||
|
||||
vec4 apply_colormap_to_grayscale(float x) {
|
||||
float alpha = x * scale + offset;
|
||||
alpha = transfer_func(H, alpha, min_value, max_value);
|
||||
|
||||
@@ -24,6 +24,7 @@ uniform Tile textures_tiles[12];
|
||||
#include ../../projection/hpx_proj.glsl;
|
||||
|
||||
uniform float opacity;
|
||||
uniform vec4 no_tile_color;
|
||||
|
||||
vec4 get_tile_color(vec3 pos) {
|
||||
HashDxDy result = hash_with_dxdy(0, pos.zxy);
|
||||
@@ -35,9 +36,8 @@ vec4 get_tile_color(vec3 pos) {
|
||||
vec2 offset = uv;
|
||||
vec3 UV = vec3(offset, float(tile.texture_idx));
|
||||
|
||||
vec4 color = get_color_from_texture(UV);
|
||||
color.a *= (1.0 - tile.empty);
|
||||
return color;
|
||||
vec4 color = mix(get_pixels(UV), no_tile_color, tile.empty);
|
||||
return apply_color_settings(color);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -21,12 +21,6 @@ uniform Tile textures_tiles[12];
|
||||
uniform float opacity;
|
||||
uniform sampler2DArray tex;
|
||||
|
||||
struct TileColor {
|
||||
Tile tile;
|
||||
vec4 color;
|
||||
bool found;
|
||||
};
|
||||
|
||||
#include ../color.glsl;
|
||||
#include ../../projection/hpx_proj.glsl;
|
||||
|
||||
@@ -40,9 +34,8 @@ vec4 get_tile_color(vec3 pos) {
|
||||
vec2 offset = uv;
|
||||
vec3 UV = vec3(offset, float(tile.texture_idx));
|
||||
|
||||
vec4 color = get_colormap_from_color_texture(UV);
|
||||
color.a *= (1.0 - tile.empty);
|
||||
return color;
|
||||
float value = mix(get_pixels(UV).r, 0.0, tile.empty);
|
||||
return apply_colormap_to_grayscale(value);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
Reference in New Issue
Block a user