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

RenderTarget: Add resolveStencilBuffer. #28096

Merged
merged 2 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/api/ar/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ <h3>
<br />
[page:Boolean depthBuffer] - الافتراضي هو `true`. <br />
[page:Boolean stencilBuffer] - الافتراضي هو `false`. <br />
[page:Boolean resolveStencilBuffer] - الافتراضي هو `true`. <br />
[page:Number samples] - الافتراضي هو 0. <br /><br />

ينشئ جديدًا [name]
Expand Down Expand Up @@ -86,6 +87,12 @@ <h3>[property:Boolean depthBuffer]</h3>

<h3>[property:Boolean stencilBuffer]</h3>
<p>يعرض على مخزن القالب. الافتراضي هو false.</p>

<h3>[property:Boolean resolveStencilBuffer]</h3>
<p>
Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
Default is `true`.
</p>

<h3>[property:DepthTexture depthTexture]</h3>
<p>
Expand Down
7 changes: 7 additions & 0 deletions docs/api/en/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ <h3>
<br />
[page:Boolean depthBuffer] - default is `true`. <br />
[page:Boolean stencilBuffer] - default is `false`.<br />
[page:Boolean resolveStencilBuffer] - default is `true`.<br />
[page:Number samples] - default is `0`.<br />
[page:Number count] - default is `1`.<br /><br />

Expand Down Expand Up @@ -96,6 +97,12 @@ <h3>[property:Boolean depthBuffer]</h3>
<h3>[property:Boolean stencilBuffer]</h3>
<p>Renders to the stencil buffer. Default is false.</p>

<h3>[property:Boolean resolveStencilBuffer]</h3>
<p>
Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
Default is `true`.
</p>

<h3>[property:DepthTexture depthTexture]</h3>
<p>
If set, the scene depth will be rendered to this texture. Default is null.
Expand Down
7 changes: 7 additions & 0 deletions docs/api/it/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ <h3>[name]([param:Number width], [param:Number height], [param:Object options])<
[page:Constant colorSpace] - il valore predefinito è [page:Textures NoColorSpace]. <br />
[page:Boolean depthBuffer] - il valore predefinito è `true`. <br />
[page:Boolean stencilBuffer] - il valore predefinito è `false`.<br />
[page:Boolean resolveStencilBuffer] - il valore predefinito è `true`.<br />
[page:Number samples] - il valore predefinito è 0.<br />
[page:Number count] - default is `1`.<br /><br />

Expand Down Expand Up @@ -101,6 +102,12 @@ <h3>[property:Boolean stencilBuffer]</h3>
Effettua il rendering al buffer stencil. Il valore predefinito è `false`.
</p>

<h3>[property:Boolean resolveStencilBuffer]</h3>
<p>
Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
Il valore predefinito è `true`.
</p>

<h3>[property:DepthTexture depthTexture]</h3>
<p>
Se impostato, la profondità della scena verrà renderizzata su questa texture. Il valore predefinito è `null`.
Expand Down
9 changes: 8 additions & 1 deletion docs/api/zh/renderers/WebGLRenderTarget.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ <h3>[name]([param:Number width], [param:Number height], [param:Object options])<
[page:Constant colorSpace] - 默认是[page:Textures NoColorSpace]. <br />
[page:Boolean depthBuffer] - 默认是`true`.<br />
[page:Boolean stencilBuffer] - 默认是`false`.<br />
[page:Boolean resolveStencilBuffer] - 默认是`true`.<br />
[page:Number samples] - 默认是`0`.<br />
[page:Number count] - default is `1`.<br /><br />

Expand Down Expand Up @@ -94,7 +95,13 @@ <h3>[property:Boolean depthBuffer]</h3>

<h3>[property:Boolean stencilBuffer]</h3>
<p>
渲染到模板缓冲区。默认为false
渲染到模板缓冲区。默认为false.
</p>

<h3>[property:Boolean resolveStencilBuffer]</h3>
<p>
Defines whether the stencil buffer should be resolved when rendering into a multisampled render target.
默认为`true`.
</p>

<h3>[property:DepthTexture depthTexture]</h3>
Expand Down
5 changes: 5 additions & 0 deletions src/core/RenderTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class RenderTarget extends EventDispatcher {
minFilter: LinearFilter,
depthBuffer: true,
stencilBuffer: false,
resolveStencilBuffer: true,
depthTexture: null,
samples: 0,
count: 1
Expand All @@ -58,6 +59,8 @@ class RenderTarget extends EventDispatcher {
this.depthBuffer = options.depthBuffer;
this.stencilBuffer = options.stencilBuffer;

this.resolveStencilBuffer = options.resolveStencilBuffer;

this.depthTexture = options.depthTexture;

this.samples = options.samples;
Expand Down Expand Up @@ -135,6 +138,8 @@ class RenderTarget extends EventDispatcher {
this.depthBuffer = source.depthBuffer;
this.stencilBuffer = source.stencilBuffer;

this.resolveStencilBuffer = source.resolveStencilBuffer;

if ( source.depthTexture !== null ) this.depthTexture = source.depthTexture.clone();

this.samples = source.samples;
Expand Down
6 changes: 2 additions & 4 deletions src/renderers/WebGLRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -1404,12 +1404,10 @@ class WebGLRenderer {
type: ( extensions.has( 'EXT_color_buffer_half_float' ) || extensions.has( 'EXT_color_buffer_float' ) ) ? HalfFloatType : UnsignedByteType,
minFilter: LinearMipmapLinearFilter,
samples: 4,
stencilBuffer: stencil
stencilBuffer: stencil,
resolveStencilBuffer: false
} );

const renderTargetProperties = properties.get( currentRenderState.state.transmissionRenderTarget );
renderTargetProperties.__isTransmissionRenderTarget = true;

// debug

/*
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 @@ -1880,7 +1880,7 @@ function WebGLTextures( _gl, extensions, state, properties, capabilities, utils,

// resolving stencil is slow with a D3D backend. disable it for all transmission render targets (see #27799)

if ( renderTarget.stencilBuffer && renderTargetProperties.__isTransmissionRenderTarget !== true ) mask |= _gl.STENCIL_BUFFER_BIT;
if ( renderTarget.stencilBuffer && renderTarget.resolveStencilBuffer ) mask |= _gl.STENCIL_BUFFER_BIT;

}

Expand Down