Culling offscreen meshes

Blitz3D Forums/Blitz3D Programming/Culling offscreen meshes

JoshK(Posted 2004) [#1]
Holy crap!

I was looking at my render statistics, and noticed something funny. Here I am looking straight up at the sky, with no meshes directly in view. According to the stats, there are 61 meshes directly around me, but few polygons are being rendered:

61 staticmeshes
240 polygons
16 msecs

Look at the staticmesh render time! 16 msecs to render a couple hundred polys!!! That is slow as hell.



Now I lower the camera. Look at the stats. 8000 polys are drawn in a couple msecs more than it took to not render them in the previous shot.


61 staticmeshes
7905 polygons
18 msecs

What is happening? I am assuming the slowdown from the first shot was from checking every triangle in the surface to see if it was in the camera view frustum. This process must be so slow, that it is almost as slow as just rendering the mesh! I can do a box render test that's a million times faster than this. There needs to be a brushfx flag that forces a render if a mesh is shown. The per-triangle surface check is totally self-defeating. As the above shots show, it takes about as long to NOT render something in Blitz as it does to just draw it! Probably another reason multiple surfaces are so slow.


Wayne(Posted 2004) [#2]
I've noticed that as well.
This something I'd love to see Mark comment on, and better yet do something about it.

Thanks for pointing this out Halo.


JoshK(Posted 2004) [#3]
By using an EntityInView culling method, the same number of polys are rendered in a significantly less amount of time.


29 staticmeshes
7927 polygons
13 msecs

With this method, when I look up at the sky, staticmesh rendering takes 0 msecs, as it should. Unfortunately, I can't eliminate this surface check for polys that I want to render. With meshes that are all in view, the first triangle will be in the view, so it will only slow down meshes that are partially out of view.

The way I would really do offscreen culling is by rendering a box for each staticmesh. If the render results in a TrisRendered() value, I would force the mesh to render, otherwise hide it.