Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Sun and render distance

Discussion in 'General Graphics' started by matt_unity236, Aug 24, 2023.

  1. matt_unity236

    matt_unity236

    Joined:
    Nov 24, 2017
    Posts:
    2
    Hello!

    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?
     
    Last edited: Aug 24, 2023
  2. Sluggy

    Sluggy

    Joined:
    Nov 27, 2012
    Posts:
    853
    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.
     
  3. c0d3_m0nk3y

    c0d3_m0nk3y

    Joined:
    Oct 21, 2021
    Posts:
    568
    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.
     
  4. matt_unity236

    matt_unity236

    Joined:
    Nov 24, 2017
    Posts:
    2
    Thanks for the tips. I'll have a play
     
    c0d3_m0nk3y likes this.