Real-time shading is an enormous performance hit on your CPU. Real-time shading should always be limited to just a few objects, especially when you apply Phong shading. Wherever possible, you should use baked textures that contain the shading information instead. However, when your project requires real-time bitmap-based shading, a small performance optimization is possible.
A good trick is to add the object that needs to be shaded to the scene twice. The first object has the regular bitmap material applied to it, which is the material you want to be shaded. The other object uses a color-based shader as material, for instance PhongMaterial
. The ambient color of this shader should be black to make this trick work. Each object should be added to a sublayer of an index sorted viewport layer. This renders the second object with a color based shader as the top layer. By using the BlendMode.MULTIPLY
as the blend mode of the top layer, you can create an illusion of shading on...