• Editor
  • Textures and resolutions

Related Discussions
...

Nate, would you consider always adding the original dimensions of the page used to compute the "xy" and "size" of each region in the atlas? With this, normalized texture coordinates could be computed and the texture dimensions wouldn't matter.

tex_matrix.identity();
tex_matrix.scale(1.0 / page.w, 1.0 / page.h); // region in page pixel units
tex_matrix.translate(region.x, region.y); // from atlas.region.xy
tex_matrix.scale(region.w, region.h); // from atlas.region.size

What would be the purpose of storing the page size? Currently the page image size doesn't change. If you have a smaller atlas, you have a different atlas file and different page images. The images might be packed differently and the pixel size of the regions could be slightly smaller or large depending on how they were scaled.

If I had the dimensions of the image used to compute the regions, I could swap out the atlas image (example.png - 1024x1024) with a low-res version (example-low.png - 256x256) at runtime and use the same atlas (example.atlas) by scaling the "xy" and "size" fields by 256/1024 (normalized texture coordinates) without needing to load example.png to see what the dimensions were.

var atlas_png = atlas.page.name;
if (low_res)
{
    atlas_png = basename(atlas_png) + "-low.png"
}

I think you might have off by one pixel issues doing that, depending on how the downscaled images are rasterized. If the packer could create multiple atlas sizes I don't think it is much of an issue to swap both the atlas file and images.

Yeah, that makes sense. For this to work, the higher res images would need larger gaps between the regions. Not exactly ideal. Thanks for hearing me out.