Sign in to follow this  
N1ghtDr34m3r

Handling an open world

Recommended Posts

Hi all,

In the last 2 years I learned a lot about 3D, OpenGL, GLSL, Rendering techniques like instanced rendering, framebuffers and post processing, but also things like ECS vs OOP, state managing, different Frameworks (GLFW, SDL, SFML, ...),
Physics (BulletPhysics) and stuff like that.
Previously I made little 2D games in Java and C++.

Now I'm feeling ready to dig deeper.
My current project is a 3D open world game. Graphics isn't relevant, that's why it will simply consist of low poly objects with low res textures and a pixelating post processing shader with a sci fi setting.
The first idea is a city, which feels a little bit like a living world.

Therefore my goals are cutted to
these points:
- animated neon lights and general lighting (banners, "advertises", street lamps, ambient lighting, etc.)
- walking pedestrians
- flying cars on multiple height levels
- moving around in first person

I think, I can definitely achieve this in a few years with my current knowledge. But there is one simple point I can't wrap my head around it:

<strong>TL:DR</strong>
- How are multiple (hundreds of) objects (buildings) handled? I know how I can render anything,but I didn't think, that I need to render anything at the same time. But how I can easily achieve it, to determine if something should be rendered and something not? How can I calculate if it is visible at the current position and view direction of the player?
And that, without hitting the performance a lot?

My ideas:
I know about texture streaming but is sonething like that possible for whole game objects? Like "game object streaming"?

I read stuff about so called SceneGraphs. But I don't really get it how it can help me? When each objects position is stored relatively to its parent position, in which way it would be simplier/faster to determine, if its in the viewport or not?

I hope it is understandable what I mean. :)

PS:
Please don't answer, if you just want to tell me something like "GTA V has over 1000 members in over 3 years full time". I appreciate it.

Share this post


Link to post
Share on other sites


How are multiple (hundreds of) objects (buildings) handled? I know how I can render anything,but I didn't think, that I need to render anything at the same time. But how I can easily achieve it, to determine if something should be rendered and something not? How can I calculate if it is visible at the current position and view direction of the player?
And that, without hitting the performance a lot?

 

You will typically use frustum culling for this purpose: http://www.lighthouse3d.com/tutorials/view-frustum-culling/

Also, you can use simplified buildings for distant ones (level of detail, LOD)..

Share this post


Link to post
Share on other sites
You can put your world into smaller grid sized bits to implement with the suggestion above to cut down on what you have to check if it is in or out as you will only have to test things in your grid + grid(s) that are infront of you

Share this post


Link to post
Share on other sites

there are actually two issues to be dealt with:

1. drawing it all.   frustum cull is the first step.   depending on scene type, additional methods of VSD and reducing rasterizing such as oct-trees, occlusion culling, LOD, terrain chunks, optimized render queue, etc  may help. well - optimized render queue always helps <g>.  and don't forget to make your assets speed friendly in size.

2. fitting it all into memory. streaming, asset reuse, small (low ram) assets, real-time procedural generation - all these can be employed.

 

start with a prototype with a frustum cull and a whole bunch of cubes, enough to get the number of triangles onscreen as you want in the game. see how fast that runs. if its not good enough, consider your scene type and determine what additional method(s) are called for. implement and test. repeat until fast enough.

 

once you can draw it fast enough, then all you need to do is figure out how to get the bits of data you need into ram when you need them - some how. streaming is a popular solution. i use small assets, heavy asset reuse, and real-time procedural terrain chunk generation (both on-demand and in the background).

Edited by Norman Barrows

Share this post


Link to post
Share on other sites

Thanks at all! That made it a bit clearer, especially the frustum culling. smile.png

 

I would appreciate it, if I could do this. But for me, there's one detail missing...

If I have a bunch of meshs, all bound to a cube and a player with a "camera", I only have a bunch of points (the cubes) and a 4x4 matrix (the camera). How am I now able to compute the frustum culling on the CPU side?

The link you gave me is awesome! Thanks! smile.png

 

But what about the logical update aspect instead of just the rendering?

If I render only the objects within the previously calculated frustum, maybe I could update each objects logic?

Or is something like "update only objects within a specific radius outside of the frustum" a good approach?

Edited by N1ghtDr34m3r

Share this post


Link to post
Share on other sites

As Tessellator mentions you really should look into spatial subdivision in combination with frustum culling.  Things like BSP, quad, oct, kd - trees and bounding volume hierarchies (though not spatial subdivision also PVS) could be used to accelerate frustum culling.  ( https://en.wikipedia.org/wiki/Space_partitioning )  He also mentions occlusion culling this is important as well, look into software occlusion culling and predicate rendering (IIRC).  

 


But what about the logical update aspect instead of just the rendering?
If I render only the objects within the previously calculated frustum, maybe I could update each objects logic?
Or is something like "update only objects within a specific radius outside of the frustum" a good approach?

Yes LOD in regards to AI and current game relevance is also a good idea, radius is good and a second dimension is relevance to an active "plot".

Share this post


Link to post
Share on other sites


But what about the logical update aspect instead of just the rendering?

i only update everything at games speeds up to 128x accelerated time. above that speed, i simply model the effects of running the AI, but don't actually run it. and anything far enough from the player gets removed from the simulation entirely, so it never gets updated.

Share this post


Link to post
Share on other sites

I would recommend using a premade engine for something like an open world game.

 

Something like unreal engine 4 would do the job well as it already has industry proven LOD, frustrum culling, level streaming and open world systems built in (see their kite demo).

 

You could spend years writing all this yourself, and if you just want to get on writing the game and know the functionality needed works fine, going the premade route is a good idea.

 

If you do want to do it all yourself, good luck because creating it and making sure it scales well could take you a long time...

 

Good luck! 

Share this post


Link to post
Share on other sites


Something like unreal engine 4 would do the job well as it already has industry proven LOD

I have no real experience with unreal engine 4 so I was wondering exactly what you mean by this?  Does UE4 use some sort of dynamic LOD or is it still static but the method used to select LOD level is "robust"?

Share this post


Link to post
Share on other sites

 


Something like unreal engine 4 would do the job well as it already has industry proven LOD

I have no real experience with unreal engine 4 so I was wondering exactly what you mean by this?  Does UE4 use some sort of dynamic LOD or is it still static but the method used to select LOD level is "robust"?

 

 

Well, I am sure most proven engines would work. I point this out because selecting something premade simply means that a lot of edge cases that can go wrong have already been found and fixed, and all the development is done for you. When you're dealing with something as large and complex as an open world game, IMHO you need as much of a leg-up as you can get your hands on as producing the content and populating the game world will be challenge enough!

 

I speak from experience as I am currently making an open world game myself and I knew from the start that it would be content that I would need to concentrate on. Without content an open world game is just an empty wilderness for the player to get bored in :)

Share this post


Link to post
Share on other sites

Thanks for all this interesting stuff. Yeah, spacial partitioning was a thing I learned a time ago. Just forget about it, but ya, that will be definitely a thing I will implement.

Moewover I will definitely look up software occlusion culling and predicate rendering. Thanks for that. smile.png 

 

 

 

I would recommend using a premade engine for something like an open world game.

 

Something like unreal engine 4 would do the job well as it already has industry proven LOD, frustrum culling, level streaming and open world systems built in (see their kite demo).

 

You could spend years writing all this yourself, and if you just want to get on writing the game and know the functionality needed works fine, going the premade route is a good idea.

 

If you do want to do it all yourself, good luck because creating it and making sure it scales well could take you a long time...

 

Good luck! 

 

Mhmm... yeah, that's true. I can definitely use an premade engine. But what should I, as a programmer, learn, when I'm letting all the stuff done by the Unreal Engine which other programmer wrote. And where does these programmer have their knowledge from? rolleyes.gif Another engine maybe? Maybe from Unity3D? tongue.png

Share this post


Link to post
Share on other sites

The knowledge within the big engines is built up over many decades of big AAA game releases. Unreal engine has lineage going back before 1998, and others back even further. Unity is a relative newcomer on the scene compared to a lot of engines - not to bash it's achievements because it is a very powerful and newbie friendly engine, whereas others such as UE4 can appear a bit unfriendly to the newcomer.

 

Try a few engines out and see which you like best smile.png

 

Bear in mind that cryengine and ue4 have open world facilities out of the box whereas for a lot of the functionality in unity you need to spend some cold hard cash in their asset store for plugins and addons (e.g. foliage instancing, terrain editing within the editor, possibly asset streaming etc). YMMV...

Edited by braindigitalis

Share this post


Link to post
Share on other sites

Yeah, I know that.

Sorry, if my message wasn't as clear as I thought.

What I really wanted to say by that, was that I'm interested in learning the "background programming": how an engine would handle it, how far it can be handled, where pros/cons are, where performance critical sections are, how to achieve stable performance, etc.

I already played around with Unity and Unreal. And I just don't want to click a game together. smile.png (I know, you can code your own stuff, due to the fact, that I prefer C++ style over C#, I would stick to UE instead of Unity smile.png

For me, it feels like a WYSIWYG Website Editor, just for Games. But I want to code it. I want to code something, that I'm proud off and not something, where some other devs can be proud of their engine, that she could handle it. wink.png

 

 

Back to topic:

 

Is it useful to use a "scene format" (XML or something like that) instead of hardcode positions in the mehs vertices?

My thoughts were, that when the meshs vertex positions are hard coded (offsetted in Blender), it could be bad due to floating point errors.

Is it something to worry about? Or should I make something like a world editor, where I can move objects around and save it to a file like a "world description"?

Edited by N1ghtDr34m3r

Share this post


Link to post
Share on other sites

Bear in mind that cryengine and ue4 have open world facilities out of the box whereas for a lot of the functionality in unity you need to spend some cold hard cash in their asset store for plugins and addons (e.g. foliage instancing, terrain editing within the editor, possibly asset streaming etc). YMMV...

Wasn't Unity5 relaeased recently and the engine with all features made "free"?  Do you know if some of that stuff is included now or still through the asset store?

 

 

 


Thanks for all this interesting stuff. Yeah, spacial partitioning was a thing I learned a time ago. Just forget about it, but ya, that will be definitely a thing I will implement.
Moewover I will definitely look up software occlusion culling and predicate rendering. Thanks for that.  
 

You're welcome, I also forgot to post this presentation for the occlusion culling system in Assassin's  Creed Unity and the newest Trials.  Go to the last presentation (gpu driven renderiing pipelines) here: http://advances.realtimerendering.com/s2015/index.html

 

edit - oh and I know of predicate rendering from DX, I don't know if opengl has an equivalent.

Edited by Infinisearch

Share this post


Link to post
Share on other sites

To OP here is something on software occlusion culling

https://software.intel.com/en-us/blogs/2013/09/06/software-occlusion-culling-update-2

 

edit - here is the original article

https://software.intel.com/en-us/articles/software-occlusion-culling

https://software.intel.com/en-us/blogs/2013/03/22/software-occlusion-culling-update

 


Is it useful to use a "scene format" (XML or something like that) instead of hardcode positions in the mehs vertices?
My thoughts were, that when the meshs vertex positions are hard coded (offsetted in Blender), it could be bad due to floating point errors.
Is it something to worry about? Or should I make something like a world editor, where I can move objects around and save it to a file like a "world description"?

When you say hardcode the positions of the vertices do you mean that your map is not "instances" of a mesh?  I don't know what "offsetted" in relation to blender means.

Off hand the only thing I can think of with floating point errors are T-junctions in regards to rendering and in regards to multiplayer networking code.

Edited by Infinisearch

Share this post


Link to post
Share on other sites
Hi,

Sorry for late answering, university eats all of my sparetime. :D

Here's an example of what I mean:

I want to have a Quadtree for the map, so I can easy traverse it and calculate collisions and other things.
That would be no problem, if I would have an idea for how I can positioning an object like a building on the map/on that grid -> quadtree.

Share this post


Link to post
Share on other sites

you may want to consider data structures tailored to each task, such as 2d collision maps for movement physics, and some other structure such as an indexed renedrables list for a terrain chunk.

 

they idea is you store the same data two different ways for two different types of lookups, so both lookups run fast.

Share this post


Link to post
Share on other sites


Here's an example of what I mean:

Are you talking to me?  If so I still don't know exactly what you mean by this:


Is it useful to use a "scene format" (XML or something like that) instead of hardcode positions in the mehs vertices?
My thoughts were, that when the meshs vertex positions are hard coded (offsetted in Blender), it could be bad due to floating point errors.

 

BTW besides reducing the number of triangles you try to render, you should also look into techniques to reduce draw calls like instancing, merge instancing and in the paper I linked above on gpu driven pipelines.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this