Search Unity

Planetary Terrain: Quadtree Planets for Unity

Discussion in 'Assets and Asset Store' started by simitro, Nov 10, 2017.

  1. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,124
    The case is there are two cameras. Using GPUInstancer asset, for example, you need to attach an script to every camera on scene to work properly and only one camera can be active at a time.
    Another problem I see is with floating origin system. If I understand well, using it, the objects are repositioned around the user camera when they are too far from origin. I don't think it is the better way to create a realistic game world if the scenery objects change their position all the time.
     
    Last edited: Jun 24, 2019
  2. simitro

    simitro

    Joined:
    Feb 13, 2015
    Posts:
    113
    Sorry, but both of those things are an absolute requirement if the game world is larger than say 50,000 units in radius, and you want to be able to see reasonably far. If you're planning for a world smaller than that, you can use PT with just on camera and without floating origin just fine.

    The camera part should not be too much of an issue. You can perhaps set the near camera far plane to 10,000 or 20,000 units, and then have it as the active camera in GPU Instancer. Like this you would obviously only be able to see the instanced items from a distance of 10,000 or 20,000 units, but that shouldn't be an issue if the objects aren't too large.

    I don't think floating origin would be much of an issue as well, depending on how low-level of an API GPU Instancer provides. You could set it up in such a way that coordinates are relative to quad positions, and then push quadPosition + relative as render coordinates to GPU Instancer. This is what the built-in foliage system does.
     
  3. Hellgeist

    Hellgeist

    Joined:
    Feb 13, 2017
    Posts:
    7
    Planetary Terrain doesn't have to use far/near all the time. You can use one camera with a very far max distance. What I meant by 'using one camera at time' is that you have a main camera on your controller, and then you swap to a camera attached to the ship, or a freelook cam, or any other cam you'd use to change the player's perspective. Having multiple cameras (one active at a time) does not affect the planetary terrain scene negatively.

    With scaled space, that is another story. I kind of went a different direction and just handle objects how I'd imagine a ship's sensors would work. I scan for any body within a certain range as one of several object types, and then apply appropriate actions to them, like instantiating a model for bodies or atmospheres, adjusting exposure or density, etc.

    I only apply a scaling effect when traveling distances that are farther than that general range (outside of far orbital). And really, if this is for a space travel game, to traverse that kind of distance, you're going to be using a different method of propulsion that is much more powerful, making your visible scaling effect so brief, you could just simplify the process.
     
  4. angel_m

    angel_m

    Joined:
    Nov 4, 2005
    Posts:
    1,124
    This is the project I'm working on:

    I´m assessing if I will use PT. Now, the planet is a sculpted high poly sphere. I don't want to use a too big sphere-world because I get collision errors and other issues, and the floating origin system is not a good solution for me. As I said, I don't think it is the better way to create a realistic and credible game world if the scenery objects change their position all the time when they are too far from origin.
     
  5. simitro

    simitro

    Joined:
    Feb 13, 2015
    Posts:
    113
    The game world doesn't look incredibly big, there might still be some rigidbody twitching and such far from the origin. Your judgement in the end if that's an issue or not. For a very large-scale game (solar system) with floating origin, check out Kerbal Space Program.
     
  6. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    278
    Have any of you guys tried landing on a realistically sized rotating planet?

    I notice that my planets surface is moving at hundreds of meters per second at the equator, and even if I match velocity with it, the unity physics is having a very difficult time of it. My ship generally starts sliding across the terrain after landing. I've tried creating a fixed joint to the planet to hold it in place but this doesn't work as expected. I don't know what it does exactly, but definitely not what I expected.

    Any suggestions?

    edit: I originally thought this was an issue with unitys physics not handling the fact that the colliding objects were moving very quickly, however i did a test with a flat plane and a spaceship landing on it, moving linearly (not rotating) and there was no problems at much higher speeds. Is it something to do with the angular velocity, or the generated colliders?
     
    Last edited: Jul 7, 2019
  7. simitro

    simitro

    Joined:
    Feb 13, 2015
    Posts:
    113
    Haven't looked into this much myself yet. The problem might be caused by the quads not having (kinematic) rigidbodies themselves (that would be very expensive though).
    You could try writing a script that matches the rigidbodies velocity to the surface velocity. Just apply some force based on height and difference in velocity. That's how it works in real life, in the atmosphere, after all.

    There's also a simple rotate around planet script included, you can set it to the same rotation speed as the planet and try if that works.
     
  8. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    278
    I am able to pilot my ship to a very soft landing, so the velocities are already matched to within 0.1m/s at the point of touchdown. I don't know why the result is a mess.
     
  9. simitro

    simitro

    Joined:
    Feb 13, 2015
    Posts:
    113
    Are you using continuous collision detection on your rigidbody?
     
  10. Innovine

    Innovine

    Joined:
    Aug 6, 2017
    Posts:
    278
    A suggestion for your next version, please remove the dependency on using the main camera. We should be allowed control over that. Your script fails hard if no camera is tagged as mainCamera.
     
  11. simitro

    simitro

    Joined:
    Feb 13, 2015
    Posts:
    113
    Sure, that's easy to change.
     
    Innovine likes this.
  12. iamarugin

    iamarugin

    Joined:
    Dec 17, 2014
    Posts:
    170
    Why are there only 8 different triangle configurations in BaseQuadMeshes (9 with no endge fans)? As I understand it should be 16. Or you are rotating quads with mirrored configurations?
     
  13. simitro

    simitro

    Joined:
    Feb 13, 2015
    Posts:
    113
    No rotating is done, there just aren't cases where quads need more than two fans, or two fans on opposing sides. This is since always two of the neighbors were part of the same parent quad, and therefore can't have a lower subdivision level.
     
  14. Susihiisi

    Susihiisi

    Joined:
    Jan 11, 2018
    Posts:
    10
    Can you give any suggestions on water shaders that works with the ocean? I have tried some, but I haven't found anything good. Or maybe I just didn't know how to configure them properly.
     
  15. simitro

    simitro

    Joined:
    Feb 13, 2015
    Posts:
    113
    Sorry, haven't found anything outstanding myself yet. Only thing I can think of is Unity-Proland water, as that's also where the atmosphere shader is from. Most water shaders are designed for flat terrain unfortunately, your configuration is likely not the problem.
     
  16. LukeDawn

    LukeDawn

    Joined:
    Nov 10, 2016
    Posts:
    335
    Try looking at up-coming Poseidon by EarthShaping.
     
  17. rasto61

    rasto61

    Joined:
    Nov 1, 2015
    Posts:
    298
    Is there a reason why a planet would not generate sometimes? No errors thrown. (If I move the desert planet into another scene it does not generate) Can't find anything in the docs...

    Also instead of hiding the quads in the hierarchy wouldn't it be better/simpler to just allow to specify a parent for them?
     
  18. simitro

    simitro

    Joined:
    Feb 13, 2015
    Posts:
    113
    Only reason I can think of for the planet not generating is the camera being in the wrong place. Try placing it at a distance of a bit more than the radius.

    Hierarchical quads would be nice, but they need to be independently moveable of one another, otherwise I can't do the positioning with doubles.