Objects fading with distance

I have no lights in my scene. All techniques specify “unlit” shaders. I just implemented zooming in and out of the scene and am finding my objects fade out as I get further aways from them.

In the documentation I only see reference to fading when using lights (which I don’t have).

How can I disable this behavior?

It’s probably getting fog from the Zone. If you haven’t set a Zone specifically, then it is using the default Zone which defines a black fog with Fog Start at 250 units and Fog End (maximum visible distance) at 1000 units. You can modify the fog values to push the fog boundary out further than your furthest objects to disable fog completely.

Thanks for the tip. Yes it was the default Zone. I have added the following code where I set up the scene. Does this seem like a reasonable way to disable this feature?

        var zoneNode = scene.CreateChild("Zone");
        Zone zone = zoneNode.CreateComponent<Zone>();
        zone.SetBoundingBox(new BoundingBox(-float.MaxValue, float.MaxValue));
        zone.AmbientColor = new Color(0f, 0f, 0f);
        zone.FogStart = float.MaxValue;
        zone.FogEnd = float.MaxValue;

you can define a normal region and move it when you are moving… a huge zone will take lot of processing…

That probably wouldn’t work in my case. This is a galaxy visualization and I show things as close as 0.5 light-years out to maybe 100,000,000 light-years. They pretty much all have to be visible at the same time.

I haven’t seen a performance problem yet, but I don’t yet have objects throughout the complete volume.

Yikes. That might play hell with your depth buffer.

How would that be manifest? What should I watch out for?

Z fighting. Depth buffer only has so much range. Having an extremely far far plane and an extremely near near plane is the worst-case scenario for it. If a lot of bits are eaten up handling near Z-depth precision, then far objects can end up Z-fighting a lot. See https://developer.nvidia.com/content/depth-precision-visualized for some graphs of what happens. You end up with a very fine resolution near-space, and a much coarser resolution of values further away, leading to distant objects that might be quite far apart, but which end up z-fighting with one another due to the precision loss.


Since you may want stars to switch from being spheres to billboards anyway, you might as well split the universe into two scenes and overlay them; one for near and one for faraway objects. You could also cheat with the distance of objects, since you’d mainly want to vary a star’s magnitude beyond a certain point.

Another thing that comes to mind is merging distant stars into a single piece of custom geometry that uses a point rendered vertex color material.