# Very large map on small Render Texture

**URL:** <https://phaser.discourse.group/t/very-large-map-on-small-render-texture/14853>\
**Category:** Examples\
**Created:** [October 16, 2024, 3:47pm UTC](https://phaser.discourse.group/t/very-large-map-on-small-render-texture/14853 "2024-10-16T15:47:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 16, 2024, 3:47pm UTC](https://phaser.discourse.group/t/very-large-map-on-small-render-texture/14853/1 "2024-10-16T15:47:31Z")

</div>

![Desert map](https://global.discourse-cdn.com/free1/uploads/phaser1/original/2X/f/ffb84ae3075bca9421497b3697eee36db6c5d9bf.png)

This is 1 million tiles stored in a [Uint8Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array "The Uint8Array typed array represents an array of 8-bit unsigned integers") 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.

> **[Very large map on small Render Texture Phaser Sandbox Entry](https://phaser.io/sandbox/iueb1Von)**
>
> 1 million tiles. Scroll with cursor keys

---

<div class="post-metadata">

**Author:** ![jjcapellan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jjcapellan/32/542_2.png) [@jjcapellan](https://phaser.discourse.group/u/jjcapellan)\
**Post date:** [October 17, 2024, 6:53pm UTC](https://phaser.discourse.group/t/very-large-map-on-small-render-texture/14853/2 "2024-10-17T18:53:51Z")

</div>

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:

```javascript
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

```

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [October 17, 2024, 7:43pm UTC](https://phaser.discourse.group/t/very-large-map-on-small-render-texture/14853/3 "2024-10-17T19:43:26Z")

</div>

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.
