Modeling Large Modular Structures

Started by
5 comments, last by Flyverse 8 years, 11 months ago

I'm writing a game with Ogre that is modeling the top portion of a large skyscraper. It is modeled with 20 fairly large floors each containing many rooms. They are all constructed randomly by piecing together a small collection of modular building pieces. I'm looking for general suggestions about how to do this in a clean and fairly efficient way. I do want the player to be able to modify the modular structure to a certain degree, but there won't be any need for much animation or active motion. It will largely be a static environment.

Right now, I keep a couple multidimensional vectors that hold enum values representing the different kinds of modular pieces, and then after I've filled up those vectors, I call a buildMap function that checks each map position to see if a mesh needs to be placed there based on the vector information. I then batch together all of the pieces into one large StaticGeometry object and display that. This works, but it is already dragging on performance even without any UI or gameplay added on top. So I need a better way.

Here's the project for reference. It can be built with Ogre 1.9. Most of what I'm referring to is in 'systems/MapSystem'. https://github.com/kabbotta/Last-Ditch

Advertisement


I then batch together all of the pieces into one large StaticGeometry object and display that. This works, but it is already dragging on performance

Rendering a single StaticGeometry is causing performance issues? How many triangles are in this combined StaticGeometry?

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

I don't know much on this matter, but, did you implement culling?

It looks like about 200,000,000 tris in the full scene. I have a map that is 256 * 256 with 40 layers of modular meshes that have roughly 70-100 tris each.

256 * 256 * 40 * 85 ~ 200,000,000

That does seem kind of high...

I've cut the map down to 128 * 128, and it seems to run pretty smoothly already. Maybe the 256 * 256 map is just a bit too much?

If youre rendering all those triangles, it is high.

But you shouldnt be.

Look into various culling methods. Dont render meshes outside the view frustum (split the giant static mesh into smaller ones to make selective rendering possible). Dont render floors/rooms you cant see (this is more game specific - maybe you cant see other floors than the current one and the ones below and above? Maybe you cant see rooms with all doors shut, maybe you cant see the 'core' rooms if looking at the building from outside).

Theres also more general methods that basically first render stuff in a cheap/approximate way, to discard some objects that are not visible, avoiding having to render them in full detail (expensive). Eg first render the scene depth-only, maybe with simplified geometry, so you can do cheap checks to see if an object is going to be fully occluded before rendering (this kind of occlusion culling can be done fully on hardware with conditional rendering AFAIK). This can be done on software too (at low res for performance), but Im not sure thats very relevant here.

Anyways, the first thing to do is not render the whole thing as a single mesh. Cut it in pieces, so you can more easily discard occluded ones. Try to take advantage of the specifics of your game to find simple ways to discard stuff.

EDIT:

Oh, and you can also try doing some level-of-detail optimization, to reduce the triangle counts. Though, if you are drawing dozens of rooms on top of each other, fillrate might be a bottleneck so Im not sure if this is going to help without actually eliminating much of the stuff.

o3o

Unfortunately, I think Ogre is already doing a lot of this stuff. There is definitely frustum culling and occlusion culling already being done, because the FPS skyrockets up when I turn around and stare into empty space instead of looking at the building. I can also see there is LOD being done. So I thought that would help, but it still wasn't doing the trick. I am using a pretty old computer with only 2gb of RAM, but I didn't think it would be that bad.

I've been looking into using Ogre Paging component to setup paging for the mesh, and there is a Paged Geometry addon for Ogre, but I haven't been able to get them working with Ogre 1.9 yet.

Oh, and you can also try doing some level-of-detail optimization, to reduce the triangle counts. Though, if you are drawing dozens of rooms on top of each other, fillrate might be a bottleneck so Im not sure if this is going to help without actually eliminating much of the stuff.

I don't quite understand what you mean by fillrate.

2GB of RAM does seem quite low, if you account for a part of it being used by the OS etcetera. If you need to test your application on a better computer you can contact me, mine is quite good (16GB RAM, good graphics card & processor, etc). Only if you want, of course.

Also, why don't you implement something like chunking? You said your map is 256 x 256, you could cut those down to many little pieces and only load those who are around the player. I know a few games who do this and it seems to work quite well.

Again, please note that I am a total beginner on these topics and thus my knowledge is very limited. Rather listen to the other guys posting here than me...

This topic is closed to new replies.

Advertisement