• Create Account

## mesh versus entity in frustum

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.

10 replies to this topic

### #1cozzie  Members

Posted 07 January 2013 - 03:34 PM

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.

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

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

### #2mast4as  Members

Posted 07 January 2013 - 03:55 PM

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...

Edited by mast4as, 07 January 2013 - 03:57 PM.

### #3cozzie  Members

Posted 07 January 2013 - 05:41 PM

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

### #4mast4as  Members

Posted 07 January 2013 - 06:40 PM

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).

Edited by mast4as, 07 January 2013 - 06:40 PM.

### #5cozzie  Members

Posted 08 January 2013 - 11:56 AM

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

### #6mast4as  Members

Posted 08 January 2013 - 03:53 PM

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.

### #7cozzie  Members

Posted 08 January 2013 - 03:57 PM

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

### #8MaxDZ8  Members

Posted 09 January 2013 - 01:50 AM

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?

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).

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).

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"

### #9cozzie  Members

Posted 09 January 2013 - 01:52 AM

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

### #10MaxDZ8  Members

Posted 11 January 2013 - 01:54 AM

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,

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"

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"

### #11cozzie  Members

Posted 11 January 2013 - 04:24 PM

Hi Krohm,

Fair enough, although I dont have an I7 ("just an I5 2320").

You do trigger me to upload a demo;

www.sierracosworth.nl/gamedev/2013-01-11-demo.zip

Would you like to try it out and see how it goes?

(controls are W/S/A/D, PG UP/DWN, ESC to quit)

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

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

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.