depth Partitionning

Hi all,

is there any way (Unity Core or plugin tool) to achieve realtime depth partitionning in Unity scenes ?

I need to render very large scenes containing big objects (planets) ans very small objects (satellites e.g) without any z buffer and near/far clipping problems.

I used OpenSceneGraph in the past, with can provide such feature, by sorting nodes from camera distance, and then create local cameras… But I don’t know if the is an elegant way to achieve this in Unity.

Thanks a lots for all your future suggestions :slight_smile:

Eric

It sounds doable

Get Two Cameras
Place them in the identical location, move them together.
Give one a depth of 0, and one a depth of 1;

The one at depth 0 should have a long distance near and far clipping plane. It should be set to not clear
It should be set to render things in FarLayer layer
and not NearLayer.

The one at depth 1 should have a close near and far clipping plane. It should be set to render things in NearLayer and not FarLayer. This one is set to clear all.

Now go to the Layers Preferences and add a NearLayer and FarLayer.

Now create a script that checks the distance to camera on each Update and changes it’s layer property if needed.

Make sure there is some overlap between the two so the transition is clean.

Your Far transparencies will not work with your near objects, however that would be my best guess as to how to approach the problem.

thanks Ntero !

I see what you mean but if I understand it is a “manual” way to achieve this with a near layer and a far layer.

But I’m wondering if there is a more generic way to do this, with layers adjusted in realtime depending on camera position, and working with several objects : let’s imagine, 5 satellites, the Earth, the Moon and Sun for example.

I looking for something generalist to deal with huge scenes.

Does anyone has to work on such a subject in the past ?

Well, the automatic way would be to do all that, and then have a script that reads the depth values, and automates the moving of the Near and Far planes, as well as automatting the swapping of objects between distance level cameras.

Think like OpenSceneGraph, where you sort your own objects based on depth, and need to create some system that swaps the object between cameras.

There is no built in method that will automatically refocus and reorganize it’s camera distances based on objects, but the underlying scripts themselves that you would need to automate that process are pretty simple.