ソースを参照

fix rendering with very small viewport and SSAO

Alexander Rose 2 年 前
コミット
55e940e88c
2 ファイル変更9 行追加8 行削除
  1. 1 0
      CHANGELOG.md
  2. 8 8
      src/mol-canvas3d/passes/postprocessing.ts

+ 1 - 0
CHANGELOG.md

@@ -13,6 +13,7 @@ Note that since we don't clearly distinguish between a public and private interf
 - Fix rendering issues caused by VAO reuse
 - Add "Zoom All", "Orient Axes", "Reset Axes" buttons to the "Reset Camera" button
 - Improve trackball move-state handling when key bindings use modifiers
+- Fix rendering with very small viewport and SSAO enabled
 
 ## [v3.33.0] - 2023-04-02
 

+ 8 - 8
src/mol-canvas3d/passes/postprocessing.ts

@@ -506,11 +506,11 @@ export class PostprocessingPass {
         const sw = Math.floor(width * this.ssaoScale);
         const sh = Math.floor(height * this.ssaoScale);
 
-        const hw = Math.floor(sw * 0.5);
-        const hh = Math.floor(sh * 0.5);
+        const hw = Math.max(1, Math.floor(sw * 0.5));
+        const hh = Math.max(1, Math.floor(sh * 0.5));
 
-        const qw = Math.floor(sw * 0.25);
-        const qh = Math.floor(sh * 0.25);
+        const qw = Math.max(1, Math.floor(sw * 0.25));
+        const qh = Math.max(1, Math.floor(sh * 0.25));
 
         this.downsampledDepthTarget = drawPass.packedDepth
             ? webgl.createRenderTarget(sw, sh, false, 'uint8', 'linear', 'rgba')
@@ -562,12 +562,12 @@ export class PostprocessingPass {
             this.ssaoDepthTexture.define(sw, sh);
             this.ssaoDepthBlurProxyTexture.define(sw, sh);
 
-            const hw = Math.floor(sw * 0.5);
-            const hh = Math.floor(sh * 0.5);
+            const hw = Math.max(1, Math.floor(sw * 0.5));
+            const hh = Math.max(1, Math.floor(sh * 0.5));
             this.depthHalfTarget.setSize(hw, hh);
 
-            const qw = Math.floor(sw * 0.25);
-            const qh = Math.floor(sh * 0.25);
+            const qw = Math.max(1, Math.floor(sw * 0.25));
+            const qh = Math.max(1, Math.floor(sh * 0.25));
             this.depthQuarterTarget.setSize(qw, qh);
 
             ValueCell.update(this.renderable.values.uTexSize, Vec2.set(this.renderable.values.uTexSize.ref.value, width, height));