Hey, I’m working on a small voxel engine, and I’m optimizing the rendering by joining multiple blocks faces to a single quad, but I can’t find a way to properly texture it
So I was asking if it was even possible
Does GLSL ‘texture()’ function allows one to do tiling towards a texture atlas? If so, how can I do it?
My shader currently gives me these informations per vertex:
atlasX : the X offset in the texture atlas (integer)
atlasY : the Y offset in the texture atlas (integer)
quadX : the X offset relative to the quad we are rendering
quadY : the Y offset relative to the quad we are rendering
For example if I’m drawing a quad representing 4x4 blocks top face, (quadX, quadY) will be (0, 0), (4, 0), (0, 4), (4, 4)
Thank you, I hope my english was alright
EDIT: Alright i find a way to reach my goal, I’m basically calculating the UV dynamically (using an offset + a modulus) inside the fragment shader
float uvx = atlasX * uuvx + mod(quadX, 1.0) * uuvx;
float uvy = atlasY * uuvy + mod(quadY , 1.0) * uuvy;