Jump to content
  • Advertisement
Sign in to follow this  
b3rs3rk

Isometric Tiles Culling

This topic is 3452 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!