good generalized frustum cull algo

Started by
10 comments, last by Norman Barrows 10 years ago

guess i need to turn off all those unnecessary calls to superclip5() ! .

well, i was about to turn off the line of code for superclip5 in draw_chunk, and it occurred to me that auto-clip would no longer work if i did that. auto-clip times a frame, and adjusts clip ranges accordingly on the fly. you can also turn it off and set clip ranges for things (trees, ground, water, people, etc) individually, or set all clip ranges to a single value. ever since i switched to generating terrain chunks on the fly, i've simply been running at all clip ranges = 500 feet. so i guess i'll turn it off, and perhaps disable autoclip in the long run. chunks are pretty fast.

multi-mesh models (people, animals, complex objects) are already culled just at the model level, not when a model's meshes are added to the render queue.

and things like a character's equipment are not drawn if the character isn't drawn, so in that respect i have some scene subdivision, thanks to implicit procedural call hierarchy control flow. you might think of each draw function as a node in an N-tree, only calling its children if it gets called.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

Advertisement


The benefit of a hierarchical tree is that if a parent node is outside of the frustum, then all of it's child nodes are also absolutely 100% guaranteed to also be outside of the frustum.


terrain is divided up into chunks 300x300 in size. chunks are generated on the fly as needed from underlying world map data structures. a chunks is essentially an indexed render queue of all the meshes and textures in the chunk. when i render the scene, not only do i cull entire chunks, but each mesh in a chunk as well (IE each plant, rock, tree, and bush).


as you say, the chunk cull alone should be sufficient. and it sounds as though i should not frustum cull rain particles. i suppose by the same token, i should do a single cull for multi-mesh models, instead of culling each mesh in the model.

well, i turned off:

 
if (Zsuperclip2((int)x,(int)CL[d].d.list[e].y,(int)z,CL[d].d.list[e].rad,CL[d].d.list[e].cliprng)) continue;        
 

frame rate dropped to 8-9 fps in a tall grass scene. a tall grass scene draws 40,000 alpha tested grass meshes of 8 quads each (640,000 triangles) in visible range. this is how i get my "million blades of grass" effect.

the HUD said the total number of visible meshes drawn was about 30,300. this was with cull turned off, just culling entire 300x300 terrain chunks. i didn't think to check the HUD to see how many chunks were being drawn. could have been anywhere from 3 to perhaps 7. grass plants are drawn every 5 units. so a chunk has 3600 grass meshes in it.

so, i turned the cull back on.

the number of culls may seem high due to the fact that Caveman attempts to draw very dense complex scenes. Where 20 tree models might do in a shooter to suggest a forest, Caveman will draw 1300 trees in an 800x800 area (one every 22 feet), as well as plants similar to the tall grass, and fill an entire 5x5 mile map square with trees. forests in Caveman can go on for hundreds of miles (many map squares). if you figure the visible area is about 1/4 of the total stuff in visible range, then a typical complex scene in caveman will have about 60,000 meshes in visible range. i should probably get into instancing. it would allow me to further increase scene density - add small trees to the big ones, and add small plants to the larger plants. however, increased scene density, while more realistic, really does nothing for gameplay, other than make it look better. but i suppose that's all any graphics does, beyond the most basic placeholder stuff required to show whats going on.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement