-
-
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
WebGLRenderer: Fix setRenderTarget()'s activeMipmapLevel #26347
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
@Mugen87 What do you think about this one? |
WebGL is very limited and you shouldn't limit it even more preventing the ability to render to mip levels. I use this feature in my project to generate custom mip levels for cube reflection captures. Possibly my implementation is not perfect but I can easily improve it if you tell me what to do. |
It would be good to provide a live example that demonstrate what use case currently breaks (so we can see that rendering to an active cube face /mip level does not work). |
Agreed. This PR would need to include an example of usage in order to get merged. @makovkins Would you be able to add one? |
The example can be similar to webgl_materials_cubemap_mipmaps which was added by #17072. Meaning it does not have to be fancy looking. A functional example which demonstrates the feature is totally fine for the beginning. |
Ok, I will provide an example as soon as possible |
Added an example that demonstrates rendering to mip levels of a cube texture. The example is super simple, it just colorizes the mip levels. |
Awesome! I review this PR in the upcoming days. |
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.
The PR looks good to me! The example really helped to understand the current limitation of the engine and how the PR resolves it.
const rt = new THREE.WebGLCubeRenderTarget( cubeMapSize, params ); | ||
|
||
const mipLevels = Math.log( cubeMapSize ) * Math.LOG2E + 1.0; | ||
for ( let i = 0; i < mipLevels; i ++ ) rt.texture.mipmaps.push( {} ); |
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.
@mrdoob Explicitly defining the mipmaps of the cube render target like demonstrated here triggers the new code path.
Code style.
Code style.
Clean up.
WebGLRenderer.setRenderTarget accepts 'activeMipmapLevel' parameter but actually it doesn't work.