2D occlusion culling
来源:互联网 发布:网络技术开发合同 编辑:程序博客网 时间:2024/04/29 18:24
Ask:
In my 2D game, I have static and dynamic objects. There can bemultiple cameras. My problem:Determineobjects that intersect with the current camera's viewrectangle.
Currently, I simply iterate over all existing objects (not caringwheter dynamic or static) and do an AABB check with the camerasview rect on them. This seems acceptable for very dynamic objects,but not for static objects, where there can be tens of thousands ofthem (static level geometry scattered over the whole scene).
I have looked into multiple data structures which could solve myproblem:
- Quadtree
This was the first thing I considered, however the problem is thatit would force my scenes to be of fixed size. (Acceptable forstatic, but not for dynamic objects)
- Dynamic AABB tree
Seems good, but the overhead for rebalancing it seems just toogreat for many dynamic objects.
- Spatial hash
The main problem here for me was that if you zoom out with thecamera a lot, a huge number of mostly non-existing spatial hashbuckets had to be queried, causing low performance.
In general, my criterias for a good solution of this problemare:
Dynamic size: The solution must not cause the scene size to belimited, or require heavy recomputation for resizing
Good query performance (for the camera)
Good support of very dynamic objects: The computations needed tohandle objects with constantly changing position should begood:
The maximum sane number of dynamic objects in my game at one timeprobably is at 5000. Consider they all change their position everyframe. Is there even a data structure which can be faster,considering the frequent insertions and deletions, than comparingthe AABBs of the objects with the camera every frame?
Answer
Don't try to find the silver bullet. Just split your scene intodynamic and static parts and use different algorithms for them.
Quad trees are obviously suitable for static geometry with fixedbounds.
Spatial hashes are ideal for sets of objects with similarsizes
(particle systems, for example).AFAIK dynamic AABB trees are rarely used for occlusion culling,their main purpose is the broad phase of collision detection.
And as you noticed, bruteforce culling is normal for dynamicobjects if the number of them is not really big.
static level geometry scattered over the whole scene
If your scene is highly-sparse, you can divide it into islands,i.e. create a list of scene parts with "good density".
URL:http://stackoverflow.com/questions/6979910/best-solution-for-2d-occlusion-culling
参考:
1、squadTree
http://blog.sina.com.cn/s/blog_61f4999d0102uxmd.html
2、Spatial hashes
http://www.eecs.ucf.edu/~jmesit/publications/scsc 2005.pdf
- 2D occlusion culling
- Occlusion Culling
- Occlusion culling
- Occlusion Culling Algorithms
- Occlusion Culling-Unity
- [Graphics]Occlusion Culling
- Unity3d:Occlusion Culling
- Occlusion culling 趟坑
- HSR算法-Occlusion Culling
- [HSR算法-Occlusion Culling]
- Occlusion Culling in Unity 4.3
- [HSR算法-Occlusion Culling]
- Unity 3D 遮挡剔除(仅专业版) Occlusion Culling (Pro only)
- [Unity-13] Unity 3D 遮挡剔除(仅专业版) Occlusion Culling (Pro only)
- Hidden Surface Removel Algorithms — Occlusion Culling
- unity3D的occlusion culling的简单使用
- 在DirectX9中进行Occlusion Culling
- 游戏程序开发OCCLUSION CULLING算法
- 传统传真机面临新一代革新
- C++类型转换符使用详解
- Use legacy animation system in Unity
- vim tab设置为4个空格
- Rect setCenter must after setSize
- 2D occlusion culling
- Struts2框架中action无法获取到jsp页面传递的表单数据的解决办法
- What is the function MultiplyUV() in shader?
- 次数分布表和直方图
- Rendering Paths
- Missing prefab warn when delete the prefab
- ubuntu切换root和redhat切换root
- POJ 3518 Prime Gap
- POJ 1195 Mobile phones (二维树状数组)