Jump to content

  • Log In with Google      Sign In   
  • Create Account


How to cull objects behind terrain like CryEngine2


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 jdyyx1984   Members   -  Reputation: 125

Like
0Likes
Like

Posted 26 March 2011 - 06:52 PM

I found CryEngine2 could cull every thing behind terrain blocks, including terrain itself, i thought it might use the hardware query to do this ,but i found nothing in NvperfHud,the only thing i found was some one metioned in a forum: 'So you cant use terrain slopes and hills as a trick to optimize your level like Crysis does' in http://leadwerks.com/werkspace/topic/31 ... n-culling/
does any one know some hints or relative links about the solution?
thanks :)


Sponsor:

#2 Sirisian   Crossbones+   -  Reputation: 1685

Like
1Likes
Like

Posted 26 March 2011 - 09:15 PM

I was actually just recently discussing this problem with a friend. He had very hilly terrain and wanted to optimize the rendering by culling the objects occluded by the hills. I wrote up a very simple test. Given a heightmap that's NxN, in the example's case 64 by 64, and a player's position you can perform an optimized 2DDDA grid traversal from the player to a point of interest see if it's occluded. In the example the player is the mouse position 2 meters above the terrain. The points of interest that are tested are points randomly positioned above the terrain.

You might be wondering how this helps for culling large amounts of entities. If you store your entities in an octree and perform frustum culling already you know that you have to expand nodes that intersect the frustum. So you can exploit this occlusion by doing a test for nodes of a certain depth (basically for nodes that represent a cube size that's small enough to be hidden behind a mountain). If you have to expand a node in the octree you first test the top 4 points of the cube by traversing the heightmap from the player and seeing if it can see the point. It's not perfect and really weird terrain can break the algorithm, but ideally it works and allows you to not expand nodes and thus not include entities in those nodes. I haven't test it myself, but it seems cheap enough to perform.

#3 jdyyx1984   Members   -  Reputation: 125

Like
0Likes
Like

Posted 27 March 2011 - 12:26 AM

Will it be a little expensive? for example ,the terrain is 1024*1024 ,a lot of test are needed for every object in the scene,and if the object is very large(a big castle far away from the camera ),it is very possible to get a wrong result if only top 4 points of the castle's node are tested against terrain grid, we can avoid this by splitting the node into small segments(smaller than terrain's grid),but the number of test grows greatly in this case.
any suggestion?

#4 solenoidz   Members   -  Reputation: 519

Like
1Likes
Like

Posted 27 March 2011 - 01:35 AM

According to my tests.
If implemented right, occlusion culling doesn't stall the rendering and actually helps.
Culling objects behind terrain simple. You don't even need to sort anything. Just draw the terrain first.
Occlusion culling conflicts with other "speeding up" techniques like instancing, so doing it on individual objects isn't the perfect way.
You should, for example occlusion cull octree nodes against one another and the terrain in that nodes you should have instanced objects that you draw in one draw call. It depends of the scene, since there maybe nodes that contain lost of different meshes, so instancing won't help much, and maybe you will be better off in this situation have per-object culling, not per node, especially if the nodes are big and objects are complex. I think there's alway a compromise, and there isn't an ideal solution for every situation.

#5 Krypt0n   Crossbones+   -  Reputation: 2358

Like
1Likes
Like

Posted 28 March 2011 - 05:41 AM

the simplest way to do it would be to save for octree nodes what other ocetree nodes are visible from this node. you wouldn't save it for billion of nodes, but bit-tests for the octree-traversal. this can be computed offline in any way you'd like to. it's similar to the PVS the quake engines use, but on octree level, not on convex-bsp-cell level, if you sort objects into the octree, you'll get their visibility like free candy.

Tho, in cryengine it's done by a software occlusion culler, this way all kind of test: entity vs brush vs tree vs terrain work uniformly and it's editable in realtime, it's also quite fast, just some more work and experience is needed to get it running fast.



#6 UltimaX   Members   -  Reputation: 467

Like
1Likes
Like

Posted 28 March 2011 - 06:03 AM

There is also Horizon Occlusion Culling

#7 jdyyx1984   Members   -  Reputation: 125

Like
0Likes
Like

Posted 28 March 2011 - 09:21 AM

thanks for your answers !Posted Image
i asked the same question in ogre forum,they told me CryEngine utilize Coherent Hierarchical Culling(CHC) to cull the scene.this algorithm make use of hardware occlusion query, but when i put crysis in NvperHud i found only one IDirect3DQuery9 was called after i scanned all DX API calls in one frame, it was the called before rendering the ocean. so i was puzzled..





#8 Krypt0n   Crossbones+   -  Reputation: 2358

Like
1Likes
Like

Posted 28 March 2011 - 10:06 AM

i asked the same question in ogre forum,they told me CryEngine utilize Coherent Hierarchical Culling(CHC) to cull the scene.

:), people come up with funky ideas :)

this algorithm make use of hardware occlusion query, but when i put crysis in NvperHud i found only one IDirect3DQuery9 was called after i scanned all DX API calls in one frame, it was the called before rendering the ocean. so i was puzzled..




this one is really just for the water and especially for rendering the reflection map. (if you don't see the water, no need to render the reflection), and in contrast to most objects in a level, that have simple boundaries, ocean water has waves and is kinda infinite in size, so using the occlusion hardware occlusion results for this one makes really sense. you can check that out in the editor, move close to some wall where the ocean is behind, and when you move through the wall (in editor mode), you see the ocean appears some frames later.


you can also experiment with the occlusion culling, just enable the drawcall and polycounter and watch how it rises and drops when you move behind objects, terrain is obviously culled by that, but you won't see any latency issues like you'd see with hardware occlusion queries.


#9 jdyyx1984   Members   -  Reputation: 125

Like
0Likes
Like

Posted 28 March 2011 - 10:25 AM

so they use some kind of software occlusion culler , i 'm so curious~~~Posted Image

#10 Krypt0n   Crossbones+   -  Reputation: 2358

Like
1Likes
Like

Posted 28 March 2011 - 10:53 AM

so they use some kind of software occlusion culler , i 'm so curious~~~Posted Image


yes, software occlusion culling <3


what are you curious about? I might know it from somewhere ;)



#11 wmonash   Members   -  Reputation: 124

Like
1Likes
Like

Posted 29 March 2011 - 03:56 AM

i'm using horizon occlusion culling with hierarchical Z occlusion map, the result is very satisfied.
horizon occlusion culling is very fast but in some situation it can not work( like stand on top of the hill), so mixed with hierarchical Z occlusion map.








Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS