Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WebGLRenderTarget: Support for custom depth and stencil buffers #15490

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/api/en/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ <h3>[property:DepthTexture depthTexture]</h3>
If set, the scene depth will be rendered to this texture. Default is null.
</p>

<h3>[property:WebGLRenderbuffer ownDepthBuffer]</h3>
<p>
If set, the texture will use the user provided WebGLRenderBuffer instead of the one created by the renderer for this texture. Default is undefined.
</p>
<p>Usage:</p>
<code>
const myTarget = new THREE.WebGLRenderTarget( 512, 512 );
myTarget.ownDepthBuffer = gl.createRenderBuffer();
</code>

<h2>Methods</h2>

Expand Down
9 changes: 9 additions & 0 deletions docs/api/zh/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,15 @@ <h3>[property:DepthTexture depthTexture]</h3>
如果设置,那么场景的深度将会被渲染到此纹理上。默认为null
</p>

<h3>[property:WebGLRenderbuffer ownDepthBuffer]</h3>
<p>
如果设置,纹理将使用用户提供的 WebGLRenderBuffer,而不是渲染器为此纹理创建的缓冲区。默认是 undefined
</p>
<p>用法:</p>
<code>
const myTarget = new THREE.WebGLRenderTarget( 512, 512 );
myTarget.ownDepthBuffer = gl.createRenderBuffer();
</code>

<h2>方法</h2>

Expand Down
1 change: 1 addition & 0 deletions src/renderers/WebGLRenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}

Expand Down
2 changes: 1 addition & 1 deletion src/renderers/webgl/WebGLTextures.js
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

state.bindFramebuffer( _gl.FRAMEBUFFER, renderTargetProperties.__webglFramebuffer );
renderTargetProperties.__webglDepthbuffer = _gl.createRenderbuffer();
setupRenderBufferStorage( renderTargetProperties.__webglDepthbuffer, renderTarget, false );
setupRenderBufferStorage( renderTarget.ownDepthBuffer || renderTargetProperties.__webglDepthbuffer, renderTarget, false );

}

Expand Down