BatchedMesh: Enable per-instance opacity#32725
Conversation
📦 Bundle sizeFull ESM build, minified and gzipped.
🌳 Bundle size after tree-shakingMinimal build including a renderer, camera, empty scene, and dependencies.
|
|
Puppeteer doesn't like my screenshot - probably because of too many random values 🤔 I'll try changing the materials used in the demo back to |
gkjohnson
left a comment
There was a problem hiding this comment.
Just added some comments - at a high level I don't have an issue with the idea but I think there are some architectural complexities with vertex colors that make this more difficult.
Puppeteer doesn't like my screenshot - probably because of too many random values 🤔
It looks like the uploaded screenshot doesn't include any transparency. Here's the comparison downloaded from the CI artifacts:
| Commited | CI |
|---|---|
![]() |
![]() |
My bad, I forgot to build the lib before generating the screenshot 🤦♂️ |
gkjohnson
left a comment
There was a problem hiding this comment.
A few more comments but generally this is looking like the right direction to merge. To summarize the changes from what I can tell:
- the vertex color varying is now always set to a vec4
- vertex colors multiply in just the rgb channel if a vec3 (
USE_COLOR). Otherwise all four channels are multiplied if using RGBA (USE_COLOR_ALPHA). - BatchedMesh colors always multiply in vec4 rgba
- InstancedMesh colors always multiply in vec3 rgb
Open question
Will be reevaluated after #32742 is done. |


Description
Related: #28151
This PR adds support for per-instance opacity to
BatchedMesh. The current implementation ofBatchedMeshalready uses colors with 4 components and it supports sorting. The only thing missing is to use the alpha information in the shader.I've removed the
opacityoption from the example because it no longer made sense with per-instance transparency.This contribution is funded by Cozy Giant