Setting Mesh.renderingGroupId without standard material at 0 layer removes highlight

When setting Mesh.renderingGroupId without having at least one mesh in the scene using StandardMaterial in renderingGroupId = 0, the highlight and normalTexture does not work for all other Meshes.

The sphere has no highlight when the box uses BackgroundMaterial:
https://www.babylonjs-playground.com/#B5P4DA#3

Make the box in renderingGroupId 0 use standard material, and highlight works as expected:
https://www.babylonjs-playground.com/#B5P4DA#4

@Rationale:

  • Due to performance optimisations, our app doesn’t have any meshes with standard material in the 0 rendering group (only background and grid materials), so it is annoying having to create a dummy mesh just to activate standard material on all other layers.
  • Initial benchmark showed that using BackgroundMaterial for Skybox vs. StandardMaterial shaved off 2.1 ms GPU frame time (x3 faster in our case), even though both had disableLighting = true

This PR will fix the problem:

1 Like