Shared Material (TGorillaSharedMaterialSource)

The TGorillaSharedMaterialSource is inherited from TGorillaDefaultMaterialSource and representing a container or storage for textures.

Do not link them directly to a 3D component.

Instead use an extended instance of TGorillaReferenceMaterialSource, f.e. TGorillaAtlasMaterialSource.

Background

Having games like Minecraft in mind, texturing seems very simple when using a single atlas texture. Working with FMX materials makes this a struggle. Because each time you create a material source and use the atlas texture, FMX will load the texture into the GPU. So if you're having an atlas with 8×8 parts, this will create 64 texture with the size of the original one. This is just horrible memory management.

That's not what we want. Gorilla3D offers a solution to you: SharedMaterialSource's!

You set up a shared atlas material source once, where you load up your atlas texture. Than you only create referenced materials linked to that source. The reference material shader will use the global texture for rendering, instead of registering its own.

Usage

The image above shows how a texture atlas (TGorillaSharedAtlasMaterialSource) can be referenced in multiple TGorillaAtlasMaterialSource instances to display only a explicit frame of that atlas.

Notice: TGorillaSharedMaterialSource and TGorillaReferenceMaterialSource are intended to be used as template for extended material sources, like TGorillaSharedAtlasMaterialSource