Very large map on small Render Texture

This is 1 million tiles stored in a Uint8Array and drawn (in part) onto a 1024×768 Render Texture the size of the camera viewport. The idea was a memory-saving alternative to a very large Tilemap or Render Texture.

3 Likes

Thank you for the idea, it is very useful.
I have noticed that when the camera moves to the left or up, sometimes the tiles in the first column or row do not render. A possible solution:

const xMin = Math.max(0, Math.floor((worldView.left-1) / tilewidth)); // line 122
const yMin = Math.max(0, Math.floor((worldView.top-1) / tileheight)); // line 124
1 Like

Yes, thanks.

this.cameras.main.preRender();

in draw() also fixes this. It happens because the world view is a frame behind until the camera’s render step.

1 Like