Render just visible parts ?
Members - Reputation: 127
Posted 18 June 2012 - 01:34 PM
Im trying to develop a simple 2D game and im just wondering ... if i have let's say a big map 1024x1024 that's not shown as whole ... let's say that on the screen appears just a 500x500 frame ...is directx rendering all the map with all things on it and show just a part or it's rendering just the shown by camera part ? if it's rendering the whole thing... how to make it render what i need.. how to optimize it ?;D
Ty in advance
Members - Reputation: 186
Posted 20 June 2012 - 06:26 AM
Edited by HNikolas, 20 June 2012 - 06:27 AM.
Members - Reputation: 173
Posted 20 June 2012 - 07:14 AM
So the World*View will still be computed for all the vertices in the scene, even if they will eventually be clipped.
In order to further optimize this you need some sort of spatial partitioning.
Since you have a 2D game here, a simple distance function from the camera could be used to reject objects from being rendered.
If you want you could use a grid for to split your scene into multiple areas and only render objects inside the viewable grid locations. This assumes that each grid cell is composed out of multiple objects.