Search Unity

Space Graphics Toolkit & Planets

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

  1. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    In all the Orbit example scenes, the background objects are parented to a GameObject with the CwBackground component. This component automatically moves the background objects to follow the 'MainCamera', though you can modify this to a custom Transform. Perhaps there's a scenario where this doesn't work?
     
  2. Adam_Benko

    Adam_Benko

    Joined:
    Jun 16, 2018
    Posts:
    105
    I have tried it like 10 times with a back up project and each time I get errors. I have noticed that the new SGT versions has different placement than the one from 3 years ago. It is in the folder plugins, and has own CW folder. I recreated these conditions and I put the sgt folder to the CW folder, updated it and got the errors anyway. I made an empty project and imported the latest SGT version there to see the structure that the new version has but even If I recreate the same hierarchy that it needs, I still get errors. I feel like your current update is unable to update SGT versions from 2020.
     
  3. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    I've mostly rewritten everything in that 3 year time span so there is no direct way to update the asset. I recommend you stay with the old version and look at the demo scenes for that, as they should show something similar.
     
  4. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    Is there a way to make SGT Starfield Nebula interactive with Light?
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    No. You would have to heavily modify the shader code.
     
  6. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    Why does the City Light not really working? How can I fix it?
    Screenshot_20230102_160613.png
    Screenshot_20230102_160622.png

    And how can I make the Ring interactive with Lens Flare?
     
    Last edited: Jan 2, 2023
  7. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    For the City Lights, these are the settings.
    Bild_2023-01-02_164240837.png
     
  8. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Take a look at the Earth demo scene in the Solar System Pack you can download from the documentation.
     
  9. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    Still don´t work, its only work on Planet and not on Terrain Planet. Left is Terrain Planet (in north america you can see a bit the lights) and right is a normal Planet, which works fine.
     

    Attached Files:

  10. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Oh I see. I'm not sure why I included the night light settings in the terrain planet shader, because the terrain planet doesn't update the sun direction angle, which is why you experience this issue.

    I guess I could add this code to update the angle, but the reason why I didn't intend to add night lights is because a terrain planet is supposed to be something you can fly down to in high detail. What would you expect to happen to the night lights as you fly down to the surface?
     
  11. eKyNoX

    eKyNoX

    Joined:
    Feb 4, 2013
    Posts:
    14
    Hello, I did not read yet all the 80 pages here but I would like to know if you are already presenting in your plugin resources, examples and eventually docs to explain how you achieve the floating point shifting in your Youtube videos and if the answer is yes, which project it is? (Another guy who wish to create galaxies here ^^).




    Thanks in advance. I don't get how it have been possible that I miss this package all these years...
     
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    This is part of the "Universe" feature that comes with SGT (see the documentation on the store page for more info). This part of the asset was released for free for a time, but it wasn't popular enough to make sense maintaining it separately so I deprecated it.
     
  13. eKyNoX

    eKyNoX

    Joined:
    Feb 4, 2013
    Posts:
    14
    Ok, that is sad as it was the main concern about my needs. The documentation about this looks very brief speaking about origin shifting (the ability to move the world around the player instead the player moves around ..., btw, not sure this technique works with any games on *networks*), that we need to spawn things in a hierarchy and a small paragraph about SgtFloatingMassive to make distant objects visible.

    I'm not sure what's presented inside the asset as I do not own it (yet). Is it possible to view any examples on how you make your seemless transition from the universe view (the star light) to the orbital bodies inside that specific solar system?

    Thanks again for your answer.
     
  14. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    How does SGT Debris Grid work with Floating Origin?
     
  15. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    The universe feature at its core is just an additional coordinate system associated with objects in your scene, and these are moved around when your camera goes outside of the specified boundary, so there isn't much complexity to talk about. Indeed, it's not going to be automatically compatible with any networking system, so you will have to manually sync the (SgtPosition) universal coordinates across clients then they will show up in the same place. Most of the complexity comes from the components that lie on top of this, like the prefab spawner, distant object scaler, etc. There is no 'universe view', only the ability to pick (distant) objects in the universe, and warp to them, and depending on your hierarchy setup these objects could spawn solar systems or planets, etc.

    If you're looking for some fully featured floating origin system that works out of the box to make a full universe then this isn't it. This is more of a bonus feature that I needed to add to render the Earth Sized Planet demo scene. Using this in a proper project will very likely require additional code.


    I'm not sure if it does, but since the debris is spawned as a child of the SgtDebrisGrid component, it might. Due to this, the maximum debris spawn radius would be limited to that of a typical Unity scene. Therefore, you couldn't just have one debris grid and expect debris to spawn and work fine across the whole universe, more like a few thousand units around the SgtDebrisGrid component itself.
     
  16. eKyNoX

    eKyNoX

    Joined:
    Feb 4, 2013
    Posts:
    14
    Ok, thanks for clarifications. So as you said, this part of the asset (ie. origin shifting system) is deprecated and not included anymore with Sgt, right?

    I think I'm looking for something using octrees like dexyfex did on his galaxia project (ie. https://dexyfex.com/2018/07/23/galaxia-now-in-ue4/ ). Universe is an octree, solar system is an octree, each celestial is an octree and LOD is applied on it. The author himself says he's using a custom impostor system. I even do not know what is an impostor ^^. Sure long head pain will follow for me later on :)
     
    foxyspace likes this.
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    No, the the universe feature is still part of the SGT asset. It's just no longer offered as a separate free asset.
     
  18. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    I was thinkting to add Octree because its perfect for Space Games. Space Games like Galaxia or Space Engine has Octrees. @Darkcoder will you maybe improve the Spawn System or add Octrees?
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    What's wrong with the spawn system? You can already nest it to create a tree.
     
  20. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    When does that temporary discount expire?
     
  21. Adam_Benko

    Adam_Benko

    Joined:
    Jun 16, 2018
    Posts:
    105
    How did you make that lens flare effect ? Thanks.
     
  22. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    With URP or HDRP you can make your custom Lens Flare. I used these Textures to make my own Lens Flare.
     

    Attached Files:

  23. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    Just asking, maybe you have some Ideas to add more features to Floating Spawner.
     
  24. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi @Darkcoder I have an issue with SgtTerrainPrefabSpawner when used in combination with SgtFloatingCamera. Everytime an origin correction is performed, prefabs are destroyed and respawned by SgtTerrainPrefabSpawner. Is it possible to make SgtTerrainPrefabSpawner not spawn and destroy on origin corrections?

    EDIT: I am confused. Maybe it is not respawning. I don't know... Need more testing...
     
    Last edited: Jan 10, 2023
  25. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi @Darkcoder . Here is the situation: I have a planet with radius r. I want to spawn n number of prefabs around camera in a range of x. Then for SgtTerrainPrefabSpawner.Resolution value, I do this math: Resolution = 2r / x and enter the number n to Limit area (I know it is not guarantied to hit n, it is ok).

    Now, let SgtFloatingCamera snap in distance of s. when x < s, everytime the camera snaps, the prefabs disappear and are respawned. When trying to spawn grass chunks of 3 to 6 meters in size in range of 50m, you continuously see chunks behave like this in every 100 meters.

    Then, in case of x > s, those spawned prefabs just blink on screen each time a floating origin correction made. I suspect this is a respawn too. But, when x is 1000 and s is 100, it is meaningless to see prefabs respawning in 1000 m range. This only makes sense if chunks in SgtTerrainPrefabSpawner are destroyed and re-built each time an origin correction is made, but, I can't see it may be happening in x > s case.

    Also, SgtFloatingCamera snaps in LateUpdate while SgtTerrainPrefabSpawner works in Update, which makes the whole thing more mysterious. I also tried to include SgtTerrainPrefabSpawner in the script execution order in several ways, no change. I tried to alter SgtFloatingCamera snapping function, to spread the function into several frames so that SgtTerrainPrefabSpawner can read a snap is going on precisely in at least one frame and block its Update until snap is complete, I had other artifacts (some prefabs hanging on the air). I also tried having an independent (parent null) empty game object that moves with camera and referenced to the SgtTerrainPlanet.Observer field. Then, when floating origin snap begins, this object is not updated to be in the same place with camera until the operation ends. This should have worked, but I continued to get the same destroy-respawn effect on grasses (x < s case).

    Maybe, I might write a simple generator and only spawn those generators in SgtTerrainPrefabSpawner. Then, if I can detect duplicate generation at the spawn location, I may cancel the operation of the second one and destroy it. This way I may overcome the issue, I hope.

    But, before going into that, am I missing anything in this system to prevent those destroy - respawn issues?

    NOTE: I am working on a copy of Earth Sized Planet scene.
     
    Last edited: Jan 11, 2023
  26. Adam_Benko

    Adam_Benko

    Joined:
    Jun 16, 2018
    Posts:
    105
    You are using built in Lens flare function that is available for unity 2021 ? I have 2020 and cant update sadly.
     
  27. nighty2

    nighty2

    Joined:
    Dec 29, 2020
    Posts:
    29
    Hi Carlos,

    This is about SgtStarfieldNearTex.
    I use SgtStarfieldSpiral with the material "Starfield+PowerRGB+NearFade" and it has a SgtStarfieldNearTex Component.

    Problem:
    When this starfield-gameobject is already in the scene when I press play, the nearTex works fine. But if I instantiate the starfield gameObject during runtime the nearTex does not work and the particles wont disappear upon the cameras approach.

    Findings:
    If I then, still during runtime, deactivate and reactivate the NearTex component, it starts to work as expected. The reactivation trick works only on the nearTex component. Deactivating and reactivating the starfields/nearTex' gameObject itself does not help.

    I tried different approaches.
    SgtStarfieldNearTex.HandleSetProperties() seems to be added as listener successfully and gets called. Changing the execution order of neartex did not help either.

    Do you have an idea what to do?
     
    Last edited: Jan 11, 2023
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    It expired today along with the new release discount. It's now at 50% off if you already have SGT, so still a good deal :)


    Could you modify the attached scene to replicate the issue? Here the spawn radius is lower than the snap radius, and I don't notice any flickering when snapping. You can also change the scale of the prefab to see that the prefabs aren't being respawned when snapping.


    If HandleSetProperties gets called then it should work. This event should be called every frame. You can try exporting the near tex and removing this component:

    upload_2023-1-12_22-42-1.png

    If not, can you prepare a minimal unitypackage that demonstrated this so I can test it?
     

    Attached Files:

  29. TheSycoraxComplex

    TheSycoraxComplex

    Joined:
    Oct 22, 2022
    Posts:
    2
    Hey guys, I'm a new member of this community and have been utilizing Space Graphics Toolkit in the development of a game project over the past several months. I am excited to share a side project I am currently working on, which can procedurally generate equirectangular planetary textures and heightmaps for use in Space Graphics Toolkit. My intention is to release this project once I have added a few features, made some improvements, and resolved any bugs. I would appreciate any feedback or suggestions on this project as I continue its development.



    I originally posted this on Reddit a few weeks ago and included technical details about how this works in the comment section. Please feel free to check it out: https://www.reddit.com/r/Unity3D/comments/zueos1/procedurally_generating_equirectangular_planetary
     
    Last edited: Jan 12, 2023
  30. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,685
    I wish you'd said something about that before it expired. I don't see why it had to be a secret.
     
  31. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    Hi @Darkcoder. I confirmed there is no re-spawn situation with the SgtTerrainPrefabSpawner. Thank you for your help.
     
    Darkcoder likes this.
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Looks great!!
     
    TheSycoraxComplex likes this.
  33. TheSycoraxComplex

    TheSycoraxComplex

    Joined:
    Oct 22, 2022
    Posts:
    2
    Thank You!
     
    Darkcoder likes this.
  34. TheGonzoGamer

    TheGonzoGamer

    Joined:
    Apr 24, 2019
    Posts:
    35
    @Darkcoder is there a workaround for using the planets with a camera rendering to a texture?
    Everything works with cameras setup otherwise but when I set them to render to a target texture the planets go invisible. Their depth data is still present as they can obfuscate non SGT shader planets. That is, they cut out a transparent hole as they pass by.

    Using the CWDepthtextureMode component has no effect.
     
  35. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    Does Space Graphics Toolkit has Orbit Camera?
     
  36. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Cover (1).png

    Hey everyone,

    I just released a new bundle combining the Spaceships and Orbit assets. It also includes some exclusive bonus content.

    There may or may not be an extra special discount for existing owners of the SGT asset. Keep in mind this discount is temporary, and will decrease every day until it expires. Enjoy :)

    >> GET THE BUNDLE HERE <<



    I sent you a fix via private message.


    Sure, the Basic Pack's "Continuum" demo scene shows you how this can be configured.
     
  37. TheGonzoGamer

    TheGonzoGamer

    Joined:
    Apr 24, 2019
    Posts:
    35
    @Darkcoder thank you for the package it works beautiful.
    I have a quick question. In my star map i need to display 25 "celestial bodies". In my testing the terrestrial planets and planets eat up a good amount of performance. I bought the Orbit asset (Great job by the way) but that is for something different then what I'm doing.

    Here is the star map that I am referring to


    I can always try and do an object swap by using a simple textured sphere and upon inspection load the actual mini-planet but I wanted to ask you first.

    Having the atmo effect and cloud sphere and any other planetary effects is a must when inspecting the waypoint. I just need to find a more performant way to display 25 of these beauties.
     
  38. TheGonzoGamer

    TheGonzoGamer

    Joined:
    Apr 24, 2019
    Posts:
    35
    Update on the situation.
    I am using a Planet shader planet instead of a Terrain Planet. I assume this would cost less performance. Maybe I am wrong.
    If I disable the gameobject that holds the 'Atmosphere' components on the 20 mini-planet waypoints, performance jumps from 130fps to 180fps in the editor. A pretty significant amount. This is not practical though since some planets require their Atmo for the aesthetic. Such as the one I am using from the package, Alien Planet4_2 which is purple with its Atmo and brown without it.

    Is there a 'cheap' way to display the atmo? Maybe some settings I can turn off until zoomed in?
    I have set the atmo, cloudsphere and planet component to use GeoSphere10 to keep the poly count down. Which works just fine in their small size. You can't see any polygons
     
  39. nighty2

    nighty2

    Joined:
    Dec 29, 2020
    Posts:
    29
    @TheGonzoGamer
    How about recording the planet (incl. atmo), make a lower resolution (animated?) icon for it and, yeah, spawn the real thing when the players inspect it? A bit of work but probably far more efficient.

    @Darkcoder
    Did you made any progress on the nearTex not working properly? Have you been able to recreate it using the unitypackage I sent you?

    Another question and potential feature request: I want to add entrances to underground tunnels/bases. I can deactivate the planet/terrain collider when the ship moves into a planet, but not the whole mesh-visual (because that would be noticed by the player). Is there already a way to "poke a hole" into a planets texture/shader / make a specific part of it invisible?
    Is that feasible?
    I know about "dissolving shader assets" but there are multiple reasons for not using them. Main reason is because my project uses the built in render pipeline thus I cant combine these with your planet shaders.

    Cheers
     
    Last edited: Jan 25, 2023
  40. TheGonzoGamer

    TheGonzoGamer

    Joined:
    Apr 24, 2019
    Posts:
    35
    @Darkcoder Is there a forum for support with Orbits? I don't want to clog up this one if there is a separate one. Thanks!
     
  41. TheGonzoGamer

    TheGonzoGamer

    Joined:
    Apr 24, 2019
    Posts:
    35
    I have a bunch of planetary textures I got for use with SGT. They are in the aspect ratio of 2:1 and I see Orbit planets use textures of 1:1.
    Trying my textures results in very odd UV wrapping. Any way to get them to work with Orbit?
     
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414

    You can check the profiler to see what's eating up the performance. Using a RenderTexture like this probably a lot of it. The planet, atmosphere, and clouds are all separate layers, so rendering each of them has performance overhead. The fastest way to render this is to combine them into a single texture ahead of time and scroll them across, but this would require a custom shader (it's similar to how Orbit works).

    Yes, you should use planets for this. SgtTerrain is designed for planetary landing, so there is overhead to rendering them especially if you have so many.


    There's a thread for it HERE.

    The way planets are rendered in SGT is completely different to how they're rendered in orbit. In SGT they are spheres and require cylindrical/equirectangular textures. Whereas in Orbit they're normal seamless 2D textures that are warped to give the illusion of being a sphere. Therefore, you cannot swap the texture across.

    Haven't had a chance to look at it yet. There's no possibility to make holes/caves in the terrain, it's simply too much work. The easiest approach is to just add rock meshes on top that form some kind of cave that's technically above the terrain surface.
     
  43. Pabi

    Pabi

    Joined:
    Feb 13, 2016
    Posts:
    48
    When I'm trying to buid on android with URP, I have this error :

    The DOTS_INSTANCING_ON keyword requires shader model 4.5 or greater ("#pragma target 4.5" or greater).

    Any Ideas?
     
  44. lsgheero

    lsgheero

    Joined:
    Mar 24, 2013
    Posts:
    60
    @Darkcoder I found an issue I am hoping you can help me find a way to solve...

    I use your space background stuff in place of a skybox.. which works great on the main camera... however I have a sight system setup on my weapons that uses its own base camera and a render2texture setup.. This works fine but my issue is that the base camera for the target system cannot see the SGT things... (space background with stars/clouds, the planets, etc...

    How can get the second base camera to see the SGT items? Both the main and the SGT Camera have the same settings outside of the second is obviously not the main...

    example this is pointed at the sun but sees nothing but black..
     
  45. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    If I make a new project in Unity 2021.3.16f1 with URP and SGT and open the "Jovian" demo scene, I can make an Android build of it without any errors.


    If I make a new project in Unity 2021.3.16f1 with SGT and open the "Star" demo scene, duplicate the Main Camera, untag MainCamera, and make it render to a Render Texture then everything works as expected:

    upload_2023-1-30_16-6-10.png
     
  46. Pabi

    Pabi

    Joined:
    Feb 13, 2016
    Posts:
    48
    I guess it might be because I have DOTS in my build. I'm experimenting with Entities 1.0. Is everything working on Android or there is limitation I should be aware? Thanks a lot for your answer.
     
  47. foxyspace

    foxyspace

    Joined:
    Oct 16, 2021
    Posts:
    71
    using Mono.Cecil.Cil;
    using SpaceGraphicsToolkit;
    using SpaceGraphicsToolkit.Billboard;
    using System.Collections;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Linq;
    using TMPro;
    using UnityEngine;
    using UnityEngine.UIElements;

    public class SgtFloatingOctree : MonoBehaviour
    {
    static Vector3[] octreePositions = {
    new Vector3(0f,0f,0f),
    new Vector3(0f,0f,1f),
    new Vector3(0f,1f,0f),
    new Vector3(0f,1f,1f),
    new Vector3(1f,0f,0f),
    new Vector3(1f,0f,1f),
    new Vector3(1f,1f,0f),
    new Vector3(1f,1f,1f)
    };

    #region public
    public float updateInterval = .2f;
    public List<SgtFloatingObject> prefab = new List<SgtFloatingObject>();
    public float range = 5f;
    public int numberOfPrefabs = 1;
    public SgtFloatingOctree octree;
    public Vector3 octreeScale = new Vector3(1,1,1);
    public float LODDistanceMultiply = 6f;
    public int maxLOD = 4;
    public List<SgtFloatingObject> instances = new List<SgtFloatingObject>();
    #endregion

    #region private
    private float LODDistanceShow = 2f;
    private bool headOctree = true;
    private float LODDistance;
    #endregion

    int thisLOD;

    bool isCurrentLOD = true;
    public bool IsCurrentLOD
    {
    get { return isCurrentLOD; }

    // take actions for when this LOD is activated/deactivated (such as enabling/disabling a Mesh Renderer)
    set
    {
    isCurrentLOD = value;
    //if(renderer)renderer.enabled = value;
    }
    }

    public void Start()
    {
    LODDistance = octree.transform.localScale.x * LODDistanceMultiply;

    Transform parent;
    // any special processing for if this is the first LOD
    if (transform.parent == null)
    {
    thisLOD = 0;
    }
    // iterate through ancestors (if any) to find what level of subdivision this object is
    else
    {
    parent = transform.parent;
    while (parent != null)
    {
    thisLOD += 1;
    parent = parent.parent;
    }
    }

    }

    IEnumerator Waiter()
    {
    yield return new WaitForSeconds(updateInterval);
    enabled = true;
    }

    private void Update()
    {
    LODDistanceShow = LODDistanceMultiply / 3f;

    SetLOD();
    DeactiveInstnaces();

    enabled = false;
    StartCoroutine(Waiter());
    }

    public void SetLOD()
    {
    Vector3 halfScale = AbsoluteScale(transform) * 0.5f;
    Vector3 center = transform.position + halfScale;

    Vector3 parentHalfScale;
    Vector3 parentCenter = Vector3.zero;

    if (transform.parent != null)
    {
    parentHalfScale = AbsoluteScale(transform.parent) * 0.5f;
    parentCenter = transform.parent.position + parentHalfScale;
    }

    Vector3 cameraPosition = Camera.main.gameObject.transform.position;
    {
    if (thisLOD > 0 && thisLOD > Mathf.CeilToInt(Mathf.Log(LODDistance / LODDistanceShow / (cameraPosition - parentCenter).magnitude, 2.1f)))
    {
    SgtFloatingOctree[] children = transform.parent.GetComponentsInChildren<SgtFloatingOctree>();
    int count = children.Length;
    for (int i = 0; i < count; i++) children.isCurrentLOD = false;

    transform.parent.GetComponent<SgtFloatingOctree>().IsCurrentLOD = true;
    }
    else if (thisLOD < maxLOD && thisLOD < Mathf.CeilToInt(Mathf.Log(LODDistance / LODDistanceShow / (cameraPosition - center).magnitude, 2.3f)))
    {
    if (transform.childCount == 0)
    {
    IsCurrentLOD = false;

    if (transform.childCount == 0)
    {
    for (int i = 0; i < 8; i++)
    {
    Vector3 instancePosition = transform.position;
    instancePosition.x += halfScale.x * octreePositions.x;
    instancePosition.y += halfScale.y * octreePositions.y;
    instancePosition.z += halfScale.z * octreePositions.z;

    BuildNewNode(instancePosition);
    }
    }
    }
    else
    {

    SgtFloatingOctree[] children = transform.GetComponentsInChildren<SgtFloatingOctree>();
    int count = children.Length;
    for (int i = 0; i < count; i++) children.isCurrentLOD = true;

    IsCurrentLOD = false;
    }
    }
    }
    }

    public void DeactiveInstnaces()
    {
    var floatingCamera = SgtFloatingCamera.Instances.First.Value;

    for (int i = 0; i < instances.Count; i++)
    {
    var distance = SgtPosition.SqrDistance(instances.Position, floatingCamera.Position);

    if(distance > range)
    {
    instances.gameObject.SetActive(false);
    }
    else
    {
    instances.gameObject.SetActive(true);
    }
    }
    }
    }

    I am making my own Spawn System using Octree (just for fun I called it SGT Floating Octree). I want that the Octree should work with Floating Origin, its working but the disabling and enabling system doesnt work really... With Vector3.Distance work good, but why it doesnt work with SgtPosition.Distance and what is the different between SgtPosition.Distance and SgtPosition.SqrDistance?
     
    Last edited: Jan 31, 2023
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    No idea, never seen this error before. Could you try making a new project and seeing if the error appears for you? If not, try adding the packages you have one at a time until it appears and let me know exactly which one caused the error to appear.


    SqrDistance (square distance) is Distance*Distance. The square is calculated first, and then Distance can be calculated from it using sqrt. Sqrt is fairly expensive, and some types of code like checking if one distance is closer than another doesn't require the actual distance, so it's useful to have both.
     
  49. Darkcoder

    Darkcoder

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

    In continuation of the Modular Backgrounds asset series, I introduce:

    Cover.png

    This asset allows you to place highly detailed nebulas in the background of your scene.

    Just like with the previous Orbit asset, I've added an extra spicy discount for existing customers of SGT. This discount will expire in 2 weeks.

    p.s. if you decide to buy this or have bought Orbit, please write a review. Even if you think it's garbage and give it 1 star you will help me out, thanks!
     
    dmenefee and hjohnsen like this.
  50. Pabi

    Pabi

    Joined:
    Feb 13, 2016
    Posts:
    48

    I created a new project without DOTS and now it's working fine.

    I'm testing the earth size planet on mobile and I was wondering if you got any hints to improve performance? It work correctly on my samsung s20 ultra but lag a lot on an older device. Is it possible to have better performance? My project needs to work on mobile so I'm testing before using it.

    OH yeah, on android, I have a glitch in a shader I think? here a picture