deathcap / voxel-texture-shader

custom shader for texturing voxels in voxeljs (for three.js-based voxel-engine, no longer needed with voxel-engine-stackgl)
MIT License
8 stars 1 forks source link

Manual mipmaps instead of tilepad? #1

Open deathcap opened 10 years ago

deathcap commented 10 years ago

From http://0fps.wordpress.com/2013/07/09/texture-atlases-wrapping-and-mip-mapping/

Using an automatic mipmap generator like glGenerateMipmaps will cause blurring across texture atlas boundaries, creating visible texture seams at a distance.

At least the first of these problems is pretty easy to solve. The simple fix is that instead of generating a mipmap for all the tiles simultaneously, we generate a mipmap for each tile independently using periodic boundary conditions and pack the result into a texture map. This can be done efficiently using sinc interpolation and an FFT (for an example of how this works, check out this repository). Applying this to each tile in the texture atlas separately prevents any accidental smearing across boundaries.

Ref https://github.com/deathcap/voxpopuli/issues/32 - instead adding tilepad reduced the distant seams, but also increased texture sizes in the atlas to quadruple. Using manual mipmaps where each tile is scaled individually may be a better fix, though with my initial per-tile scaling attempts (e853e12) it did not show any difference (seams still visible); would need further investigation