Page 1 of 1

Managing visible objects / sync create and delete of objects

Posted: Sun Oct 04, 2015 5:44 am
by sushbone
While trying to create a simple procedural space scene in Unity3D (see e.g. https://forums.inovaestudios.com/t/proc ... -to/765/97 ) I always reach a point at terms of how to create and delete objects where I wonder what is the right route to go. I guess (or I am sure) Josh must have had a similar issue where he obviously took the right decision when looking at how Limit Theory looks at it current state.

When you create a procedural universe, you likely use noise functions like simplex noise to decide where to create asteroids, planets, suns, etc. All kind of objects.
You do these checks around the current player position, until a certain distance where things should stream in when the player moves.
As you need to check a lot with those resource-expensive noise functions, you want to check positions only once, and likely in a separate background thread. And, you want create these objects only once of course, you dont want to create a sun a second time at a position where you already create one beforehand due to some noise result.

Summarising: You need a good strategy how to check the area around the player, keep track of the objects already created, find a good strategy when to delete objects and create new ones only if missing in the current scene. I find this really complicated when using background threads that check positions with noise functions, when at the same time you somewhen need to delete (in a different main trhread, of Unity3D in my case) objects if they get out of range. Exceptions within lists where you keep track of the objects are not unlikely, also not to bounce between creation and deletion of objects.

I hope Josh will somewhen give an inside view of how he manages the creation and deletion of objects in the background. If there is a core thread of function responsible for this, or if every object manages itself, etc.

Re: Managing visible objects / sync create and delete of obj

Posted: Sun Oct 04, 2015 12:14 pm
by Silverware
I'll admit I have only skim read this, but here is how I would go about doing a solar system, (admittedly more to-scale than Josh's stuff)

Every planet and star are always visible.
Each planet has multiple levels of detail, which are multiple images that get blended together on an s-curve. So that things nearby have more detail, and further away that detail drops until it's just a bright point of an approximate color of the planet blended with that of the star.

When you are close enough you start drawing moons around planets, starting from a single point like planets, but with an opacity of 0 to begin with, which fades in as you get closer.

Asteroids require a little more work, as I would want tens or hundreds of thousands of the buggers, in the same orbit each time.
We don't need to store the majority of asteroids, just the ones with resources. Which can be repopulated as often as required (or never)
The main asteroids all get generated from the same base algo that gets given the belt's density and distance from star. And this algo gets run for all the boring asteroids each time you enter the system.

As with moons when you get near you should start being able to pick them out in the distance.

Dust particles don't matter about storage or keeping them identical between games, so instead we just pop them in when needed.
Typically they will be when we start to spawn in the moon, or asteroids.
As asteroid belts ( or planetary rings ) would have a ton of dust.
At a distance, we just draw the region's surface, and add any reflective qualities.
As we get closer we want that region to break up with noise, and then slowly be replaced by a volumetric display of the dust.



Now, that's far from an implementation, and I would love to hear other ideas on the subject too, it's a cool topic.