Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Space Graphics Toolkit & Planets

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

  1. zeux-n00b

    zeux-n00b

    Joined:
    Nov 4, 2017
    Posts:
    73
    HI!
    As a nonprofit hobbyist, I very glad to have SGT.
    For experiment i was thinking to plan to use 24 materials or 54 or 96 to increase resolution of planet,.. and maybe to cover entire terrain splat map. Is there something like that that can be done using SGT Dynamic Planet component? It sounds not worth, but real life planets do use more materials ..:D... Here is my (still unfinished) planet in Blender so that i dont sound to crazy planet.png
     
    Last edited: Jun 25, 2020
  2. zeux-n00b

    zeux-n00b

    Joined:
    Nov 4, 2017
    Posts:
    73
    ...custom UV maps, by cube sphere with 24 materials gjlgil;gi;.PNG
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Is this a screenshot for ants? :D

    SgtDynamicPlanet is only designed to work with one equirectangular heightmap, with procedural noise to fill in the gaps. Since the mesh is made from a subdividing cube it would be possible to modify the code to allow something like you describe, but 99% of users don't need this much texture detail so it makes no sense to add something so complex to the main component. This component was basically designed to be a high detail version of SgtStaticPlanet, which is designed to work with the planet shader.
     
  4. zeux-n00b

    zeux-n00b

    Joined:
    Nov 4, 2017
    Posts:
    73
    if you are interested to add anything similar idea (to increase resolution, (the best way for scaling up the planets)) i can trade you for this node tree. Which i do use 8 height maps here that was generated in Genetica Studio version, but can be easily replaced with noise (noise that might be complex enough), the rest is very flexible and controllable and nothing spaghetti mess like... How much time would take to bake neede maps, at that resolution, i dont know yet i will use another PC for that for sure
     
    Last edited: Jun 27, 2020
  5. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    Hi Darkcoder, hope you're well. Is there any chance you could add the tiled heightmaps back into the planet system? I miss having the finer control.
     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I'm super busy this month so I can't add anything.

    I replaced the tiled heightmaps with procedural noise because breaking up the look of obvious tiling is quite difficult and requires a lot of samples and manual work, which makes it more expensive than procedural noise. To implement this you could duplicate SgtDynamicPlanetDetail and add additional .Data and .Size fields that you fill with tiled heightmap data rather than the current splat map, you can then modify the sample code to tile, and remove the procedural code. I guess it's a little complicated to do.
     
    RedEarth likes this.
  7. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    No worries. I'll dig into the code, see if it's something I can handle.
     
    Darkcoder likes this.
  8. ethaneditsbusiness

    ethaneditsbusiness

    Joined:
    Feb 6, 2020
    Posts:
    31
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    If you have SGT then the SgtDynamicPlanet component can be used to make a quadtree planet based on the settings you provide. You can hover the mouse over each for a tooltip to see what it does, or read some information in the documentation, or go through demo scenes 13-20 in the SpaceGraphicsToolkit/Features/Planet folder.

    If you want to make a planet using Unity's built-in terrain system then that's not possible, at least with SGT. I only handle support via email or this forum thread.
     
  10. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    219
    Floating Orbit Visual appears to be broken. From a fresh install, I load up the relevant sample scene, and no visual appears, either in Scene or Game view.

    upload_2020-7-7_6-32-19.png

    upload_2020-7-7_6-32-36.png

    Using Unity 2019.3.10f1.
     
  11. emptyxu

    emptyxu

    Joined:
    Jun 15, 2017
    Posts:
    12
    Too may unnecessary global shader keywords! Every time i update this asset, i have to fix this problem myself!!!
     
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Oops, you can fix this by changing the Universe/Media/Orbit Ring/Near Distance = 10.

    This demo scene shows the orbit visual in a small scene, and the previous distance of 10million meters means the orbit is invisible.


    SGT doesn't have 'unnecessary' shader keywords. They're used to optimize the shaders based on the features you use, and there are only 10, which are shared across all the shaders to minimize their use as much as possible.

    Unity introduced local keywords in 2019.1, but SGT is currently designed for 2018.4+, so I can't switch to them yet.
     
    emptyxu likes this.
  13. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    219
    Great! That fixes the problem.

    One other thing: Somehow, my floating coordinates have gotten out of sync in the editor.
    upload_2020-7-9_7-14-49.png

    This object's parent has a default 0/0/0, 1/1/1 transform, so local Position and actual Position are the same, but its SGT Floating Point coordinates are not. How do I reset the SGT coords, so that Position and Local X/Y/Z are identical?
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The difference between these values depends on where your SgtFloatingCamera last snapped to. You can set the SnappedPoint values to 0 to fix this, though it requires your floating camera be at 0,0,0, or at least within the SnapDistance radius of it.
     
    MasonWheeler likes this.
  15. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    219
    Yeah, that was the problem. Somehow my camera had been set up with a ridiculously small snap distance of 100, and that was breaking everything without me realizing it.
     
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    100 is the default value :D In my testing you can notice issues at even 1000 units under some circumstances, so to keep it round I made it 100. Also, you don't have to position it at 0,0,0 as I previously stated, it can also be any multiple of your snap distance.
     
  17. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    The terrain is offset from the shader on the tiled heightmaps you gave me. The shader matches the procedural terrain so it must be in the tiled heightmap code but I can't find it.
     
  18. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Sorry for the late reply, things have been really busy these past few weeks.

    The tiled heightmap UV is calculated on line 236. You may need to change the 2.0 multiplier to 1.5 or something to line up. Also, keep in mind this only does one sample around the equator, whereas the detail texture in the planet shader does one for the poles too and blends them based on latitude.
     
    joshua_42 likes this.
  19. tgamorris76

    tgamorris76

    Joined:
    Apr 24, 2013
    Posts:
    292
    Hi, just wanted to ask how to manually place objects or colliders to the planets. Would like to fly low and trigger a collider for level change to a more detailed location map.
     
  20. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    You can see the Features/Planet folder for examples on how to add colliders to planets (Static Planet / Collider scene, and Dynamic Planet / Collider scene).

    If you want to place an object on a SgtStaticPlanet or small SgtDynamicPlanet then you can add it as a child GameObject.

    If you're using a large SgtDynamicPlanet then you can use the SgtDynamicPlanetObject component to snap it to the surface (Dynamic Planet / Object scene).

    If you're using the origin shifting system then you can add the SgtFloatingObject component too.

    Depending on how big your planet is and how small your collider/trigger is, it may be difficult to manually position it in the Scene view or via the inspector. In this scenario it may be easiest to fly down to your planet in game, place the object in the scene, then copy+paste it when you're back in edit mode.
     
    Last edited: Sep 24, 2022
    tgamorris76 likes this.
  21. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    Cool. Fixed it. I've been trying to figure out how to get sampler states to take the polar coordinates from your shader as the function that does this takes a Sampler2D and won't accept sampler states. I'm totally stumped on this one. Do you have any suggestions?
     
  22. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    If you're trying to modify SGT Planet to use sampler+state then you can modify the sample2 function to take the state as well, then you can modify every tex2D call in the shader to use the tex.Sample(state, ...) syntax instead, unless I misunderstand your question?
     
  23. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    That's what I have been trying but the shader won't accept Texture2D, SamplerState and .Sample() functions. I tried changing the pragma target to different versions but no luck. It will accept macros (UNITY_DECLARE_TEX2D(_MainTex) etc) but I can't get them into a function (as they're not a type?).
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Are you running on a platform that has sampler states?

    HLSLSupport.cginc shows it requires one of these: #if defined(SHADER_API_D3D11) || defined(SHADER_API_XBOXONE) || defined(UNITY_COMPILER_HLSLCC) || defined(SHADER_API_PSSL)

    Where UNITY_SEPARATE_TEXTURE_SAMPLER will be defined if it does.
     
  25. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    Thanks man, but it seems that they don't work with surface shaders...oh well, I'll leave it until your next terrain system is ready. Thanks for your help!
     
    Darkcoder likes this.
  26. wechat_os_Qy0128_6hl32gJ9TvurFeYlus

    wechat_os_Qy0128_6hl32gJ9TvurFeYlus

    Joined:
    Jul 15, 2020
    Posts:
    10
    hi, i just buy it, and i'm using HDRP, i see all the mat is wrong, so does it support HDRP now? thanks!
     
  27. ethaneditsbusiness

    ethaneditsbusiness

    Joined:
    Feb 6, 2020
    Posts:
    31
    Okay. So Im re-doing my project moving from an imac to a windows device, and I am trying to import SGT into Unity 2019.3, but when i do, i get 100 errors about namespaces such as mathematics not existing in namespace unity.
     
  28. ethaneditsbusiness

    ethaneditsbusiness

    Joined:
    Feb 6, 2020
    Posts:
    31
    heres a picture of my error
     

    Attached Files:

  29. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    Did you use the PIPELINE tool in the root SpaceGraphicsToolkit folder to switch to scriptable? This should make most of the features work, but there are some issues with the lighting brightness I'm working on fixing.


    You must manually import the Burst, Mathematics and Collections packages, more info HERE. I plan to add a readme specifically for this in the next version.
     
    JFI66 likes this.
  30. wechat_os_Qy0128_6hl32gJ9TvurFeYlus

    wechat_os_Qy0128_6hl32gJ9TvurFeYlus

    Joined:
    Jul 15, 2020
    Posts:
    10

    hi, thanks, now everything is ok.

    and i want ask anther thing:

    you say we can this:

    Newtonian Physics ― Quickly add realistic gravitation to your scene. This allows your player and spaceship to realistically orbit and land on planets, and even allows planets to orbit each other.

    but I can't find any excample scenes, could you make a showcase scenes about Newtonian Physics?

    i really need this.

    like: some planet orbit the sun, and player can drive spaceship to land on them.

    thanks!

    and very great work! worth the price!
     
  31. wechat_os_Qy0128_6hl32gJ9TvurFeYlus

    wechat_os_Qy0128_6hl32gJ9TvurFeYlus

    Joined:
    Jul 15, 2020
    Posts:
    10
    hi, i'm using hdrp, and i get this wired thing, can you help?



    thanks!
     
  32. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    219
    Looks to me like Z-fighting between the atmosphere and the planet's surface.
     
  33. ethaneditsbusiness

    ethaneditsbusiness

    Joined:
    Feb 6, 2020
    Posts:
    31
    Hello, so im trying to create a planet with a dynamic lod, where i can land my spaceship on and then walk around it with a first person character. My first question is how do i configure the planet? and my second is how do I make a collider for the planet?
     
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    This is shown in the "Features/Shared/06 Newtonian Gravity" and "/07 Planet Gravity" demo scenes. Also in the "Packs/Basic Pack/Terrestrial Planet" and "/Terrestrial Planet + Ring" demo scenes.


    Does this issue go away if you open Features/Atmosphere/Resources/SgtAtmosphere.shader, and uncomment line 46 to become: Offset -0.01, 0


    You can add the SgtDynamicPlanetCollider component alongside your SgtDynamicPlanet component to add colliders at the specified resolution. This is shown in the "Features/Planet/19 Collider" demo scene, as well as the "Packs/Basic Pack/Terrestrial Planet" and "/Terrestrial Planet + Ring" demo scenes with a spaceship that can land.
     
  35. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,303
    hey @Darkcoder ,
    how is URP/HDRP support standing currently ?
    and second question: is there anything resembling runtime atmospheric mass/clouds movement ?
    Thank you
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    As far as I know URP is fully supported, and HDRP is mostly supported. The main issue with HDRP is the SgtDepthCamera component doesn't work, so the light flare that shrinks as it goes behind planets and such doesn't work, and also the light brightness values are too high. I plan to fix these in the next update.

    The SgtCloudsphere component allows you to add a layer of clouds to your planets, but these aren't volumetric or animated. Making volumetric and animated clouds that wrap around a planet is pretty difficult though, so I can't promise they will ever be in SGT. Perhaps they will be part of the new planetary terrain asset I'm still working on, or a separate asset, who knows.
     
  37. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,303
    thanks, volumes don't bother me much though; if there's a cloud layer already would be too difficult to have basics done by just changing texture's UVs ?
    terrain assets are _exactly_ what I'm *not* after currently ;0)
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The SgtCloudsphere component uses a Cubemap to render the clouds. You could add some kind of animation by modifying the way the UVW is sampled, might be a little tricky to get it looking good though.
     
  39. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,303
    ah right, thanks !
     
  40. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,303
    @Darkcoder, got the planets package
    with HDRP:
    immediately after importing there's:
    Code (CSharp):
    1. ArgumentException: Can not deserialize (UnityEditor.Rendering.LWRP.LightWeightPBRSubShader), type is invalid
    2. UnityEditor.Graphing.SerializationHelper.Deserialize[T] (UnityEditor.Graphing.SerializationHelper+JSONSerializedElement item, System.Collections.Generic.Dictionary`2[TKey,TValue] remapper, System.Object[] constructorArgs) (at Library/PackageCache/com.unity.shadergraph@7.3.1/Editor/Data/Util/SerializationHelper.cs:105)
    3. UnityEditor.Graphing.SerializationHelper.Deserialize[T] (System.Collections.Generic.IEnumerable`1[T] list, System.Collections.Generic.Dictionary`2[TKey,TValue] remapper, System.Object[] constructorArgs) (at Library/PackageCache/com.unity.shadergraph@7.3.1/Editor/Data/Util/SerializationHelper.cs:157)
    4. UnityEditor.Experimental.AssetImporters.ScriptedImporter:GenerateAssetData(AssetImportContext)
    5.  
    6.  
    7. {}
    8. UnityEditor.Experimental.AssetImporters.ScriptedImporter:GenerateAssetData(AssetImportContext)
    9.  
    and running first 4 (so not 'all planets' scenes) spams the console with:
    Code (CSharp):
    1. Thread group size must be above zero
    2. UnityEngine.Camera:Render()
    3. SpaceGraphicsToolkit.SgtDepthCamera:DoCalculate(Vector3, Vector3) (at Assets/Space Graphics Toolkit/Features/Billboard/Scripts/SgtDepthCamera.cs:100)
    4. SpaceGraphicsToolkit.SgtDepth:Calculate(Vector3, Vector3) (at Assets/Space Graphics Toolkit/Features/Billboard/Scripts/SgtDepth.cs:35)
    5. SpaceGraphicsToolkit.SgtDepthScale:LateUpdate() (at Assets/Space Graphics Toolkit/Features/Billboard/Scripts/SgtDepthScale.cs:49)
    Switching to Scriptable Pipeline prints

    every time (so I'm not sure if shaders get really updated), followed by first deserialization errors

    the Z-fighting fix you mentioned earlier seems to be working (the shader is SgtAtmosphereInner)

    Hope this helps, let me know if there's something else worth to be checking/tested out
    otherwise the planets are OK except the lights which is expected
    Cheers ~

    EDIT: this is on current latest LTS 2019.4.4 and its verified HDRP, so 7.3.1
     
    Last edited: Jul 23, 2020
  41. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    219
    @r618
    ArgumentException: Can not deserialize (UnityEditor.Rendering.LWRP.LightWeightPBRSubShader), type is invalid


    Why is it trying to deserialize LWRP shader stuff on HDRP? Are you sure you didn't miss a step somewhere?
     
  42. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,303
    I just now noticed Experimental namespace, SRP was moved out of it some time ago - it might be enough to regenerate graphs in reasonably recent version

    no I didn't miss a step anywhere @MasonWheeler
     
  43. ethaneditsbusiness

    ethaneditsbusiness

    Joined:
    Feb 6, 2020
    Posts:
    31


    upload_2020-7-23_8-52-10.png
    Im trying to make my planet big enough for my ship to land, and for me to walk on. But the issue im getting is the detail is too little and everything looks super triangular. I also tried increasing the planet and sphere size to 2 (as shown here) How did you get your planets to look so real and detailed? what settings did you use for this for example: upload_2020-7-23_8-54-56.png

    also here are my settings for my planet: upload_2020-7-23_8-55-37.png upload_2020-7-23_8-55-50.png
     
  44. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    Shader progress: Screenshot (1).png
     
    Titan2105 and blacksun666 like this.
  45. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    I checked it out and I can replicate these issues.

    As far as I can tell, the deserialization errors are a bug with Unity. They seem to be harmless though, so you can ignore them.

    Enabling the offset in the SgtAtmosphereInner shader indeed seems to stop or greatly reduce the flickering. This does introduce other rendering issues with SgtDynamicPlanet though. Fixing this will probably require me to rewrite a lot of the meshing code, so this will take some time.

    As for SgtCameraDepth (seems to spam the console with "Thread group size must be above zero"), I think it's easiest to just remove this and use the raycast alternative instead. The only difference is optical depth through the atmosphere or rings is lost, but I can manually calculate these easily enough to make them almost the same. Doing it manually like this is also likely to see a massive speed increase, so I'll look into this.


    While I didn't save that exact scene, I did save some made for the newer promo video. You can get them HERE, these were made with an older version of SGT though, let me know if they don't work and need to be updated.


    Incredible as always!!

    Just so you know, I've been making progress on the new terrain rendering system. I still wasn't happy with my previous implementations, so I went back to the drawing board and experimented with about 5 completely different ideas I had. Most of these experiments were with fully GPU based (e.g. ray marching) that almost worked well on their own, but there was always some big limiting factors that make them unusable when combined with other features needed in a typical scene. I'm working on yet another idea now though, fun times :D
     
    joshua_42, JFI66 and dirkjacobasch like this.
  46. dirkjacobasch

    dirkjacobasch

    Joined:
    Apr 24, 2018
    Posts:
    418
    Looks amazing. I wish I could work again on my planets if @Darkcoder is ready with the new asset. :D
     
    Darkcoder, joshua_42 and JFI66 like this.
  47. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    Hello. In the last version of SGT terrain it was relatively easy to add additional mask maps for finer control of the heightmaps. Could you point me in the right direction to do the same with this version? I'm having trouble figuring this one out. Cheers.
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,404
    The new terrain component uses the job system for everything, and jobs can only access large data like masks from their own job struct using a NativeArray, which requires you to convert your mask, and assign it to the job.

    Inside SgtDynamicPlanet_Job.cs you can see the HeightmapJob, which stores the heightmap in the Data array + Size + Scale. Execute(int index) gets run once for each vertex in the current terrain chunk which samples the current Vectors[index] and contributes to the Heights[index]. The heightmap data itself is copied from line 340 where the job information is filled and scheduled.
     
    joshua_42 likes this.
  49. MasonWheeler

    MasonWheeler

    Joined:
    Apr 2, 2016
    Posts:
    219
    Rings seem to react oddly to lighting.

    I copied the Jovian example with the ring around it, and the entire thing is lit equally. It seems like if any SgtLight falls upon any portion of the ring, the entire ring is lit evenly by that light, with no respect for shadows cast by the planet or for portions of the ring being out of range of the light.
     
  50. halagame

    halagame

    Joined:
    Jan 14, 2020
    Posts:
    17
    Hi there, great asset! I have just tried to add the SGT Starfield Box with all default settings, everything looks good when I hit play button. However, if I try to build it for windows x64, the sgt starfield is not displaying. I built a new project with every setting by unity 2019.4.4f by default.
    Any idea where should I look for? thanks