Megatextures

Latest days I've been working on the latest hype (or not) of 3d engine : megatexture ! However, I didn't want it to alter the toolchain with specific texturing tools.

After some thinking, I think I came up with an interesting idea :

  • Mega texture (including atlas) is built on the fly, with a given texture block granularity (let's say 32 * 32 texels).
  • To avoid wasting resource, tiling is detected via a simple CRC check of texture blocks when a texture is uploaded.
  • Texture could also be checked for duplication before uploading (not sure of that, still to be determined).
  • UV mapping of objects get remapped at loading.

My hope is to end with a system where you could paint in the middle of a very big tiled texture very easily while consuming minimum texture size. In fact, megatexture, or the idea of virtualizing textures is a neat idea, but some care should be taken (i.e. still use of tiling/texture reuse), because a 32k*32k seems a lot, but stretched over a very big terrain, it could end up with a very bad resolution.

My hope is it will be merged in the source within few days.

Update : After some prototyping, seems to behave fine (no artifact). I gonna take a look at perfhud to check if it's not too heavy (on pixel-shader side). In fact, with bilinear filtering, 8 texture lookups are needed.

Update 2 : Pixel shader complexity was increasing too much. As a result, I switched the way to do it and I ended up with border uploaded. Now pixel shader is basically two tex2D lookup, a frac and few additions/multiplications. It was a bit painful to get perfect mipmaps (including border) without any shifting artifact.