Multiple models and their materials

If I have two models that in Blender are stored in the same blend-file and share the same material and texture(s), but that are exported separately, will Panda recognise their materials and textures as the same and treat them as such, or will it treat them as separate materials?

To explain, I’m working on having the model-files for larger levels in my game be split into multiple files. This would, I hope, allow me to more-quickly make small-scale changes and to speed up the overall export-and-import process.

However, this means that I’ll have material- and texture- entries repeated across those files. If, for example, I have two buildings that use the same material but that end up in different files, their files would presumably each include a copy of that material and the references to its textures. I’m thus concerned that I’ll end up with a multiplicity of materials and texture-references, potentially degrading performance.

(If this is a problem for materials, I can perhaps try calling “setMaterialOff” on all nodes, as I’m not using Panda materials in any significant way as far as I recall. Blender materials are just used as a way to get YABEE to apply my textures, and to export my vertex normals.)

Um, you touched on one of the topics that I’m concerned about. Earlier, I expressed the idea of making the material a separate file. And as far as I remember, @rdb considered this possible in the near future. However, this has not yet happened, it is theoretically possible to remove material from the EGG files. And to make an additional upload of your material, you will have to create your own material format. Also write code to read this file.

1 Like

The .egg loader will unify references to identical materials through the MaterialPool, so you don’t need to worry about it. Even if it didn’t, Material objects do not consume any graphics memory at the moment, and a negligible amount of system memory.

References to external texture files are automatically unified through the TexturePool.

References to identical TextureStage objects are automatically unified through the TextureStagePool, but like Materials, TextureStage objects also only consume a small amount of system memory and no graphics memory. You can explicitly unify identical texture stages in a scene using render.unifyTextureStages().

The main reason why Material and TextureStage objects are uniquified is to reduce the number of unique RenderState objects that Panda will be creating under the hood.

2 Likes

Ah, that’s excellent to know, and impressive! Thank you for answering! :slight_smile: