|
@@ -18,6 +18,8 @@ import { evaluateWboit_frag } from '../../mol-gl/shader/evaluate-wboit.frag';
|
|
|
import { Framebuffer } from '../../mol-gl/webgl/framebuffer';
|
|
|
import { Vec2 } from '../../mol-math/linear-algebra';
|
|
|
import { isDebugMode, isTimingMode } from '../../mol-util/debug';
|
|
|
+import { isWebGL2 } from '../../mol-gl/webgl/compat';
|
|
|
+import { Renderbuffer } from '../../mol-gl/webgl/renderbuffer';
|
|
|
|
|
|
const EvaluateWboitSchema = {
|
|
|
...QuadSchema,
|
|
@@ -50,6 +52,7 @@ export class WboitPass {
|
|
|
private readonly framebuffer: Framebuffer;
|
|
|
private readonly textureA: Texture;
|
|
|
private readonly textureB: Texture;
|
|
|
+ private readonly depthRenderbuffer: Renderbuffer;
|
|
|
|
|
|
private _supported = false;
|
|
|
get supported() {
|
|
@@ -87,6 +90,7 @@ export class WboitPass {
|
|
|
if (width !== w || height !== h) {
|
|
|
this.textureA.define(width, height);
|
|
|
this.textureB.define(width, height);
|
|
|
+ this.depthRenderbuffer.setSize(width, height);
|
|
|
ValueCell.update(this.renderable.values.uTexSize, Vec2.set(this.renderable.values.uTexSize.ref.value, width, height));
|
|
|
}
|
|
|
}
|
|
@@ -106,6 +110,8 @@ export class WboitPass {
|
|
|
|
|
|
this.textureA.attachFramebuffer(this.framebuffer, 'color0');
|
|
|
this.textureB.attachFramebuffer(this.framebuffer, 'color1');
|
|
|
+
|
|
|
+ this.depthRenderbuffer.attachFramebuffer(this.framebuffer);
|
|
|
}
|
|
|
|
|
|
static isSupported(webgl: WebGLContext) {
|
|
@@ -128,7 +134,7 @@ export class WboitPass {
|
|
|
constructor(private webgl: WebGLContext, width: number, height: number) {
|
|
|
if (!WboitPass.isSupported(webgl)) return;
|
|
|
|
|
|
- const { resources } = webgl;
|
|
|
+ const { resources, gl } = webgl;
|
|
|
|
|
|
this.textureA = resources.texture('image-float32', 'rgba', 'float', 'nearest');
|
|
|
this.textureA.define(width, height);
|
|
@@ -136,6 +142,10 @@ export class WboitPass {
|
|
|
this.textureB = resources.texture('image-float32', 'rgba', 'float', 'nearest');
|
|
|
this.textureB.define(width, height);
|
|
|
|
|
|
+ this.depthRenderbuffer = isWebGL2(gl)
|
|
|
+ ? resources.renderbuffer('depth32f', 'depth', width, height)
|
|
|
+ : resources.renderbuffer('depth16', 'depth', width, height);
|
|
|
+
|
|
|
this.renderable = getEvaluateWboitRenderable(webgl, this.textureA, this.textureB);
|
|
|
this.framebuffer = resources.framebuffer();
|
|
|
|