Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aardgoose committed Sep 22, 2023
1 parent 48d0500 commit 90cf968
Showing 1 changed file with 8 additions and 98 deletions.
106 changes: 8 additions & 98 deletions examples/jsm/renderers/webgl/WebGLBackend.js
Original file line number Diff line number Diff line change
Expand Up @@ -645,110 +645,20 @@ class WebGLBackend extends Backend {
if ( renderContext.textures !== null ) {

const renderContextData = this.get( renderContext );

let fb = renderContextData.framebuffer;

if ( fb === undefined ) {

fb = gl.createFramebuffer();

gl.bindFramebuffer( gl.FRAMEBUFFER, fb );

const textures = renderContext.textures;

const drawBuffers = [];

for ( let i = 0; i < textures.length; i++ ) {

const texture = textures[ i ];
const { textureGPU } = this.get( texture );

const attachment = gl.COLOR_ATTACHMENT0 + i;

gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0 + i, gl.TEXTURE_2D, textureGPU, 0 );

drawBuffers.push( attachment );

}

gl.drawBuffers( drawBuffers );

if ( renderContext.depthTexture !== null ) {

const { textureGPU } = this.get( renderContext.depthTexture );

gl.framebufferTexture2D( gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, textureGPU, 0 );

}

renderContextData.framebuffer = fb;

} else {

gl.bindFramebuffer( gl.FRAMEBUFFER, fb );

}

} else {

gl.bindFramebuffer( gl.FRAMEBUFFER, null );

}

}

}

_setFramebuffer( renderContext ) {

const { gl } = this;

if ( renderContext.textures !== null ) {

const renderContextData = this.get( renderContext );

let fb;
let cubeFace = 0;

if ( renderContext.isCube ) {

if ( renderContextData.cubeFramebuffers === undefined ) {

renderContextData.cubeFramebuffers = [];
console.log( 'fb cube', renderContext.textures[ 0 ].id );

}

cubeFace = this.renderer._activeCubeFace;
fb = renderContextData.cubeFramebuffers[ cubeFace ]

} else {

fb = renderContextData.framebuffer;

}

if ( fb === undefined ) {

fb = gl.createFramebuffer();

gl.bindFramebuffer( gl.FRAMEBUFFER, fb );

const textures = renderContext.textures;

let drawBuffers = [];

let fb;
let cubeFace = this.renderer._activeCubeFace;

if ( renderContext.isCube ) {

if ( renderContextData.cubeFramebuffers === undefined ) {

renderContextData.cubeFramebuffers = [];

}

cubeFace = this.renderer._activeCubeFace;

fb = renderContextData.cubeFramebuffers[ cubeFace ]

} else {

fb = renderContextData.framebuffer;
Expand All @@ -760,7 +670,7 @@ _setFramebuffer( renderContext ) {
fb = gl.createFramebuffer();

gl.bindFramebuffer( gl.FRAMEBUFFER, fb );

const textures = renderContext.textures;

let drawBuffers = [];
Expand Down

0 comments on commit 90cf968

Please sign in to comment.