diff --git a/src/core/src/app.rs b/src/core/src/app.rs index 8d14d582..e7cf5337 100644 --- a/src/core/src/app.rs +++ b/src/core/src/app.rs @@ -133,7 +133,6 @@ impl App { //let exec = Rc::new(RefCell::new(TaskExecutor::new())); let projection = ProjectionType::Sin(mapproj::zenithal::sin::Sin); - gl.enable(WebGl2RenderingContext::BLEND); // TODO: https://caniuse.com/?search=scissor is not supported for safari <= 14.1 // When it will be supported nearly everywhere, we will need to uncomment this line to @@ -829,6 +828,7 @@ impl App { // Render the scene // Clear all the screen first (only the region set by the scissor) gl.clear(WebGl2RenderingContext::COLOR_BUFFER_BIT); + // set the blending options layers.draw(camera, shaders, colormaps, projection)?; diff --git a/src/core/src/renderable/mod.rs b/src/core/src/renderable/mod.rs index 4ab0d5e6..5035913c 100644 --- a/src/core/src/renderable/mod.rs +++ b/src/core/src/renderable/mod.rs @@ -213,9 +213,13 @@ impl Layers { let raytracer = &self.raytracer; let raytracing = camera.is_raytracing(projection); + // The first layer or the background must be plot with no blending + self.gl.disable(WebGl2RenderingContext::BLEND); + // 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 idx_start_layer = -1; for (idx, layer) in self.layers.iter().enumerate() { @@ -235,6 +239,8 @@ impl Layers { } } + let mut blending_enabled = false; + // Need to render transparency font if idx_start_layer == -1 { let vao = if raytracing { @@ -258,6 +264,9 @@ impl Layers { // The background (index -1) has been drawn, we can draw the first HiPS idx_start_layer = 0; + + self.gl.enable(WebGl2RenderingContext::BLEND); + blending_enabled = true; } let layers_to_render = &self.layers[(idx_start_layer as usize)..]; @@ -283,6 +292,11 @@ impl Layers { } } } + + if !blending_enabled { + self.gl.enable(WebGl2RenderingContext::BLEND); + blending_enabled = true; + } } Ok(())