Skip to content

Save/load texture atlas for caching to improve performance #12

@deathcap

Description

@deathcap

The complete process of generating the texture atlas is fairly expensive (including extracting the texture .png files from the resource pack .zip archives, which is not cached either: deathcap/artpacks#15), so it ought to be possible to save it and load a precomputed stitched atlas (including all the mipmap levels) for better performance.

There is existing code when the debug option is enabled to log the canvases to the document:

  if (showLevels) {
    // add each mip level to the page for debugging TODO: refactor with rect-mip-map demo
    pyramid.forEach(function(level, i) {
      var img = new Image();
      img.src = savePixels(level, 'canvas').toDataURL();
      img.style.border = '1px dotted black';
      document.body.appendChild(document.createElement('br'));
      document.body.appendChild(img);
      document.body.appendChild(document.createTextNode(' level #'+i+' ('+img.width+'x'+img.height+')'));
    });
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions