best practice for performance (3d)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By samuncle
:warning: Old Version Published before Godot 3 was released.

I have a question regarding performances (in 3d)

If I have several small objects like a pencil, a bottle, a radio each one of them using a 256 * 256 texture. Would it be better to create a texture atlas and shared material. For instance a 512 * 512 texture containing all 4 objects?

In the end there would be 4 objects but only one material

:bust_in_silhouette: Reply From: volzhs

Document says YES.

http://docs.godotengine.org/en/latest/tutorials/3d/3d_performance_and_limitations.html#reuse-shaders-and-materials

Reuse shaders and materials

Godot renderer is a little different to what is out there. It’s designed to minimize GPU state changes as much as possible. FixedMaterial does a good job at reusing materials that need similar shaders but, if custom shaders are used, make sure to reuse them as much as possible. Godot’s priorities will be like this:

  • Reusing Materials: The less amount of different materials in the scene, the faster the rendering will be. If a scene has a huge amount of objects (in the hundreds or thousands) try reusing the materials or in the worst case use atlases.

  • Reusing Shaders: If materials can’t be reused, at least try to re-use shaders (or FixedMaterials with different parameters but same configuration).

If a scene has, for example, 20.000 objects with 20.000 different materials each, rendering will be really slow. If the same scene has 20.000 objects, but only uses 100 materials, rendering will be blazing fast.