# Transparency Groups?

**URL:** <https://forum.babylonjs.com/t/transparency-groups/64123>\
**Category:** Questions\
**Created:** [September 17, 2026, 8:55pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123 "2026-09-17T20:55:02Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jpg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jpg/32/43445_2.png) [@Jpg](https://forum.babylonjs.com/u/Jpg)\
**Post date:** [September 17, 2026, 8:55pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/1 "2026-09-17T20:55:02Z")

</div>

Hello!

Is there a way to group meshes/materials to ignore each other when dealing with transparency?

I am making a game where the character has swappable clothes and hair and I can see the objects from the other side.

Issue:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/a/8/a86974b3fccca04c25175241722c3b0a05bb8540.png)

Goals/Use Cases:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/0/0/00f80347dcf588ad65ee1ea00781d88d0339077e.jpeg)

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/2/0/20d10b4adcd15e2c07791551dbbf0e37659bbada.jpeg)

I set up a simple example to demonstrate my issue:

> **[Babylon.js Playground](https://playground.babylonjs.com/#WZUV2D)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

I have tried a bunch of things and nothing seemed to work perfectly.

- I noticed alphaIndex + needDepthPrePass works until I move the camera to certain angles.
- I made a RTT with a simple shader and it worked, but felt like this was a hack and not the right way to do things. I am concerned about performance and flexibility (if I had multiple characters each with their own RTT so that I could animate the invisibility effect).
- I looked at Multi Render Targets too, but I’m not yet familiar with how they work.

Here are some pictures to help demonstrate what I mean:

If I could hide the red from this angle that would be great, it’s visible through the green here.

 ![red](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/6/0/6033f374af30c81f021beb614085981aaf6f5e5f.png)

At this angle if I could hide the green but still show the blue box in the background that would be nice too.

 ![green](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/c/0/c0d871368179214a83d57771fc65f0e76a91bff1.png)

If anybody can help me, this would be a lifesaver, I’ve been tackling this issue for the past couple of days.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [September 17, 2026, 9:11pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/2 "2026-09-17T21:11:15Z")

</div>

You would probably need to render the scene without the group then grab stencil pass or a mask, then capture the group full color in an RTT then draw it back onto the main scene with your transparency amount masked by the stencil or mask RTT you made.

---

<div class="post-metadata">

**Author:** ![Jpg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jpg/32/43445_2.png) [@Jpg](https://forum.babylonjs.com/u/Jpg)\
**Post date:** [September 17, 2026, 9:21pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/3 "2026-09-17T21:21:21Z")

</div>

That is somewhat what I was doing. But I am unsure of performance.

```js
BABYLON.Effect.ShadersStore["invisibilityFragmentShader"] = `
    precision highp float;

    varying vec2 vUV;

    uniform sampler2D textureSampler;  
    uniform sampler2D backgroundSampler; 
    uniform float amount;

    void main(void) {
        vec4 sceneColor = texture2D(textureSampler, vUV);
        vec4 bgColor = texture2D(backgroundSampler, vUV);

        gl_FragColor = mix(sceneColor, bgColor, amount);
    }
`;

const bgTexture = new BABYLON.RenderTargetTexture("bgRTT", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, scene);
scene.customRenderTargets.push(bgTexture);
const renderList = [];
let effectAmount = 0.0;

function addToRenderList(rootNode) {
    rootNode.getChildMeshes().forEach(m => renderList.push(m));
    bgTexture.renderList = scene.meshes.filter(m => !renderList.includes(m));
    effectAmount = 0.7;
}

function removeFromRenderList (rootNode) {
    rootNode.getChildMeshes().forEach(m => renderList.splice(renderList.indexOf(m), 1));
    bgTexture.renderList = scene.meshes.filter(m => !renderList.includes(m));
    if (renderList.length == 0) effectAmount = 0.0;
};

const postProcess = new BABYLON.PostProcess(
    "invisiblePP", "invisibility", ["amount"], ["backgroundSampler"], 1.0, camera
);

postProcess.onApply = (effect) => {
    effect.setTexture("backgroundSampler", bgTexture);
    effect.setFloat("amount", effectAmount);
};

addToRenderList(player);

```

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [September 17, 2026, 9:23pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/4 "2026-09-17T21:23:36Z")

</div>

Performance should be fine as long as you don’t over use it, its just adding a couple draw calls for the one group id imagine.

---

<div class="post-metadata">

**Author:** ![Jpg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jpg/32/43445_2.png) [@Jpg](https://forum.babylonjs.com/u/Jpg)\
**Post date:** [September 17, 2026, 10:34pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/5 "2026-09-17T22:34:06Z")

</div>

I’ve just learned about RTTs yesterday, can clarify what you mean by group id? 😅

Don’t RTTs do a full re-render and render everything in the scene an additional time? Or perhaps I’m misunderstanding how render target textures work.

I thought maybe a visibility/alpha method would be better.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [September 17, 2026, 10:45pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/6 "2026-09-17T22:45:38Z")

</div>

Give me one second Ill whip something up for you.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [September 17, 2026, 11:05pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/7 "2026-09-17T23:05:07Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#7J9XO1)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

@jpg let me know if you have any questions.

---

<div class="post-metadata">

**Author:** ![Jpg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jpg/32/43445_2.png) [@Jpg](https://forum.babylonjs.com/u/Jpg)\
**Post date:** [September 18, 2026, 12:56am UTC](https://forum.babylonjs.com/t/transparency-groups/64123/8 "2026-09-18T00:56:26Z")

</div>

Thank you!

I spent the last couple hours going through it. I simplified the code just so I can what was really happening.

Others may view that here:

> **[Babylon.js Playground](https://playground.babylonjs.com/#7J9XO1%232)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

I am not sure what the overall performance gains are with this versus what I had. I know this renders the groups separately, but I’m concerned about now having two render target textures now, and also constantly updating a ghost camera.

Using alpha/visibility still seems to be the most performant way, but this approach is interesting.

---

<div class="post-metadata">

**Author:** ![Jpg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jpg/32/43445_2.png) [@Jpg](https://forum.babylonjs.com/u/Jpg)\
**Post date:** [September 18, 2026, 4:23pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/9 "2026-09-18T16:23:36Z")

</div>

I decided to go with RTTs instead of transparency. I am doing it a slightly different way though. I realized I could implement other effects other than just transparency, such as glow, warp, etc.

Examples from games:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/b/4/b4e4b5d604186e3949d40a961d9160f4a6c11abc.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/c/1/c1b3ee4d355743fb29309b2fa4bbf3e94dc08e6f.jpeg)  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/3X/d/3/d33ea5586954bf263dddb8094625e05dcec82628.jpeg)

I tested the performance with a few characters and saw a very small frame rate increase. I am not sure how it will play out with more complex scenes.

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [September 18, 2026, 4:45pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/10 "2026-09-18T16:45:43Z")

</div>

Yuup! Once you understand the basics of what we did then it unlocks a ton of possibilities. Remember you can capture any kind of 3d buffer and convert the coordinates in your shader to do magic. Its all just passing data around so you can use it. You would be amazed how many effects actually happen in screenspace.

---

<div class="post-metadata">

**Author:** ![Jpg](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jpg/32/43445_2.png) [@Jpg](https://forum.babylonjs.com/u/Jpg)\
**Post date:** [September 20, 2026, 2:00pm UTC](https://forum.babylonjs.com/t/transparency-groups/64123/11 "2026-09-20T14:00:38Z")

</div>

Okay I managed to get it to work.

So there’s an issue with layer masks and animations.

> **[Babylon.js docs](https://doc.babylonjs.com/features/featuresDeepDive/scene/layermask/#layers-and-skeleton-animations)**

BUT I managed to get it working with a depth renderer + an RTT. Essentially the code I posted earlier + a depth renderer + using the samplers you get from them in the GLSL.
