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

Space Graphics Toolkit & Planets

Discussion in 'Assets and Asset Store' started by Darkcoder, Aug 18, 2012.

  1. EternalHaze

    EternalHaze

    Joined:
    Mar 25, 2017
    Posts:
    1
    Hi! I was wondering if there was a way for me to access and swap the textures in the terrain planet material during runtime. I was hoping I could swap textures between high res and low res depending on the distance of the player from the planet. When the player is very far I'd be using let's say 128x128 resolution textures and then swap to 2048x2048 textures when the player is nearer.
     
  2. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi. Adapted Sgt 4 to my project. I was capturing a skybox at the star location in a spiral starfield before by using Camera.
    RenderToCubemap(). Now, it does not capture the skybox. I followed the camera setup (scripts) on the example page. Is there a trick for this that I am missing?

    EDIT: I mean capturing the spiral star field as a skybox.

    EDIT: I wrote a more detailed script to do this and it is ok now. I had to do it anyway but I was postponing that work... :)
     
    Last edited: Mar 25, 2022
    Darkcoder likes this.
  3. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    Can I write a small code for the spawners that spawns an object at x seconds?
     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    You can select the shader file (not material), and see a list of all the property names in the inspector:

    upload_2022-3-26_10-31-27.png

    The name on the left is the actual shader property name, and on the right is what it shows up as in the material.


    Sure? With custom code you can do anything :D
     
  5. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    Ok one think when i change something in the floating sphere spawner script do i need to change the floating spawner script too?
     
  6. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    and another thing. When my game is paused, the camera doesn't move or look around. How can I do that?
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    It depends how you want your changes to work, but it shouldn't be necessary.


    The example components all use Time.deltaTime. You will have to modify them to use Time.unscaledDeltaTime instead.
     
  8. Respaekt

    Respaekt

    Joined:
    Dec 11, 2018
    Posts:
    15
    Hi,

    Using Unity 2020.3.26f LTS with URP 10.8.1 / Burst 1.4.11 and SpaceGraphicsToolkit 4.0.4 and Space Graphics Planets 4.0.3:

    From recent forum post i guess there are still problems with the terrain colliders?!
    In my case the collider is being created not directly below the camera (this is the terrain examples 05 scene).
    if i lower the resolution of the terrain collider, the collider goes below the camera. With higher resolution it disappears completly.
    Also with an Collider attached to the camera object, there is no collison with the terrain collider for me...

    upload_2022-3-28_10-53-1.png
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Hey everyone,

    Version 4.0.5 of Space Graphics Toolkit is now out!
    • Added warning to SgtTerrainAreas inspector if the texture is non-readable.
    • Fixed SgtTerrainCollider vertex alignment and distribution to match visual mesh.
    • Fixed SgtTerrainPrefabSpawner component's Area being misaligned.
    Enjoy :)


    See above :D
     
    dmenefee and Respaekt like this.
  10. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    I wrote everything that was in time.deltatime as time.unscaleddeltatime but it still doesn't work. It is apparently due to the FixedUpdate. Is that correct? If so how do I fix it?
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    If you set Target to None/null then it will use Update. If you have a Target then it will use FixedUpdate. You can't pause the game with Time.timeScale and still have physics (and thus FixedUpdate) work.
     
  12. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    With target you mean like sgt floating target? If yes, what do i need to do?
     
  13. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    No, I'm talking about the Target setting of the SgtCameraMove component.
     
  14. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    hey @Darkcoder really good improvments since 3.8/3.9

    did you plan for multiplayer: integrate base functionalities for floating origin stuffs or a base compatibility with existing common assets ?

    btw what would be the cost to transform the floating origin system to a continuous floating origin system, what is the real benefits to do so ?
    i'm talking about this. zero-centred relative methods like Progressive Relative Spaces, Continuous Floating Origin, with distance and proximity tests sounds great, but i'm scared to jump in by myself. Plus the author warn that this early WIP should not be downloaded for now and it need for advanced unity script skills.
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    I don't plan to create any multiplayer integrations, or integrations with any other assets.

    The only benefit to continuous origin shifting that I can think of is that it would simplify certain calculations since you could ignore the camera position. However, moving colliders and particles to go around the camera has some overhead, so it would probably not be a good idea to do it every frame.
     
    Last edited: Sep 24, 2022
  16. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi there... This is version 3 of my project by Sgt... All distances you will see are real distances...
     
    dirkjacobasch likes this.
  17. Chaz32621

    Chaz32621

    Joined:
    Apr 17, 2015
    Posts:
    199
    Does this not work for HDRP? I just imported and it looks terrible do I need to do any other settings? Do I require to have that sharder packaged recommended for it to work properly?
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Looking better each time! If the ground colors or tree textures were tweaked to more closely match each other then it would look even better. Do you know what causes the shadows to flicker like this?

    It should work automatically. Here's what SGT + Burst looks like in a new 2021.2.7f1 project with the Earth Sized Planet demo scene:

    Screenshot_2.png
     
  19. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    The gas giant causes that flicker. Also, the directional light is too far away which may be contributing the situation. But, turning gas giant game object off makes the flicker go away. This v3 of the project is Sgt 3 by the way. I haven't tried to put a jovian in project v2 which I recently upgraded to Sgt 4.
     
    Last edited: Apr 5, 2022
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    I see, in V3 the Jovian and most other objects are rendered using Graphics.DrawMesh with default settings, which may cause shadows to be drawn. The shader is transparent though so it probably shouldn't by default. In V4 I moved back to normal MeshFilter + MeshRenderer though, which allows you to easily disable CastShadows, so you could try that.
     
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Nope, this looks like some kind of cube voxel object, so you would want a cube voxel asset.
     
  22. DethKwok

    DethKwok

    Joined:
    Mar 13, 2017
    Posts:
    15
    Thanks to this asset, I can create orbits that traverse large distances without any issues. I use my own orbit scripts to move and rotate, but after changing transform.position all I need to do is use sgtposition.DerivePosition() and it just works :)

     
    dirkjacobasch and Darkcoder like this.
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Looking great! I love the planet trails, especially in the zoomed out view at the start.
     
  24. pratt_timmy

    pratt_timmy

    Joined:
    Jun 30, 2019
    Posts:
    32
    Attempting to Upgrade to latest version of SGT. I deleted the Root SGT Folder and went with a fresh install. I was a few updates behind. I got these errors in the Unity Console.

    [Worker0] Assertion failed on expression: 'state.state == kUpToDate'

    [Worker0] Assertion failed on expression: 'state.artifactID == result'

    GetLoadedImportedAssetsAndArtifactIDs called with invalid artifactID
    UnityEditor.AssetDatabase:ImportAsset (string)
    CW.Common.CwShaderBundle:TrySwitchTo (CW.Common.CwShaderBundle/Pipeline) (at Assets/Plugins/CW/Shared/Common/Required/Scripts/CwShaderBundle.cs:369)
    CW.Common.CwShaderBundle:AutoSwitch () (at Assets/Plugins/CW/Shared/Common/Required/Scripts/CwShaderBundle.cs:186)
    CW.Common.CwShaderBundle:ForceSwitch (string) (at Assets/Plugins/CW/Shared/Common/Required/Scripts/CwShaderBundle.cs:161)
    UnityEditor.AssetDatabase:Internal_CallImportPackageCompleted (string)

    Assertion failed on expression: 'it->second.IsValid()'
    UnityEditor.AssetDatabase:ImportAsset (string)
    CW.Common.CwShaderBundle:TrySwitchTo (CW.Common.CwShaderBundle/Pipeline) (at Assets/Plugins/CW/Shared/Common/Required/Scripts/CwShaderBundle.cs:369)
    CW.Common.CwShaderBundle:AutoSwitch () (at Assets/Plugins/CW/Shared/Common/Required/Scripts/CwShaderBundle.cs:186)
    CW.Common.CwShaderBundle:ForceSwitch (string) (at Assets/Plugins/CW/Shared/Common/Required/Scripts/CwShaderBundle.cs:161)
    UnityEditor.AssetDatabase:Internal_CallImportPackageCompleted (string)

    Edit: Everything seems OK. Errors stopped generating after adjusting my existing prefabs it seems.
     
    Last edited: Apr 10, 2022
    Darkcoder likes this.
  25. pratt_timmy

    pratt_timmy

    Joined:
    Jun 30, 2019
    Posts:
    32
    I have a suggestion / question. Tell me what you think.

    A script that culls overlay flares that are out of the camera's view frustrum. So this script would be like your OcclusionScaler script but like I mentioned does this when the flare is outside of the camera's view frustrum.
    I phrase this as part suggestion part question because I am not sure if this idea makes a lot of sense. I guess it depends on your imagination of what the Unity camera represents. The human eye?
    Anyways I think this might be a nice feature because right flares look a bit strange when only part of them is in the camera's view frustrum.
    You can see a big chunk of flare in the photo. It is the bright white light to the right. <----Poetry lol.
    upload_2022-4-10_21-16-22.png
    Anyways I was going to implement this myself in my own project. I havn't tried yet. But I was thinking something like this.

    This is very basic in part because I do not want to expose any of your OcclusionScaling code. Code which I would probably borrow to write this script to make it nice.

    GameObject sgtFlareObject;
    Vector3 starPosition;
    float starDiameter;
    Bounds starBounds = new Bounds(starPosition, new Vector3(starDiameter, starDiameter, starDiameter));
    if
    (GeometryUtility.TestPlanesAABB(GeometryUtility.CalculateFrustumPlanes(Camera.main), starBounds))
    {
    sgtFlareObject.SetActive(true);
    }
    else
    {
    sgtFlareObject.SetActive(false);
    }

    What do you guys think? Usefull? Make any sense? Or do the current flares make more sense as they are?
    LOL I'm not sure if this idea makes sense. Seems like it.

    Also and most importantly. You're better than me at this sort of thing. If you think this is a good idea you could probably do it right.
     
    Last edited: Apr 11, 2022
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    The sun's bright flare doesn't suddenly disappear as I rotate my head, so I implemented it like this. Feel free to change it as you wish though :D
     
    pratt_timmy likes this.
  27. pratt_timmy

    pratt_timmy

    Joined:
    Jun 30, 2019
    Posts:
    32
    Yeah I was thinking the same. Thought I'd get a second opinion at the very least LOL. I'm going to write it and see how it goes.

    Edit...Removed useless comment
     
    Last edited: Apr 11, 2022
    Darkcoder likes this.
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Hey everyone,

    Version 4.0.6 of Space Graphics Toolkit is now out!
    • Fixed the SgtFlareMainTex component's Color setting being ignored.
    • Fixed the SgtStarfield___ component's stretch feature not working in URP/HDRP.
    • Fixed SgtDebrisGrid when using origin shifting system.

    Enjoy :)
     
    Last edited: Sep 24, 2022
    pratt_timmy and dirkjacobasch like this.
  29. nighty2

    nighty2

    Joined:
    Dec 29, 2020
    Posts:
    29
    Hey all,

    today, I got a (for me) big issue sorted (many thanks to Darkcoder), and I had the urge to make a short video of some now working systems for celebration.

     
    shadm, dirkjacobasch and Darkcoder like this.
  30. dirkjacobasch

    dirkjacobasch

    Joined:
    Apr 24, 2018
    Posts:
    418
    Great job.
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Looks great!
     
  32. VitaMonara

    VitaMonara

    Joined:
    Jan 26, 2018
    Posts:
    4
    Hello, Is there a way to bake the generation in the editor? Such as planet shape and star field locations?
    I love the look and configurability of the kit, but basically I need to remove all runtime geometry generation. I understand this removes the ability to have terrain update as you get close but I only need the planet to look good from a distance, and so far your planets look the best.
    Thank you for your time.
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    There's no built in feature for this, because most people don't need this and I don't want to add extra code that I have to maintain. It's easy enough to do with a little custom script though. In the case of terrains, the SgtTerrainPlanet component has the private 'cubes' list, which you can loop through, these have the 'Quads' array which you can loop through, then finally these all have the 'CurrentMeshes' list, which you can convert into mesh assets or something. The starfield is easier because you can just access the mesh directly from the MeshFilter.
     
  34. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    Hello, I want to do a procedural update by being able to change a planet with UIs. But I can't access many SGT settings in the UI as Dynamic Float. How can I fix this?
     
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    For example which settings?
     
  36. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    Everythink in SGT Terrain Simplex.
     
  37. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    or the Radius in Sgt Terrain Planet and Ocean
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    I see, well these settings are doubles, not (single) floats. You would have to add a custom method that takes a float and assigns to the double.
     
  39. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
  40. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    ok i know now how, thx
     
  41. Les-Bird

    Les-Bird

    Joined:
    Apr 22, 2013
    Posts:
    12
    V4 SgtStarfield question: I have one SgtStarfieldBox in my scene. I believe I can access the points of the Starfield via the mesh.vertices[] array in the child object, however, it seems like there are overlapping vertices. The mesh.vertices[] array is 4 times bigger than I was expecting and it seems like there may be 4 vertices per point. Is this expected? Or am I doing something wrong?

    For example I'm setting the star count to 100000 but the vertices[] array size is 400000.

    Les
     
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Each star is a quad, which requires 4 vertices. These are then expanded out based on the specified radius, pulse, clamp size, etc.

    It's possible to use 1 vertex and make it quad using point sprites, but in my testing these have very inconsistent device support, and are far more limited than actual quads so I used those.

    You can also check out the "Starfield/Examples/35 Custom" demo scene for another way.
     
  43. Les-Bird

    Les-Bird

    Joined:
    Apr 22, 2013
    Posts:
    12
    Ah, that makes sense. I thought they were point sprites at first then I looked at the source and saw you were initializing 4 vertices to the same value and wasn't sure why. I ended up iterating over the list in increments of 4 and that seems to do the trick. I'll look at 35 Custom to see how that works.

    Les
     
    Darkcoder likes this.
  44. pratt_timmy

    pratt_timmy

    Joined:
    Jun 30, 2019
    Posts:
    32
    Hey there,
    Is it possible to use the LightAndShadow components with the SgtTerrain components? Shadows are cast upon the Atmosphere component just fine without any set up. Generated SgtTerrain meshes do not receive shadows.
     
  45. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    Good idea! This is currently not possible, but I've added it to the to-do list.
     
    pratt_timmy likes this.
  46. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    Hello, I just saw that there was an update and updated it. Thanks for fixing the floating origin with debris grid but I don't know how to do it.
     
  47. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    I think I did it. If not, I'll ask here again, always thanks for fixing it! Can I actually now create a Galaxy with the Debris Grid? So when I go into the Galaxy, the stars spawn there.
     
  48. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    Ok, I didnt get it. The Camera has Floating Camera, the Object with the Shape Group has Floating Object and the Debris that has SGT Debris has Floating Object, why is it wrong and how to fix it?
     
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,337
    The SgtDebrisGrid can now be added to an SgtFloatingObject GameObject and it will correctly work with the position shifts. However, SgtDebrisGrid itself works using Transform.position data, which is single precision. Therefore, it's unlikely that it will work with scales as large as a galaxy.

    To make a galaxy with procedurally placed stars it's best to use a floating spawner hierarchy setup as described in the documentation HERE.
     
  50. spacesimulationandplanetarium

    spacesimulationandplanetarium

    Joined:
    Jun 27, 2021
    Posts:
    54
    But can I get to make a Galaxy with Millions if stars with that? Are the spawned objects Pooling? And its very lagging when i go inside.