Browse Source

Exposed dpoitIterations parameter

giagitom 2 years ago
parent
commit
7bcbcd5a7f
2 changed files with 7 additions and 3 deletions
  1. 3 0
      src/mol-canvas3d/canvas3d.ts
  2. 4 3
      src/mol-canvas3d/passes/draw.ts

+ 3 - 0
src/mol-canvas3d/canvas3d.ts

@@ -84,6 +84,7 @@ export const Canvas3DParams = {
     cameraResetDurationMs: PD.Numeric(250, { min: 0, max: 1000, step: 1 }, { description: 'The time it takes to reset the camera.' }),
     sceneRadiusFactor: PD.Numeric(1, { min: 1, max: 10, step: 0.1 }),
     transparentBackground: PD.Boolean(false),
+    dpoitIterations: PD.Numeric(2, { min: 1, max: 1000, step: 1 }),
 
     multiSample: PD.Group(MultiSampleParams),
     postprocessing: PD.Group(PostprocessingParams),
@@ -686,6 +687,7 @@ namespace Canvas3D {
                 cameraResetDurationMs: p.cameraResetDurationMs,
                 sceneRadiusFactor: p.sceneRadiusFactor,
                 transparentBackground: p.transparentBackground,
+                dpoitIterations: p.dpoitIterations,
                 viewport: p.viewport,
 
                 postprocessing: { ...p.postprocessing },
@@ -823,6 +825,7 @@ namespace Canvas3D {
                 if (props.camera?.stereo !== undefined) Object.assign(p.camera.stereo, props.camera.stereo);
                 if (props.cameraResetDurationMs !== undefined) p.cameraResetDurationMs = props.cameraResetDurationMs;
                 if (props.transparentBackground !== undefined) p.transparentBackground = props.transparentBackground;
+                if (props.dpoitIterations !== undefined) p.dpoitIterations = props.dpoitIterations;
                 if (props.viewport !== undefined) {
                     const doNotUpdate = p.viewport === props.viewport ||
                         (p.viewport.name === props.viewport.name && shallowEqual(p.viewport.params, props.viewport.params));

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

@@ -29,6 +29,7 @@ type Props = {
     postprocessing: PostprocessingProps;
     marking: MarkingProps;
     transparentBackground: boolean;
+    dpoitIterations: number;
 }
 
 type RenderContext = {
@@ -129,7 +130,7 @@ export class DrawPass {
         }
     }
 
-    private _renderDpoit(renderer: Renderer, camera: ICamera, scene: Scene, transparentBackground: boolean, postprocessingProps: PostprocessingProps) {
+    private _renderDpoit(renderer: Renderer, camera: ICamera, scene: Scene, iterations: number, transparentBackground: boolean, postprocessingProps: PostprocessingProps) {
         if (!this.dpoit?.supported) throw new Error('expected dpoit to be supported');
 
         this.colorTarget.bind();
@@ -168,7 +169,7 @@ export class DrawPass {
                 renderer.renderDpoitTransparent(scene.volumes, camera, this.depthTextureOpaque, dpoitTextures);
             }
 
-            for (let i = 0; i < 2; i++) { // not working with 1 pass
+            for (let i = 0; i < iterations; i++) {
                 dpoitTextures = this.dpoit.bindDualDepthPeeling();
                 if (scene.opacityAverage < 1) {
                     renderer.renderDpoitTransparent(scene.primitives, camera, this.depthTextureOpaque, dpoitTextures);
@@ -330,7 +331,7 @@ export class DrawPass {
         if (this.wboitEnabled) {
             this._renderWboit(renderer, camera, scene, transparentBackground, props.postprocessing);
         } else if (this.dpoitEnabled) {
-            this._renderDpoit(renderer, camera, scene, transparentBackground, props.postprocessing);
+            this._renderDpoit(renderer, camera, scene, props.dpoitIterations, transparentBackground, props.postprocessing);
         } else {
             this._renderBlended(renderer, camera, scene, !volumeRendering && !postprocessingEnabled && !antialiasingEnabled && toDrawingBuffer, transparentBackground, props.postprocessing);
         }