Thursday, March 10, 2016

opengl - How to draw only visible tiles?


I have a big map with isometric tiles(3d camera), how can i draw only visible tiles ?


Whats the best way to do that ? space partitionning (octrees etc...)?



Answer



If all the tiles are approximately the same size, lie roughly on a flat plane, and the camera is always a set distance from the plane, simply calculate the tile that the camera is looking directly at and then cull any tile whose distanceSquared() from the looked at tile is greater than a value that would place it outside the FOV.


When considering the 'value', consider the obliqueness of the vertical component of the FOV when using an isometric perspective.



Further optimization can be had by doing the same with small groups of tiles rather than each tile individually.


This method will usually give a number of false positives but will cull the vast majority in a big map situation and is relatively cheap.


No comments:

Post a Comment

Simple past, Present perfect Past perfect

Can you tell me which form of the following sentences is the correct one please? Imagine two friends discussing the gym... I was in a good s...