postprocessing
postprocessing copied to clipboard
Per-object opacity for OutlineEffect
Is your feature request related to a problem?
Currently, objects can be added to the OutlineEffect's selection
array in order to be rendered with an outline. The outline is either "on" or "off", with whatever opacity settings that may be provided at instantiation of the OutlineEffect itself (i.e. opacity affects all objects).
Describe the solution you'd like
Would it be possible to add an opacity
setting to individual objects? For example, rather than merely adding Object3Ds to the selection
array, perhaps a javascript object with per-Object3D parameters could be passed? e.g.
// At initialization:
const outlineEffect = new OutlineEffect(this.scene, this.camera, { ... });
const cube = new Mesh(new BoxGeometry( 1, 1, 1 ), new MeshBasicMaterial());
...
// Later:
this.outlineEffect.selection.push({
object: cube,
opacity: 0.5
});
// Even later:
this.outlineEffect.selection[0].opacity = 0.1;
Describe alternatives you've considered
I could create many OutlineEffect layers with pre-configured opacity, but when the number of objects combined with the opacity settings is large, the number of effect passes increases exponentially.
Additional context
As an example, I'd like to make the outline around this lamp "fade in" gently when selected, then "fade out" when deselected:
There are a number of ways the current OutlineEffect
implementation could be improved, especially in terms of performance and visual quality. Supporting per-object opacity would be nice, but figuring out if and how that's possible requires further research. I'm currently prioritizing other issues in postprocessing
, some of which will make it easier to implement features like this one. In that sense, let's keep this ticket open and revisit it later.
I sure appreciate your work. Thanks for the insights & for keeping this as a tracker for potential improvement.
A related feature request: per-object outline color (e.g. red outlines vs white outlines on the same pass).
I'll put it on the outlines revamp feature list :sweat_smile: