Browse Source

fix marking pass for transparentBackground

Alexander Rose 3 years ago
parent
commit
28bc212132
3 changed files with 9 additions and 7 deletions
  1. 2 0
      CHANGELOG.md
  2. 3 3
      src/mol-canvas3d/passes/draw.ts
  3. 4 4
      src/mol-gl/renderer.ts

+ 2 - 0
CHANGELOG.md

@@ -6,6 +6,8 @@ Note that since we don't clearly distinguish between a public and private interf
 
 ## [Unreleased]
 
+- Fix marking pass not working with ``transparentBackground``
+
 ## [v3.0.0] - 2022-01-23
 
 - Assembly handling tweaks:

+ 3 - 3
src/mol-canvas3d/passes/draw.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2019-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2019-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  * @author Áron Samuel Kovács <aron.kovacs@mail.muni.cz>
@@ -310,12 +310,12 @@ export class DrawPass {
             const markingDepthTest = props.marking.ghostEdgeStrength < 1;
             if (markingDepthTest) {
                 this.marking.depthTarget.bind();
-                renderer.clear(false);
+                renderer.clear(false, true);
                 renderer.renderMarkingDepth(scene.primitives, camera, null);
             }
 
             this.marking.maskTarget.bind();
-            renderer.clear(false);
+            renderer.clear(false, true);
             renderer.renderMarkingMask(scene.primitives, camera, markingDepthTest ? this.marking.depthTarget.texture : null);
 
             this.marking.update(props.marking);

+ 4 - 4
src/mol-gl/renderer.ts

@@ -1,5 +1,5 @@
 /**
- * Copyright (c) 2018-2021 mol* contributors, licensed under MIT, See LICENSE file for more info.
+ * Copyright (c) 2018-2022 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
  */
@@ -53,7 +53,7 @@ interface Renderer {
     readonly stats: RendererStats
     readonly props: Readonly<RendererProps>
 
-    clear: (toBackgroundColor: boolean) => void
+    clear: (toBackgroundColor: boolean, ignoreTransparentBackground?: boolean) => void
     clearDepth: () => void
     update: (camera: ICamera) => void
 
@@ -523,13 +523,13 @@ namespace Renderer {
         };
 
         return {
-            clear: (toBackgroundColor: boolean) => {
+            clear: (toBackgroundColor: boolean, ignoreTransparentBackground?: boolean) => {
                 state.enable(gl.SCISSOR_TEST);
                 state.enable(gl.DEPTH_TEST);
                 state.colorMask(true, true, true, true);
                 state.depthMask(true);
 
-                if (transparentBackground) {
+                if (transparentBackground && !ignoreTransparentBackground) {
                     state.clearColor(0, 0, 0, 0);
                 } else if (toBackgroundColor) {
                     state.clearColor(bgColor[0], bgColor[1], bgColor[2], 1);