GlowLayer Inclusive and Exclusive Methods

Hello, and I have been looking to reduce the overhead of enabling glow in the scene by controlling the list of meshes which are included or excluded from the list of meshes attached to the GlowLayer (as described here).

Can I ask what is the expected behaviour of the following PG:

There are three meshes in the scene, including the root mesh imported by glb, and the scene makes 9 draw calls (and only two with the glow disabled). This would suggest that all three meshes are being called once per glow pass (horiz and vert).

In the following PG I have added all of the meshes (including the root) to the exclude mesh list (and removed the unnecessary getChildMeshes()[0] call).

This increases the number of draw calls to 11, despite all scene meshes being marked as excluded.

In the following PG I have set include and exclude values for each of the meshes individually.

This decreases the number of draw calls from 11 to 10, although it gives the appearance I believe was expected by the scene setup (glow only on the light mesh).

In the following PG I have used only the include method and disabled emissive color and texturing on all meshes besides the light.

This gives the appearance I would expect and also offers the easiest way of setting up the scene (using inclusive without needing to set exclusive on the other meshes). However, it makes 10 draw calls, which would suggest an exponential increase in calls and be totally unusable for more complex setups.

Finally, I have added emissive color back to the other meshes and followed the previous pattern of including only the required meshes.

This also results in only the desired meshes participating in the glow effect, despite the emissive value being > black for the Wall material.

Thank you for reading this far.

How can I enable the glow layer without creating the additional draw calls for unincluded meshes in the scene? Is the behaviour mentioned above expected or the result of shader and rendering updates which have broken what may have once worked?

r

1 Like

Here is another PG where I have disabled the DefaultEnvironment and used inclusive on the light mesh only.

This reduces draw calls from 10 to 8, but doesn’t explain where the additional draw calls are coming from. Disabling visibility on the Wall mesh further reduces the draw calls (to 7), but it would seem the Wall continues to be called by the GlowLayer.

Disabling the Wall mesh and Background, as well as the GlowLayer reduces draw calls to 1 (as expected in a scene with 1 material), although it further confuses how the GlowLayer is using the material attached to the disabled mesh.

Thanks again for taking the time to follow along, and I appreciate any suggestions to optimizing GlowLayer usage in the scene.

r

Sorry, I didn’t read everything, but here’s how it works:

  • There are two draw calls without the glow layer. There are two meshes (PG with no default environment), so two draw calls (the root “mesh” is a mesh without geometry, so it is not drawn)
  • When you enable the glow layer (and you don’t include/exclude meshes), you get 7 additional draw calls:
    • 2 draw calls to draw the two meshes in the glow layer
    • 2 draw calls for the first blur pass (one horizontal and one vertical pass)
    • 2 draw calls for the second blur pass (one horizontal and one vertical pass)
    • 1 draw call to merge the blur layer with the scene

Now, when you call addIncludedOnlyMesh at least once, the glow layer will only draw these meshes to the glow layer.
If you don’t call addIncludedOnlyMesh but call addExcludedMesh, all meshes of the scene will be drawn to the glow layer SAVE for the meshes you excluded.

I think this should explain all your results(?)

1 Like

Hey, and thanks for answering. In the fourth PG (second from bottom) I have used include on one of the two meshes and disabled any emissive values on the other mesh’s material (for the love of effort). The result is 10 draw calls.

Assumedly, one draw call for each mesh and another for the background, plus three draw calls for the mesh which is included in the glow. What would be causing the additional calls? It is conceivable to use instancing and buffers to keep draw calls low, but I would like to understand if there are empty calls being made or an error in the setup which would make debugging difficult in more complex scenes.

May I also ask why the horizontal and vertical blurring are not done in a single pass? There are fast versions of gaussian blur filters which would do the job just as well.

r

It is the #LRFB2D#866 one, right? It checks out:

5 base draw calls from GlowLayer
+ 2 draw calls for the glow layer mesh (light)
+ 1 draw call for the other mesh (panel)
+ 2 draw calls for the background meshes (skybox, plane)

= 10


Anyway, depending on what your final goal is, do keep in mind that you will need non-glowing occluders as well if you do not want your glowing meshes to shine through them. In the 4th playground, rotate the camera so that the panel occludes the light → light shines through.

My count for PG #4 is like this:

  • 4 draw calls for the Light, Wall, Plane, Skybox (the last two coming from the default env)
  • 6 draw calls for the glow layer:
    • 1 draw call to draw the Light mesh in the layer
    • 4 draw calls for the blurring
    • 1 draw call to merge the glow layer with the scene

It’s faster to do two separate passes one after the other then a single one (see Blur effect - why two passes? - Graphics and GPU Programming - GameDev.net for eg).

3 Likes

Thanks, and I appreciate the clarity of answer. I think my misunderstanding was in accounting for the 4 draw calls of blurring; one to write to the buffer and the second to perform the blur.

I’m not sure what you mean by this. The 4 draw calls are simply:

  • horizontal blur for blur pass 1
  • vertical blur for blur pass 1
  • horizontal blur for blur pass 2
  • vertical blur for blur pass 2

It would probably be clearer for you to use Spector and watch what is generated in your PG.

1 Like