In theory (untested), the fallowing could work. Might vary depending on the Graphics Pipeline.
Assuming you are using custom shaders. The basic concept (in my probably failing attempts to explain it) is to take the world position of each fragment, and use that to generate your texture coordinates. Those coordinates ranging from (0,0) to (1,1), representing an entire image. Say you wanted 1/1 unit/image ratio (the image repeated once for every unit of space), In GLSL:
vec3 worldTexCoord = fract(vertexPosition.xyz); // 1 unit in the game world will
// vary from (0,0) to (1,1) in TexCoords
You could then transform that into a smaller portion of the atlas. So then, instead of repeating an entire image, only the small portion of the image could be repeated.
vec2 trueTexCoord = mix(texCoordMin.xy, texCoordMax.xy, worldTexCoord.xy);
So then, if you want the image to repeat from the texture-coordinates
(0.5,0.5) (instead of
(1,1)), you would set
texCoordMin.xy = vec2(0.1, 0.1) and
texCoordMax.xy = vec2(0.5, 0.5)
You could also say
texCoordMax.xy = texCoordMin.xy + vec2(0.4, 0.4) and get the same result as above.
So, after probably failing at that explanation, here is an overview.
- Pass Vertex Position (in world coordinates) to the fragment/pixel shader
- Use the Vertex Position to generate the texture-coordinates.
- Manipulate the Vertex Position coordinates into coordinates relative to a smaller portion of the image, as indicated by the Texture Coordinates.
Sorry, scratch that.
Personally, I would suggest Sparse-Voxel-Octrees (SVO) if your looking to optimize your meshes. It works by clumping up large chunks formed of the same type of terrain. (Air, dirt, etc) so you wind up with, not only an optimized mesh, but a memory efficient structure, which could double as a Space Partitioning Tree for whatever else you may do.
Another thing usually done, is RLE (Run Length Encoding), it is used in BMP images to unify strips of similar colors from
X color, X color, X color, ... down to saying
X color is repeated Y times, reducing the required space when stored on your hard-drive. That get's interpreted when rendering Voxels as
X textured polygon is Y times it's usual length
What does the guy in that image use? Looking at it, I would guess an SVO. It seems to have some resemblance. Large polygons for flat surfaces, little squares around corners that vary from
solid type to
air type. Though his flat surfaces do tend to be more rectangular, with less of an identifiable structure. could be some further optimizations on his part. But he doesn't actually texture the terrain, so can't actually know if there are multiple voxel types per polygon.