How to calculate Uvs from texture atlas?

30 Views Asked by At

I have been making a voxel engine and I was planning to apply multiple textures on each face of a voxel.

My first approach was to pass in a texture code that depicts which face it is and sample it accordingly. The problem is it seems inefficient because I have 2 to 3 textures assigned in units.

My friend suggested me to use a texture atlas but the problem is I couldn't figure out how to calculate the Uvs for a specific texture.

Suppose I needed a grassblock from the atlas and the atlas has 64 textures and the first one in the top left was the grass block. How can I sample it?

0

There are 0 best solutions below