-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
WebGLRenderer: Support stenciling transmission buffer contents. #26959
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
Conversation
In case the regular rendering is using stencil based effects, the transmission pass also needs a stencil buffer so that the rendering matches the normal render pass. This contribution is funded by https://higharc.com/
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
src/renderers/WebGLRenderer.js
Outdated
| minFilter: LinearMipmapLinearFilter, | ||
| samples: ( isWebGL2 ) ? 4 : 0 | ||
| samples: ( isWebGL2 ) ? 4 : 0, | ||
| stencilBuffer: needStencilBuffer |
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.
For simplicity reasons, couldn't we just always create the transmission render target with a stencil buffer? I don't think this would cause noticeable overhead.
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'd always avoid extra memory allocations wherever possible. On a large resolution screen the bytes add up.
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.
TBH, I'm still a bit unsure about the amount of new code and the checks per frame if we could also fix the issue with just stencilBuffer: true.
Is it possible to quantify how much memory the engine would additionally allocate with enabled stencil buffer and e.g. a 5K framebuffer ?
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.
Stencil uses 1 byte per pixel, so for rendering at 5K resolution that's about 15 megabytes. Whether that's a lot or not depends on perspective, but I think we should avoid this kind of waste. With WebGL it also can't be assumed that the user is focusing on one app at once, but rather it's quite common to have multiple open simultaneously.
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.
With WebGL it also can't be assumed that the user is focusing on one app at once, but rather it's quite common to have multiple open simultaneously.
That's true but only when all applications actually rendering transmissive objects (which is not a common thing I would say). But yes I understand the concerns regarding memory.
@mrdoob What is your preference regarding this issue?
|
Side note: Stencil for the default drawing buffer is enabled by default (since the Let's clarify in #27799 (comment) first if we can set |
In case the regular rendering is using stencil based effects, the transmission pass also needs a stencil buffer so that the rendering matches the normal render pass.
This contribution is funded by Higharc