Hey, I recently tested many use cases of SelectionOutlineLayer. First, to process transparent meshes occlusion, I apply scene.enableDepthRenderer().forceDepthWriteTransparentMeshes = true to make it work normally. Since I opened this setting and used the multi views, I found that the outline would draw abnormal like below:
Comparing two graphs and you will find some differences.
Any ideas about this issue?
Since the PG not support the multi views, I provide a demo here, you can try it!
Also, I found that the HighlightLayer would blink at the very first render step in multi views. Maybe some issues related to the Layers or EffectLayers? What do you think @Evgeni_Popov ?
Another issue that the SelectionOutlineLayer would not correctly process occlusion when a mesh with visibility 0 even if the depthRenderer.forceDepthWriteTransparentMeshes enabled.
But a mesh with material.alpha 0, it handles correctly.
I found that the clientRect of the canvas which used to initialize the Engine would affect the EffectLayer render when rendering multi views. I debug a lot and I still don’t know why. @Evgeni_Popov
That’s because the depth renderer is created right from the start by the scene.enableDepthRenderer().forceDepthWriteTransparentMeshes = true; call, and at this time, the current canvas size is 400x400 (the virtualDom size). The size will only be updated later on, when we first render to the view.
A simple fix is to move scene.enableDepthRenderer() just before the initialization of the selection outline layer, inside the scene.onPointerPick function.
It rescales the parent canvas (the canvas you pass when you create the engine) to the same dimensions than than the view canvas (this.setSize does that).
If it’s a problem, you can try to use your own resize strategy by passing a customResize function when you register the view.
It’s the same reason: because the highlight layer is created with the default 400x400 dimensions, the first time the layer must render, it recreates a number of resources (texture, post-processes), which generates this blinking.
As above, to fix the problem, you can create the highlight layer in scene.onPointerPick the first time a mesh is picked.
@Evgeni_Popov Is tha on purpose? You can see the outline get dark when it’s in front of other meshes which should be dealed with depth render forceWriteTransparentMeshesDepth.