From 723ce3b7beda108e6b035a2c20c819901002b1c7 Mon Sep 17 00:00:00 2001 From: Dusan Bosnjak Date: Sat, 29 Dec 2018 12:14:55 -0800 Subject: [PATCH 1/7] allow targets to use their own buffers --- src/renderers/webgl/WebGLTextures.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index c7a86037d803e4..09882437f50071 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -811,7 +811,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, _gl.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer ); renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); - setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget ); + setupRenderBufferStorage( renderTarget.ownDepthBuffer || renderTargetProperties.__webglDepthbuffer, renderTarget ); } From 4dbf09c16a3a83088f90af8de9693801108374b2 Mon Sep 17 00:00:00 2001 From: Dusan Bosnjak Date: Tue, 18 Jan 2022 09:35:26 -0800 Subject: [PATCH 2/7] fix lint --- src/renderers/webgl/WebGLTextures.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/renderers/webgl/WebGLTextures.js b/src/renderers/webgl/WebGLTextures.js index 9831260e4f5047..79d5533302fc85 100644 --- a/src/renderers/webgl/WebGLTextures.js +++ b/src/renderers/webgl/WebGLTextures.js @@ -1294,8 +1294,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils, state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer ); renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer(); - setupRenderBufferStorage( renderTarget.ownDepthBuffer || renderTargetProperties.__webglDepthbuffer, renderTarget, false); - + setupRenderBufferStorage( renderTarget.ownDepthBuffer || renderTargetProperties.__webglDepthbuffer, renderTarget, false ); } From b3ed638ab9b415b4599aaff0809779967caf8ce8 Mon Sep 17 00:00:00 2001 From: Dusan Bosnjak Date: Thu, 20 Jan 2022 16:52:55 -0800 Subject: [PATCH 3/7] add ownDepthBuffer key to WebGLRenderTarget --- src/renderers/WebGLRenderTarget.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/renderers/WebGLRenderTarget.js b/src/renderers/WebGLRenderTarget.js index 41ad23cccf91f4..041c648b7d3918 100644 --- a/src/renderers/WebGLRenderTarget.js +++ b/src/renderers/WebGLRenderTarget.js @@ -35,6 +35,7 @@ class WebGLRenderTarget extends EventDispatcher { this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false; this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; + this.ownDepthBuffer = undefined } From c7f15206776ad9f58009c196ac6f86885b327c78 Mon Sep 17 00:00:00 2001 From: Dusan Bosnjak Date: Thu, 20 Jan 2022 16:57:42 -0800 Subject: [PATCH 4/7] add ownDepthBuffer docs --- docs/api/en/renderers/WebGLRenderTarget.html | 5 +++++ docs/api/zh/renderers/WebGLRenderTarget.html | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/docs/api/en/renderers/WebGLRenderTarget.html b/docs/api/en/renderers/WebGLRenderTarget.html index 7f264688672929..b2d055a01f4099 100644 --- a/docs/api/en/renderers/WebGLRenderTarget.html +++ b/docs/api/en/renderers/WebGLRenderTarget.html @@ -93,6 +93,11 @@

[property:DepthTexture depthTexture]

If set, the scene depth will be rendered to this texture. Default is null.

+

[property:WebGLRenderbuffer ownDepthBuffer]

+

+ If set, the texture will use the user provided WebGLRenderBuffer instead of the one created by the renderer for this texture. Default is undefined. +

+

Methods

diff --git a/docs/api/zh/renderers/WebGLRenderTarget.html b/docs/api/zh/renderers/WebGLRenderTarget.html index 072a5efe405acb..6622072008b939 100644 --- a/docs/api/zh/renderers/WebGLRenderTarget.html +++ b/docs/api/zh/renderers/WebGLRenderTarget.html @@ -89,6 +89,11 @@

[property:DepthTexture depthTexture]

如果设置,那么场景的深度将会被渲染到此纹理上。默认为null

+

[property:WebGLRenderbuffer ownDepthBuffer]

+

+ 如果设置,纹理将使用用户提供的 WebGLRenderBuffer,而不是渲染器为此纹理创建的缓冲区。默认是 undefined +

+

方法

From b7d3a62e79e8c59eed150de58d1b25c0ebd3b627 Mon Sep 17 00:00:00 2001 From: Dusan Bosnjak Date: Thu, 20 Jan 2022 17:02:59 -0800 Subject: [PATCH 5/7] add usage example --- docs/api/en/renderers/WebGLRenderTarget.html | 6 +++++- docs/api/zh/renderers/WebGLRenderTarget.html | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/docs/api/en/renderers/WebGLRenderTarget.html b/docs/api/en/renderers/WebGLRenderTarget.html index b2d055a01f4099..d81af3c8c3f4ed 100644 --- a/docs/api/en/renderers/WebGLRenderTarget.html +++ b/docs/api/en/renderers/WebGLRenderTarget.html @@ -97,7 +97,11 @@

[property:WebGLRenderbuffer ownDepthBuffer]

If set, the texture will use the user provided WebGLRenderBuffer instead of the one created by the renderer for this texture. Default is undefined.

- +

Usage:

+ + const myTarget = new THREE.WebGLRenderTarget( 512, 512 ); + myTarget.ownDepthBuffer = gl.createRenderBuffer(); +

Methods

diff --git a/docs/api/zh/renderers/WebGLRenderTarget.html b/docs/api/zh/renderers/WebGLRenderTarget.html index 6622072008b939..e34387b69b8285 100644 --- a/docs/api/zh/renderers/WebGLRenderTarget.html +++ b/docs/api/zh/renderers/WebGLRenderTarget.html @@ -93,7 +93,11 @@

[property:WebGLRenderbuffer ownDepthBuffer]

如果设置,纹理将使用用户提供的 WebGLRenderBuffer,而不是渲染器为此纹理创建的缓冲区。默认是 undefined

- +

用法:

+ + const myTarget = new THREE.WebGLRenderTarget( 512, 512 ); + myTarget.ownDepthBuffer = gl.createRenderBuffer(); +

方法

From b6f928e080b6265fffe254d03e2f1e4cc0ff0991 Mon Sep 17 00:00:00 2001 From: Dusan Bosnjak Date: Thu, 20 Jan 2022 17:03:47 -0800 Subject: [PATCH 6/7] fix lint --- src/renderers/WebGLRenderTarget.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderers/WebGLRenderTarget.js b/src/renderers/WebGLRenderTarget.js index 041c648b7d3918..ece3cc07ce0c41 100644 --- a/src/renderers/WebGLRenderTarget.js +++ b/src/renderers/WebGLRenderTarget.js @@ -35,7 +35,7 @@ class WebGLRenderTarget extends EventDispatcher { this.depthBuffer = options.depthBuffer !== undefined ? options.depthBuffer : true; this.stencilBuffer = options.stencilBuffer !== undefined ? options.stencilBuffer : false; this.depthTexture = options.depthTexture !== undefined ? options.depthTexture : null; - this.ownDepthBuffer = undefined + this.ownDepthBuffer = undefined; } From 4b35da0f8a652eba535146893b9212bf6d102e3c Mon Sep 17 00:00:00 2001 From: Dusan Bosnjak Date: Thu, 20 Jan 2022 17:09:33 -0800 Subject: [PATCH 7/7] fix usage example formatting --- docs/api/en/renderers/WebGLRenderTarget.html | 2 +- docs/api/zh/renderers/WebGLRenderTarget.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api/en/renderers/WebGLRenderTarget.html b/docs/api/en/renderers/WebGLRenderTarget.html index d81af3c8c3f4ed..88729fdb4d0f14 100644 --- a/docs/api/en/renderers/WebGLRenderTarget.html +++ b/docs/api/en/renderers/WebGLRenderTarget.html @@ -100,7 +100,7 @@

[property:WebGLRenderbuffer ownDepthBuffer]

Usage:

const myTarget = new THREE.WebGLRenderTarget( 512, 512 ); - myTarget.ownDepthBuffer = gl.createRenderBuffer(); +myTarget.ownDepthBuffer = gl.createRenderBuffer();

Methods

diff --git a/docs/api/zh/renderers/WebGLRenderTarget.html b/docs/api/zh/renderers/WebGLRenderTarget.html index e34387b69b8285..f74447e2774917 100644 --- a/docs/api/zh/renderers/WebGLRenderTarget.html +++ b/docs/api/zh/renderers/WebGLRenderTarget.html @@ -96,7 +96,7 @@

[property:WebGLRenderbuffer ownDepthBuffer]

用法:

const myTarget = new THREE.WebGLRenderTarget( 512, 512 ); - myTarget.ownDepthBuffer = gl.createRenderBuffer(); +myTarget.ownDepthBuffer = gl.createRenderBuffer();

方法