Sun and render distance


I'm experimenting with Unity to figure out how to do "Stuff" and I've come across something I could use some help with.

Let's say I was creating a space-sim or similar and I want the player to be able to fly around a vast area of space without artificial borders. That itself isn't too much of an issue, I can use an HDRi for the stars and just allow the player to fly around.

The issue I have or rather the issue i foresee is that unity doesn't seem to like using just IBL as it's only light source, my experiments with them have seen mixed results so far, but the camera culling doesn't allow for large planets or suns to be in the scene because for them to be sufficiently far away that they give the illusion of being planetary objects, the camera won't render them because they are too far away.

Has anyone got any suggestions for a workaround?

Trickery. Magic. And lots of smoke and mirrors. There are always artificial borders, you just can't always see them because devs go to great lengths to hide them.

I'll assume you already know about the spacial limits within games, especially when the use floats the way Unity does for positions. If not, look into that.

As for a 'local' scene where you have a nearby planet or something. You can increase the camera draw distance quite a bit. I've pushed it as far as 50k on the far plane and not had any serious issues. I believe the recommended range for near and far is a scale of no more than 100k between the two. It might take some playing around to find what is idea though.

The above would be more than enough for something like a 1:1 scale of the Earth and when you consider that you likely can't see beyond the horizon you technically could do a planet twice that size since you'd never see the back half being clipped. But perhaps you want to go bigger? A planet and it's moons? Or maybe something more like Jupiter, or Sol, or UY Scuti? In that case you'll need to get clever. Likely I would go with a 3D skybox camera that is rendered behind you main view but with objects at much smaller scales. You'd need to work out the math to account for positioning between your scaled skybox camera and the real one though.

These are two separate issues. You are describing a lighting issue and an issue of far plane distance.

If IBL is not sufficient, you can always add a directional light as well.

One thing to realize is that for objects far away the locational changes of the camera are negligible. So you can basically render either an environment sphere or some distant objects as if they were always centered around the camera. This alleviates the far plane distance problem a little bit.

Thanks for the tips. I'll have a play

1 Like