-
-
Notifications
You must be signed in to change notification settings - Fork 35.6k
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
WebGLRenderer: Allow for binding and rendering into a 2d render target mipmap #29844
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
I'm very sick right now, so I can't give this my full attention until the end of next week. Just a quick glance: bullet points are reasonable and code looks nonintrusive so far. If I want hardware filtering for depth and shadows, I'll add it myself. No need for that burden now. |
Hey @CodyJasonBennett - just wanted to ping again. No rush though - hope you're feeling better! |
Yes, feeling much better. I'm hopping on a plane in a few hours, but just ping or assign me and I'll go through them first thing when I land. Thanks again for leading this stuff. |
How are you testing this? I'm noticing I have to disable |
This looks like it's maybe related to setting the
If you set |
Cool, that works well with |
Should this be merged? |
Yes. Would you want an example? One immediate use case might be custom mipmaps for alpha-testing (#20522). |
Sorry for losing track of this! Yes I think this is ready to be merged.
I think an example like that would be great and help identify some of the remaining issues with custom mip rendering. For something like the alpha test use case, for example, I think we'd want to be able to bind and render to actual raw Here's a rough idea of what that could look like: const texture = await new TextureLoader().loadAsync( /* texture url */ );
texture.generateMipmaps = MIPMAP_STORAGE;
const levels = getMipmapLevels( texture );
for ( let i = 1; i < levels; i ++ ) {
const resolution = getMipmapResolution( texture, i );
renderer.setRenderTarget( texture, 0, i );
/* render to texture mipmap */
} @CodyJasonBennett Not sure if it's worth thinking about MRT use cases before going too far down this path. |
Merging - we can discuss further needed changes in #29779 |
Related issue: #29779
Description
Adjusts
setRenderTarget
to afford binding and rendering into a specific mipmap level of a 2d render target texture. A scratch frame buffer is used to avoid cases where there are other attachments on the cached framebuffer without mipmaps (ie a depth buffer) resulting in an error when drawing (which was happening with 3d render targets, as well).cc @CodyJasonBennett
edit
looks like this will need some different handling for multisample targets but I'm not sure what the best way is to handle thatFixed by not rebinding mipmap level == 0 MSRT textures