-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
DepthTexture: Update depth + stencil textures to work with multi sample RTT, make formats consistent #28460
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
||
let glInternalFormat = _gl.DEPTH_COMPONENT24; | ||
|
||
if ( isMultisample || useMultisampledRTT( renderTarget ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure why the if checks were different in the renderTarget.depthBuffer && ! renderTarget.stencilBuffer
branch compared to renderTarget.depthBuffer && renderTarget.stencilBuffer
. Why did you choose the below pattern?
if ( isUseMultisampledRTT ) {
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
} else if ( isMultisample ) {
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
} else {
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
}
and not this one:
if ( isMultisample || useMultisampledRTT( renderTarget ) ) {
if ( useMultisampledRTT( renderTarget ) ) {
multisampledRTTExt.renderbufferStorageMultisampleEXT( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
} else {
_gl.renderbufferStorageMultisample( _gl.RENDERBUFFER, samples, glInternalFormat, renderTarget.width, renderTarget.height );
}
} else {
_gl.renderbufferStorage( _gl.RENDERBUFFER, glInternalFormat, renderTarget.width, renderTarget.height );
}
Are they functional equivalent?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup! They're the same. I just thought it was easier to read. We can check using a table to make sure they get into the same branches.
Condition Layout 1
if ( isUseMultisampledRTT ) {
// Branch A
} else if ( isMultisample ) {
// Branch B
}
Table
isUseMultisampledRTT = true | isUseMultisampledRTT = false | |
---|---|---|
isMultisample = true | A | B |
isMultisample = false | A | None |
Condition Layout 2
if ( isMultisample || isUseMultisampledRTT ) {
if ( isUseMultisampledRTT ) {
// Branch A
} else {
// Branch B
}
}
Table
isUseMultisampledRTT = true | isUseMultisampledRTT = false | |
---|---|---|
isMultisample = true | A | B |
isMultisample = false | A | None |
Condition Layout 3
if ( isMultisample && isUseMultisampledRTT === false ) {
// Branch B
} else if ( isUseMultisampledRTT ) {
// Branch A
}
Table
isUseMultisampledRTT = true | isUseMultisampledRTT = false | |
---|---|---|
isMultisample = true | A | B |
isMultisample = false | A | None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! I definitely prefer the PRs approach.
Related issue: --
Description
I expect this hasn't been touched much since WebGL has been removed but there were a few issues I noticed with DepthTextures when I was experimenting with them for #28423:
You can see in the current depth texture example that using a stencil buffer breaks the page. With this PR: