Sign in to follow this  
b3rs3rk

Isometric Tiles Culling

Recommended Posts

Hi! I've started a small isometric renderer and now I would like to reduce a bit the draw calls... does anyone know a good tutorial on how to check which iso-tiles are on screen? Thank you :)

Share this post


Link to post
Share on other sites
It is quite straight-forward to figure that out, have you thought about the following?

1. Store the tiles in a two-dimensional array
2. tileIndexX = screen.x / TILE_WIDTH
3. tileIndexY = screen.y / TILE_HEIGHT

Let's say screen.x and screen.y are in world coordinates and are the center position of the screen in the world, and you know how many tiles fit on the screen, so you can simply do a two-dimensional loop to iterate through exactly the tiles to draw.

Compute the lowest and highest visible tile index along the x-axis:
4. x1 = tileIndexX - NUM_SCREEN_TILES_X / 2
5. x2 = tileIndexX + NUM_SCREEN_TILES_X / 2

Do the same for the y-axis:
6. y1 = tileIndexY - NUM_SCREEN_TILES_Y / 2
7. y2 = tileIndexY + NUM_SCREEN_TILES_Y / 2

8. For each tile x-index , from x1 to x2
->8.1. For each tile y-index, from y1 to y2
-->8.1.1. Draw the tile

Share this post


Link to post
Share on other sites
but.... for the bottom tiles, you have to extend your drawing algorithm to catch raise block. So, you may think that the bottom row of tiles is X=0 to 20 and Y=10, but if you have a tile at X=10 and Y=8 with height=5, it would be visible in this view.

Hope I made myself clear :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this