1
\$\begingroup\$

To fully get the benefits of GPU instancing in Unity in a voxel-like game I'm trying to batch as many static blocks as possible (the terrain won't be destructible, and I can't set these blocks to 'static' since I'll later need to assing different properties for each instance)

I see two possible solutions for this kind of problem:

• Creating a prefab for every possible block in my game, and batching togheter blocks with the same material/mesh/uvs

pros: won't need giant textureAtlas for storing albedo textures

cons: certain scenes with many differing terrain blocks may be hard to batch efficiently, and adding a property to every type of block would mean changing every block prefab (a nightmare if I have more than a handful of biomes)

• Creating a single block prefab and offset it's UVs with MaterialBlocks directly in the fragment shader

pros: every scene involving terrain blocks should at least in theory be efficiently batched, a single prefab to describe every type of terrain block

cons: needs a giant texture Atlas, and if it doesn't fits all of the block textures in the game more textures will be needed and I'll be limited in the future in the amount of blocks my game can have (unless I create different materials with different texture bindings, defeating the purpose of this solution), + fragment shader overhead for every type of block in the scene

Am I missing something here? Is there a different approach? If not, which one of the two would you consider the most appropriate in this scenario?

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.