Browse Source

fix Scene.opacityAverage not handling xray shaded

Alexander Rose 2 years ago
parent
commit
45760ddd41
2 changed files with 4 additions and 1 deletions
  1. 2 0
      CHANGELOG.md
  2. 2 1
      src/mol-gl/scene.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 ``Scene.opacityAverage`` not taking xray shaded into account
+
 ## [v3.8.1] - 2022-05-14
 
 - Fix issues with marking camera/handle helper (#433)

+ 2 - 1
src/mol-gl/scene.ts

@@ -211,7 +211,8 @@ namespace Scene {
                 // TODO: simplify, handle in renderable.state???
                 // uAlpha is updated in "render" so we need to recompute it here
                 const alpha = clamp(p.values.alpha.ref.value * p.state.alphaFactor, 0, 1);
-                opacityAverage += (1 - p.values.transparencyAverage.ref.value) * alpha;
+                const xray = p.values.dXrayShaded?.ref.value ? 0.5 : 1;
+                opacityAverage += (1 - p.values.transparencyAverage.ref.value) * alpha * xray;
                 count += 1;
             }
             return count > 0 ? opacityAverage / count : 0;