Is it possible to have the result from Case 1 (glow blocked) but without double the draw calls?
Please note that using Instances will prevent the doubling of draw calls, however, the current use case requires Meshes (with animations and different materials and textures).
It is not possible to have the same result without making more draw calls because those draw calls are used to draw the meshes in the glow layer (and block the glowing cube because it is farther).
When using gl.addIncludedOnlyMesh(glowSquare) you are instructing the glow layer to only render glowSquare and nothing else in the glow layer.
Is it possible to have glow without using BABYLON.GlowLayer. For example, could we have glow just by using Node Materials or shaders? If so, could this prevent doubling draw calls?
Please excuse my noob understanding of rendering Is the doubling of draw calls coming from the use of Layer? I’m not sure why the green meshes have to be drawn twice just to block the glow from the yellow mesh. Could we just render the yellow mesh glow first and then render the green meshes just once?
Well, you can write a custom shader to make your mesh look highlighted, and in this case you will get a single draw call.
But the glow layer of Babylon requires an additional pass to render the glow layer: there’s a specific render target texture setup for this and all meshes in the glow layer are rendered to this texture using a specific shader. Then, this texture is combined with the scene in a final post process.
You can have a more deeper look at what is really going on by using Spector on your scene and see all the renderings that take place.
Could there be some way to do it with the depth buffer? i.e. write depth values to the glowlayer and then compare it to the main depth buffer?
In my scenario I have a very large amount of draw calls but only very few emissive materials.
This is a pretty good idea but would require a depth texture which could only be done by rendering everything first into a RenderTarget. You should definitely try it and let us know how it goes ?