Hello.
Can anyone please share an example or a link to the information about 2D Game map spritie visibility detection?
I have googled for a while now and only found the way to render 2D tile maps which is easy.
What i am looking for is a basic info on how to Render what is visible in the camera and not render invisible objects.
My project has a map with few big ground textures and a lot of objects placed on top in the Editor. Objects are not snapped to a grid and can be places anywhere in a free-form way (can be stretched, rotated). Basically i am moving around the map, and placing the objects anywhere i want.
What I am looking for is how to detect what sprites are in the viewport and only render them.
Thanks.
Juris.
2D Map Sprite Visibility Detection
Started by Annihilator, Dec 26 2012 11:57 AM
algorithm collision culling
3 replies to this topic
#1
Posted 26 December 2012 - 11:57 AM
Technical Director, Engine Programmer.
ANN-Tech. Team.
http://www.ann-tech.com
https://twitter.com/#!/ANNTechTeam
ANN-Tech. Team.
http://www.ann-tech.com
https://twitter.com/#!/ANNTechTeam
#2
Posted 26 December 2012 - 12:08 PM
If you want sprites which block the view of other sprites, look at 2D lighting techniques. There are loads of examples.
Otherwise it's a simple matter of checking which sprites intersect with the view rectangle.
Otherwise it's a simple matter of checking which sprites intersect with the view rectangle.
#3
Posted 26 December 2012 - 12:24 PM
Stainless, on 26 December 2012 - 12:08 PM, said:
Otherwise it's a simple matter of checking which sprites intersect with the view rectangle.
Yes, i have thought about it. but what if the map is huge and we have like 10.000 sprites, starting from small dirt, stones, grass textures
up to trees, buildings, NPCs ? Then looping through array that huge is not a good idea. That is what i have right now. And In the future,
our maps might have a lot more then 10.000 sprites, as the Artist has a full freedom to load the editor and place any objects anywhere.
It is a top down 2d map and i am looking for a way to detect visible sprites for that and not having to go through a loop of all sprites. Any ideas?
Technical Director, Engine Programmer.
ANN-Tech. Team.
http://www.ann-tech.com
https://twitter.com/#!/ANNTechTeam
ANN-Tech. Team.
http://www.ann-tech.com
https://twitter.com/#!/ANNTechTeam
#4
Posted 26 December 2012 - 07:33 PM
Then use a partitioning system
to allow for dynamic allocation, I would simply use regions. Divide the world into say a 16 by 16 space and create a class which contains all the sprites in that region
You could make each class cover the visible region. So depending on view direction and position you may only have to check 4 regions
Say you have 10,000 sprites in the map evenly distributed, then each cell would contain about 40 sprites. So at most you will have to check 160
to allow for dynamic allocation, I would simply use regions. Divide the world into say a 16 by 16 space and create a class which contains all the sprites in that region
You could make each class cover the visible region. So depending on view direction and position you may only have to check 4 regions
Say you have 10,000 sprites in the map evenly distributed, then each cell would contain about 40 sprites. So at most you will have to check 160
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












