You can simply set occlusionStrength to 1.
Please refer to line 59 in PG.
You can simply set occlusionStrength to 1.
Please refer to line 59 in PG.
I’ve now noticed you’ve added Frame Graph support. ![]()
Lately, Babylon.js has been merging so many PRs overnight(in my time zone) that I missed it.
Hey, I found a rendering issue that when a mesh with a transparent material appears in front of other meshes, the outline color will appear abnormal. Just like this.
I couldn’t reproduce the green rectangle you have in your screenshot?
Assuming that the green rectangle is there to highlight the issue, which is that a transparent object is being occluded even though it is in front of other objects.
This is because transparent objects are not drawn to the depth texture by default.
You can enable that like so:
scene.enableDepthRenderer().forceDepthWriteTransparentMeshes = true
It should work fine then.
Indeed, it works! Should it be enabled by default in SelectionOutlineLayer?![]()
Thank you so much for your help, noname0310!
I was curious about the opposite use case: I noticed that if 2 objects are selected, the outlines will not appear through each other. Is it possible to have the outlines appear through other selected objects?
Original PG before your occlusionStrength change: https://playground.babylonjs.com/#ADUC74#4
Thank you so much for your help! ![]()
You must use two Selection Outline Layers as follows. If three selected objects are in a row, you must use three layers to draw them on top of each other.
Creating N layers to draw N objects is highly inefficient because it assigns one RenderTarget per object, so it is best avoided.
Amazing
, thank you so much for your expertise, noname0310!!
noname0310, when you have time, could you please share some advice on using SelectionOutlineLayer with the SceneOptimizer?
When I turn on some optimizations like TextureOptimization and RenderTargetsOptimization, outlines can degrade over time, and eventually “burn in” to the window (if there are too many outlines).
Please see the video below and the PG linked here (Lines 42-43 can be commented out to prevent the degradation and “burn in” effects).
Thank you so much for your help, noname0310!! ![]()
Render target optimisation disables the render target as stated in the code.
As the Selection Outline Layer utilises a render target, this optimisation cannot be applied.
The appearance of burn-in occurs because the render target is disabled, preventing the render target texture from being updated.
The reason TextureOptimization lowers outline quality is because the Selection Outline Layer uses a Render Target Texture.
I looked at the code for this as well. The code does not account for the render target texture.
In my opinion, Scene Optimizer will be difficult to use alongside scenes that are even slightly complex or utilize advanced features.
Noted, thank you so much for your help, noname0310!
SelectionOutlineLayerhas been working amazingly well for my test project, and I’m loving it!! ![]()
I just wanted to mention that I’d really appreciate the added functionality to choose color per mesh/object. I saw it was already on the list of considered additions but I’d like to hereby +1 on that one. Having the option to select “thickness” per object as well would also be great, but color would be amazing already!
Whoa these would be amazing if possible! ![]()
Yes, color is definitely possible and not that hard to achieve. However, there is an issue that comes with it, and I’m not sure if it is possible to avoid it…
In my multi-color example from above, I utilized the same green channel used for storing selection IDs by subdividing it into separate bins like so:
Then, in a shader, I just remapped this data to a color gradient… I think this could be good for a few colors, like differentiating between friendly and enemy units in a game, or coloring the last selected object with a different color in DCC tools, for example.
However, to give a different color to every selected mesh (also assuming that some of them you might want to share the same color), I think the easiest approach could be reserving the unused blue channel for storing color ID data and then mapping that to a color gradient in a shader.
Regardless of the approach, the overlapping different-color object issue exists.
Ideally, one would expect a result like this (darker object is closer to the camera):
However, with TRIDIRECTIONAL sampling, you would get a result like this:
And with OCTADIRECTIONAL sampling, likely something like this:
I think outlines in “Blender” seem to suffer from this same issue, but since, by default, it uses similar colors for both the active object and selected objects (different shades of orange), along with small thickness and anti-aliasing, it blends together and isn’t too noticeable.
OMG what an amazing explanation! It’s awesome to learn the tricks of how the Selection Outliner is implemented ![]()
I see, I guess that’s a bit of a caveat. I think however that even with this issue it’d be a nice addition, as long as it’s well documented in the documentation ![]()