mesh versus entity in frustum

Started by
9 comments, last by cozzie 11 years, 4 months ago

Hi,

I was studying my render function after adding lots of nice stuff, and made myself aware that before I go on with a mesh, check if it's inside or intersecting my viewing frustum. And afterwards do the same with each entity. For now both using a boundingsphere (boundingboxes maybe in the future).

What are your experiences on doing this both? How assumable is it that mesh isn't (intersecting) the frustum but an entity is? Versus checking each entity with a CPU calculation to do this. The number of entities might grow huge in a scene.

Just curious on your thoughts.

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Advertisement

Are you talking about whether drawing your mesh if it's contained in the frustum (or straddling it). Generally checking if the object's bounding box is completely outside the frustum is already a good start and will certainly provide some level of optimisation. You might gain little from implementing a more complex intersection routine than that. However it all depends of the complexity of the geometry contained in the bbox. For instance if you render a terrain, a large part of the terrain might be outside the frustum but if it's part of a single mesh then you don't have a choice to discard the invisible bits. You need to be sure for large meshes that they are split into smaller bits (of reasonable size) organised eventually as a hierarchy, and then you can easily discard the individual pieces which are outside the frustum. If you choose this strategy, a lot of the objects will be culled and the drawing objects straddling on the frustrum's boundaries is probably okay...

Thanks, this helps a lot. Doing both checks sounds as a good solution then, assuming my meshes are organised into reasonable sized entities. It also gives me freedom to load a (part of a) scene in one exported "mesh"/ object

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

If you mesh is only one big chunk you can break it using some of sort of spatial subdivision scheme a little bit like what the REYES algorithm does (it's not exactly the same but you can get inspire by the concept).

Thanks, i'll have to find the best balance between doing this with the modelling versus in my engine

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Thanks, i'll have to find the best balance between doing this with the modelling versus in my engine

However when I was saying "breaking it up into chances" you can do this in the engine at render time. You can insert the polygons in the cells of your mesh (insert polygon only once) and then display the content of the cell in the cell boundaries (min and max) are contained in the frustum. This way, you don't need to go back to modeling and you can just use a simple grid as a start to do that. It might use a bit of memory and it will take some time to construct the grid (and find optimal settings for the size of the grid, etc.) but it might be simple and fun implementing the technique and see what you gain out of it.

OK, sounds complex, but that's probably because I didn't try it/ play around yet :)

Thanks, I like the idea, so you don't have to think about sizes of meshes while modelling

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

[quote name='cozzie' timestamp='1357594496' post='5018752']
I was studying my render function after adding lots of nice stuff, and made myself aware that before I go on with a mesh, check if it's inside or intersecting my viewing frustum. ... What are your experiences on doing this both?

[/quote]

  1. In my system, entities are non-visible by default and therefore not get culled. If they have graphical component, it will get culled.
    As a side note: because of some nontrivial implications with scripting I actually don't cull at all the performance, given my current datasets is acceptable on everything that's not a 1st gen Intel Atom system. Feel free to bash me.
  2. In my current dataset, all entities which have a graphical component are very spatially-coherent with their logical position. That is, the mesh position is roughly the same as the entity itself. So doing both tests would give the same result (supposing an entity actually has a positional component and a "shape" to test).

[quote name='mast4as' timestamp='1357605602' post='5018828']

If you mesh is only one big chunk you can break it using some of sort of spatial subdivision scheme a little bit like what the REYES algorithm does (it's not exactly the same but you can get inspire by the concept).[/quote]Uhm. I wouldn't suggest to do that. It might make sense on rock-bottom portable hardware but sure it doesn't on everything modern.

Previously "Krohm"

thanks, this triggers me to always keep asking the question:

"do I really need this for my purpose/ today's hardware or is it just because I think it might be necessary for not yet arised performance issues"

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Think about it. Layout some code or interfaces.

But for personal experience, I suggest to just use the following function as visibility test.


bool IsVisible(Object blah) {
    // It's a stub, implement this in some future version.
    return true;
}

Reasoning is very simple. If you need to cull, you can iterate your project. If it's already designed correctly, it will plug in right.

If you don't need to cull, you took a 100+ fps and turned it into 150+. You also spent a week you'll never get back.

FYI, my target hardware is Athlon XP 2800+ with Radeon 9500. This is "modern" enough to let beginners just throw stuff at the renderer. But to be more accurate,

[quote name='cozzie' timestamp='1357717974' post='5019390']
do I really need this for my purpose/ today's hardware or is it just because I think it might be necessary for not yet arised performance issues"
[/quote]I have no idea of what your purpose is. But I'm fairly sure your hardware is way more powerful than mine. Are you writing this from an i7?

Previously "Krohm"

This topic is closed to new replies.

Advertisement