Referencing multiple textures on one mesh

im trying to generate a mesh with multiple cubes, like Minecraft, and I don’t want to store every single texture in a single texture sheet for obvious reasons. so how do I programmatically reference different materials or textures when mapping UV coords

Not sure what you mean by

Minecraft always has used a texture atlas. In the beginning and for a long time we had a single 256x256 “terrain.png” which included all textures for all blocks. Since 2013 MC uses a dynamically generated texture atlas from the individual textures…

ah my mistake, I did a quick lookup and found a couple results saying it used multiple atlases, probably should have checked the sources lol

Well, afaik MC only uses a single atlas texture for the terrain. It has several atlases for other purposes (entities, items, particle effects and some other stuff). Most modern GPUs have a texture size limit of 16k². That means with the default block texture size of 16x16 you can fit one million textures into one atlas. Though when your textures are 128x128, you can only handle 16k textures. When you have 512x512 textures only 1024 would fit in that atlas.

It seems that only modern Nvidia GPUs can handle larger textures likd 32k². Just a couple of years ago the low spec limit you should keep in mind was somewhere around 2k and 4k. It was a gradual change. If your game demands such a high texture resolution support, it would limit who and which devices will be able to run it.

Binding textures during rendering is very expensive. That’s why you want to avoid switching out textures / materials. That’s why Unity actually has batching support so that objects which use the same material cam be rendered together.

Technically it would be possible to have two or more texture atlases, however that would mean you would split a chunk into several meshes.

ah I see ty