Set mesh opacity selectively at renderer level without changing material opacity?

Here’s what I’m trying to achieve:

I have a scene with different meshes loaded. I want to be able to select a group of meshes, and make these meshes render differently than the others, for example make them transparent.
NOTE: each mesh has a different material and original opacity.

Here’s what i know:

I could traverse the scene and set the material opacity on each mesh depending on a ‘selected’ flag. On deselect it can reset to the original material or opacity. I want to avoid this option for different reasons.


I could set the Layer of each object and camera, but this completely hides the meshes that are not on the camera layer. I need them translucent, not hidden.


Postprocessing.js has a nice outline effect that reacts to ‘selected’ elements, so this may be a clue to how to do it.

Anyone here can suggest a way to do it? Is there a way to set a specific shader on a group of meshes not based on their material but on a layer?


There’s no built-in way that I know of. What you would need to do is keep track of the “overall” opacity, then multiply that by the opacities that each individual material should have, then finally apply the result to each material.