Custom Texture Packing

Modified on Wed, 03 Jun 2020 at 05:58 PM

Voxel Play shaders uses texture arrays to reduce draw calls. Using a single material, Voxel Play can render hundred of different textures (of the same type: for example, a material using the shader or render type "opaque-3-textures" can render any number of textures).


Texture arrays are similar to texture atlas. The main difference is that we don't have to worry about texture bleeding or wrapping since textures in an array are treated as if they were different textures. In a texture atlas we have to consider an insert or padding between each texture and computing texture wrapping must be done at pixel shader which is a bit more expensive.


However, texture arrays require all textures must have the same size which can be troublesome if our world has many different textures. You may want to use some big textures that span several voxels while preserving the rest of textures small size to reduce memory usage.


For example, say you have 100 textures of 16x16 or 64x64 but also want to use a few big textures of 2048x2048.

In this case, enable the Custom Packing option for the voxel definitions that will use the big textures as shown in the picture below:



When "Custom Packing" is enabled, Voxel Play will create a different texture array to store those textures and also clone the template material used for the render type. This process is fully automatic at runtime.


Note that Voxel Play will not create a different texture array for each voxel definition that uses Custom Packing. Instead, Voxel Play will create an unique texture array for the same settings of texture size, uv scale and normal map/relief map settings. For example, if you have 10 voxel definitions that use the same settings shown above, Voxel Play will just create a new texture array and will pack all textures for the 10 voxel definitions in the same texture array. This saves memory and draw calls as the same material is used to render the textures for these voxel definitions.




Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article