Skip to content
Snippets Groups Projects
Commit f506210b authored by Alexander Rose's avatar Alexander Rose
Browse files

dpoit, fix webgl1 support

- in webgl1 drawbuffers must be in the same format for some reason
parent cb0cbd06
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ import { blendBackDpoit_frag } from '../../mol-gl/shader/blend-back-dpoit.frag'; ...@@ -21,6 +21,7 @@ import { blendBackDpoit_frag } from '../../mol-gl/shader/blend-back-dpoit.frag';
import { Framebuffer } from '../../mol-gl/webgl/framebuffer'; import { Framebuffer } from '../../mol-gl/webgl/framebuffer';
import { Vec2 } from '../../mol-math/linear-algebra'; import { Vec2 } from '../../mol-math/linear-algebra';
import { isDebugMode, isTimingMode } from '../../mol-util/debug'; import { isDebugMode, isTimingMode } from '../../mol-util/debug';
import { isWebGL2 } from '../../mol-gl/webgl/compat';
const BlendBackDpoitSchema = { const BlendBackDpoitSchema = {
...QuadSchema, ...QuadSchema,
...@@ -187,15 +188,22 @@ export class DpoitPass { ...@@ -187,15 +188,22 @@ export class DpoitPass {
for (let i = 0; i < 2; i++) { for (let i = 0; i < 2; i++) {
// depth // depth
this.depthFramebuffers[i].bind(); this.depthFramebuffers[i].bind();
drawBuffers!.drawBuffers([drawBuffers!.COLOR_ATTACHMENT0, drawBuffers!.COLOR_ATTACHMENT1, drawBuffers!.COLOR_ATTACHMENT2]); drawBuffers!.drawBuffers([
drawBuffers!.COLOR_ATTACHMENT0,
drawBuffers!.COLOR_ATTACHMENT1,
drawBuffers!.COLOR_ATTACHMENT2
]);
this.depthTextures[i].attachFramebuffer(this.depthFramebuffers[i], 'color2');
this.colorFrontTextures[i].attachFramebuffer(this.depthFramebuffers[i], 'color0'); this.colorFrontTextures[i].attachFramebuffer(this.depthFramebuffers[i], 'color0');
this.colorBackTextures[i].attachFramebuffer(this.depthFramebuffers[i], 'color1'); this.colorBackTextures[i].attachFramebuffer(this.depthFramebuffers[i], 'color1');
this.depthTextures[i].attachFramebuffer(this.depthFramebuffers[i], 'color2');
// color // color
this.colorFramebuffers[i].bind(); this.colorFramebuffers[i].bind();
drawBuffers!.drawBuffers([drawBuffers!.COLOR_ATTACHMENT0, drawBuffers!.COLOR_ATTACHMENT1]); drawBuffers!.drawBuffers([
drawBuffers!.COLOR_ATTACHMENT0,
drawBuffers!.COLOR_ATTACHMENT1
]);
this.colorFrontTextures[i].attachFramebuffer(this.colorFramebuffers[i], 'color0'); this.colorFrontTextures[i].attachFramebuffer(this.colorFramebuffers[i], 'color0');
this.colorBackTextures[i].attachFramebuffer(this.colorFramebuffers[i], 'color1'); this.colorBackTextures[i].attachFramebuffer(this.colorFramebuffers[i], 'color1');
...@@ -232,6 +240,7 @@ export class DpoitPass { ...@@ -232,6 +240,7 @@ export class DpoitPass {
this.depthTextures[0].define(width, height); this.depthTextures[0].define(width, height);
this.depthTextures[1].define(width, height); this.depthTextures[1].define(width, height);
if (isWebGL2(webgl.gl)) {
this.colorFrontTextures = colorBufferHalfFloat && textureHalfFloat ? [ this.colorFrontTextures = colorBufferHalfFloat && textureHalfFloat ? [
resources.texture('image-float16', 'rgba', 'fp16', 'nearest'), resources.texture('image-float16', 'rgba', 'fp16', 'nearest'),
resources.texture('image-float16', 'rgba', 'fp16', 'nearest') resources.texture('image-float16', 'rgba', 'fp16', 'nearest')
...@@ -239,8 +248,6 @@ export class DpoitPass { ...@@ -239,8 +248,6 @@ export class DpoitPass {
resources.texture('image-float32', 'rgba', 'float', 'nearest'), resources.texture('image-float32', 'rgba', 'float', 'nearest'),
resources.texture('image-float32', 'rgba', 'float', 'nearest') resources.texture('image-float32', 'rgba', 'float', 'nearest')
]; ];
this.colorFrontTextures[0].define(width, height);
this.colorFrontTextures[1].define(width, height);
this.colorBackTextures = colorBufferHalfFloat && textureHalfFloat ? [ this.colorBackTextures = colorBufferHalfFloat && textureHalfFloat ? [
resources.texture('image-float16', 'rgba', 'fp16', 'nearest'), resources.texture('image-float16', 'rgba', 'fp16', 'nearest'),
...@@ -249,6 +256,23 @@ export class DpoitPass { ...@@ -249,6 +256,23 @@ export class DpoitPass {
resources.texture('image-float32', 'rgba', 'float', 'nearest'), resources.texture('image-float32', 'rgba', 'float', 'nearest'),
resources.texture('image-float32', 'rgba', 'float', 'nearest') resources.texture('image-float32', 'rgba', 'float', 'nearest')
]; ];
} else {
// in webgl1 drawbuffers must be in the same format for some reason
this.colorFrontTextures = [
resources.texture('image-float32', 'rgba', 'float', 'nearest'),
resources.texture('image-float32', 'rgba', 'float', 'nearest')
];
this.colorBackTextures = [
resources.texture('image-float32', 'rgba', 'float', 'nearest'),
resources.texture('image-float32', 'rgba', 'float', 'nearest')
];
}
this.colorFrontTextures[0].define(width, height);
this.colorFrontTextures[1].define(width, height);
this.colorBackTextures[0].define(width, height); this.colorBackTextures[0].define(width, height);
this.colorBackTextures[1].define(width, height); this.colorBackTextures[1].define(width, height);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment