postprocessing icon indicating copy to clipboard operation
postprocessing copied to clipboard

Per-object opacity for OutlineEffect

Open canadaduane opened this issue 2 years ago • 4 comments

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:

image

canadaduane avatar Feb 27 '22 23:02 canadaduane

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.

vanruesc avatar Mar 02 '22 14:03 vanruesc

I sure appreciate your work. Thanks for the insights & for keeping this as a tracker for potential improvement.

canadaduane avatar Mar 02 '22 21:03 canadaduane

A related feature request: per-object outline color (e.g. red outlines vs white outlines on the same pass).

canadaduane avatar Jul 04 '22 06:07 canadaduane

I'll put it on the outlines revamp feature list :sweat_smile:

vanruesc avatar Jul 04 '22 20:07 vanruesc