Search Unity

Space Graphics Toolkit & Planets

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

  1. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Hey the Space Graphics Planets link is broken :p

    Noob question> I want to create my own planet terrain, is there a guide on how to make the material you use in PlanetHD ? Perhaps a tutorial.
     
    Last edited: Mar 15, 2021
  2. Hellgeist

    Hellgeist

    Joined:
    Feb 13, 2017
    Posts:
    15
    Git gud.
     
  3. Oxlamon

    Oxlamon

    Joined:
    Mar 19, 2015
    Posts:
    3
    Hi, just want to share quick and dirty fix for support HDRP light layers.

    i'am using this snipped for any material property block change and before any Graphics.DrawMesh to enable HDRP light layers.

    Code (CSharp):
    1. int flags = 1 << 7; // enable light level #7
    2. float flagsFloat = System.BitConverter.ToSingle( System.BitConverter.GetBytes( flags ), 0 );
    3. Vector4 v = new Vector4( flagsFloat, 0, 0, 0 );
    4. properties.SetVector( Shader.PropertyToID( "unity_RenderingLayer" ), v );
    I hope author add supporting light layers to the framework very soon. (or unity team add api for this setting into Graphics.DrawMesh)


    Other materials:
    LightLayers with Instanced rendering

    p.s. unity 2020.2.3f1, hdrp: 10.2.2
     
  4. AkhaSkull

    AkhaSkull

    Joined:
    Mar 6, 2014
    Posts:
    10
    Hello Sir Wilkes. :)

    I would simulate excentricity and precession of orbits.
    Problem : SgtFloatingOrbit is relative to its parentPoint who is always the center of the orbit (circular or elliptical).
    I think to do a derivated class from SgtFloatingOrbit but i'm not sure that is the best way to achieve that.

    An (or more) idea(s) ? :)
    Thank you.
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Thanks, fixed!

    The texture was made using Grand Designer on Steam. The material settings were made by tweaking them one at a time until they looked good. There is no real magic technique to be learned, just mess with the settings and see some of the example planets :D

    Thanks, I had no idea it was possible to set the rendering layer like this. I'll see what I can do in the next version!


    This component wasn't designed with extensibility in mind, so I recommend you modify or duplicate&rename it.
     
  6. CosmicStud

    CosmicStud

    Joined:
    Jun 13, 2017
    Posts:
    55
    Awesome update! Loving the new night textures! Just wondering will they fade when facing the light in new update!!! Or can I accomplish that somehow... ;)
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Thanks! If your planet is rendered with the SgtPlanet component then the night lights should automatically update with your main scene light, assuming it has the SgtLight component attached. This only works with one light though. I plan to rewrite the lighting & shadow system some time to make it more flexible, and at this time you may have more options.
     
    CosmicStud likes this.
  8. DethKwok

    DethKwok

    Joined:
    Mar 13, 2017
    Posts:
    15
    How modular are the features in this? Example, If I make my own procedural terrain system, can I add atmospheric scattering, lighting, etc. from this package to it? Also, how customizable is the atmosphere settings in terms of colors?
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Fairly modular. The atmosphere system gives you access to the atmosphere material, which can be applied on top of your terrain material. This is how the atmosphere can work with the SgtPlanet and SgtTerrainPlanet components, which are completely separate. The atmosphere colors are also highly customizable, giving you access to the color at the horizon, at the azimuth, on the ground, and also separate colors for the sunset and light scattering.
     
  10. DethKwok

    DethKwok

    Joined:
    Mar 13, 2017
    Posts:
    15
    Hey so I bought the asset, its pretty awesome.

    One thing I noticed is that there is an excessive amount of back scattering when near the sunset/sunrise line of the atmosphere, resulting in a phantom glow in the opposite side of the light source. One might confuse it for another sun or light source, when none exists in that direction.

    Investigating the shader, I found that when calculating Mei/RayleighPhase in both AtmosphereInner/Outer Shaders, negative data is lost from 'angle', as the result is always positive, resulting in double scattering. In the final scattering calculations, I added ' * (angle > 0 ? 1 : -1) '
    and it gave me the desired effect for me, here's a video of before/after:



    I believe this looks more realistic, and maybe you can incorporate this into your future updates :)
     
    hopeful likes this.
  11. dmenefee

    dmenefee

    Joined:
    Oct 14, 2019
    Posts:
    142
    Hello! I’m just getting started with SGT, and have some questions regarding gravity physics. Can a spacecraft simulate the effect of gravitational “slingshot” acceleration? This is basically modeling a hyperbolic orbit if I understand it correctly. Also, could I add an intense gravimetric simulation to a black hole? I didn’t see gravity in the BH demos...

    My goal is to provide a space racing course with artificial singularities that can be used (carefully!) for spacecraft acceleration.

    thanks for an amazing asset!
     
  12. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Rayleigh scattering is the same in both directions, which is why its symmetrical in SGT (see HERE). I suppose I could add some kind of bias setting to give more artistic control though.


    The gravity components allow you to implement Newtonian gravity, which should include slingshots and black holes (minus any relativistic effects). The only limitation might be scene scale, because these components work using Unity's physics velocity, which can lose precision at extreme scales. In general this should be sufficient though.
     
    DethKwok and dmenefee like this.
  13. DethKwok

    DethKwok

    Joined:
    Mar 13, 2017
    Posts:
    15
    That's interesting, I haven't studied the topic. Would be an interesting option for aesthetic purposes, thanks for considering :)
     
    Darkcoder likes this.
  14. dmenefee

    dmenefee

    Joined:
    Oct 14, 2019
    Posts:
    142
    Thank you! That’s excellent. I’m very excited to work with the SGT.
     
    Darkcoder likes this.
  15. DethKwok

    DethKwok

    Joined:
    Mar 13, 2017
    Posts:
    15
    upload_2021-3-22_9-50-51.png
    I am getting this error regarding terrain in Unity 2020.3.0 in the Features/Terrain Scenes.

    I have no other packages/scripts loaded, just all SGT

    I have no unity console errors or warnings
     
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You must import the Burst package if you want to use the terrain features. There's more detailed info in the docs HERE.
     
    JFI66 and DethKwok like this.
  17. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    @Darkcoder nice update.

    however gradient colors and textures seem to be broken with terrain planet water or may there is new parameters to use for water not being grey ?

    i'm trying to make a starfield infinite spawner componants and having some difficulties :
    for now :
    working around a while with SgtFloatingSpaner and SgtStarfieldInfinite, i finaly choose to fork SgtFloatingSpawner to make it compatible with SgtStarfield Infinite instead of SgtFloatingObject

    its actualy listening for SgtFloatingCamera.OnSnap
    grab all vertices from starfield mesh to reconstruct the List<SgtStarfieldstar> stars
    check each stars to pull them on a toSpawn list if they are inRange (inRange always return true for the moment)
    spawn each stars in the toSpawn list
    clear the toSpawn list

    as we canot use SgtFloatingObject alongside with SgtStarfieldInfinite i'm not able to retrieve the SgtPosition of SgtStarfieldInfinite so i can't calculate the correct position to spawn stars nether be able to check properly if a star is in the spawn range.

    to be able to grab the mesh from SgtStarfield i have added a simple public method GetMesh() that return the mesh

    here is my SgtStarfieldInfiniteSpawner very dirty code, can you help me pointing on the right way ?
    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections.Generic;
    3. using FSA = UnityEngine.Serialization.FormerlySerializedAsAttribute;
    4.  
    5. namespace SpaceGraphicsToolkit
    6. {
    7.  
    8.     /// <summary>This is the base class for all starfield infinite spawners, providing a useful methods for spawning and handling prefabs.</summary>
    9.     [RequireComponent(typeof(SgtStarfieldInfinite))]
    10.     public class SgtStarfieldInfiniteSpawner: MonoBehaviour
    11.     {
    12.         /// <summary>This allows you to set the random seed used during procedural generation. If this object is spawned from an <b>SgtFloatingSpawner___</b> component, then this will automatically be set.</summary>
    13.         public int Seed { set { seed = value; } get { return seed; } } [FSA("Seed")] [SerializeField] [SgtSeed] private int seed;
    14.  
    15.         /// <summary>This is the starfield on witch we want spawn objects.</summary>
    16.         public SgtStarfieldInfinite Target { set { target = value; } get { return target; } } [FSA("Target")] [SerializeField] private SgtStarfieldInfinite target;
    17.  
    18.         /// <summary>The camera must be within this range for this spawner to activate.</summary>
    19.         public SgtLength Range { set { range = value; } get { return range; } } [FSA("Range")] [SerializeField] private SgtLength range = new SgtLength(1.0, SgtLength.ScaleType.AU);
    20.  
    21.         /// <summary>If you want to define prefabs externally, then you can use the SgtSpawnList component with a matching Category name.</summary>
    22.         public string Category { set { category = value; } get { return category; } } [FSA("Category")] [SerializeField] private string category;
    23.  
    24.         /// <summary>If you aren't using a spawn list category, or just want to augment the spawn list, then define the prefabs you want to spawn here.</summary>
    25.         public List<SgtFloatingObject> Prefabs { get { if (prefabs == null) prefabs = new List<SgtFloatingObject>(); return prefabs; } } [FSA("Prefabs")] [SerializeField] private List<SgtFloatingObject> prefabs;
    26.  
    27.         /// <summary>If you disable this then the spawned object will use the same prefab as the spawn index.</summary>
    28.         public bool RandomizeIndex { set { randomizeIndex = value; } get { return randomizeIndex; } } [SerializeField] private bool randomizeIndex = true;
    29.  
    30.         private static List<SgtFloatingObject> tempPrefabs = new List<SgtFloatingObject>();
    31.  
    32.         private List<SgtStarfieldStar> stars = new List<SgtStarfieldStar>();
    33.  
    34.         [SerializeField]
    35.         private List<SgtFloatingObject> instances;
    36.  
    37.         [System.NonSerialized]
    38.         private SgtFloatingObject cachedObject;
    39.  
    40.         [System.NonSerialized]
    41.         private bool cachedObjectSet;
    42.  
    43.         /// <summary>The <b>SgtFloatingObject</b> component alongside this component.</summary>
    44.         public SgtFloatingObject CachedObject
    45.         {
    46.             get
    47.             {
    48.                 if (cachedObjectSet == false)
    49.                 {
    50.                     cachedObject    = GetComponent<SgtFloatingObject>();
    51.                     cachedObjectSet = true;
    52.                 }
    53.  
    54.                 return cachedObject;
    55.             }
    56.         }
    57.  
    58.         private bool busy = false;
    59.  
    60.         [System.NonSerialized]
    61.         private Mesh mesh;
    62.  
    63.         protected virtual void OnEnable()
    64.         {
    65.  
    66.             SgtFloatingCamera.OnSnap += UpdateSpawnList;
    67.         }
    68.  
    69.         protected virtual void OnDisable()
    70.         {
    71.             SgtFloatingCamera.OnSnap -= UpdateSpawnList;
    72.      
    73.             DespawnAll();
    74.         }
    75.  
    76.         protected bool BuildSpawnList()
    77.         {
    78.             if (instances == null)
    79.             {
    80.                 instances = new List<SgtFloatingObject>();
    81.             }
    82.  
    83.             tempPrefabs.Clear();
    84.  
    85.             if (string.IsNullOrEmpty(category) == false)
    86.             {
    87.                 var spawnList = SgtSpawnList.FirstInstance;
    88.  
    89.                 while (spawnList != null)
    90.                 {
    91.                     if (spawnList.Category == category)
    92.                     {
    93.                         BuildSpawnList(spawnList.Prefabs);
    94.                     }
    95.  
    96.                     spawnList = spawnList.NextInstance;
    97.                 }
    98.             }
    99.  
    100.             BuildSpawnList(prefabs);
    101.  
    102.             return tempPrefabs.Count > 0;
    103.         }
    104.  
    105.         protected SgtFloatingObject SpawnAt(SgtPosition position, int index)
    106.         {
    107.             if (tempPrefabs.Count > 0)
    108.             {
    109.                 if (randomizeIndex == true)
    110.                 {
    111.                     index = Random.Range(0, tempPrefabs.Count);
    112.                 }
    113.                 else
    114.                 {
    115.                     index %= tempPrefabs.Count;
    116.                 }
    117.  
    118.                 var prefab = tempPrefabs[index];
    119.  
    120.                 if (prefab != null)
    121.                 {
    122.                     var oldSeed        = prefab.Seed;
    123.                     var oldPosition    = prefab.Position;
    124.                     var oldPositionSet = prefab.PositionSet;
    125.  
    126.                     prefab.Seed        = Random.Range(int.MinValue, int.MaxValue);
    127.                     prefab.Position    = position;
    128.                     prefab.PositionSet = true;
    129.  
    130.                     var instance = Instantiate(prefab, SgtFloatingRoot.Root);
    131.  
    132.                     prefab.Seed        = oldSeed;
    133.                     prefab.Position    = oldPosition;
    134.                     prefab.PositionSet = oldPositionSet;
    135.  
    136.                     instances.Add(instance);
    137.  
    138.                     instance.InvokeOnSpawn();
    139.  
    140.                     return instance;
    141.                 }
    142.             }
    143.  
    144.             return null;
    145.         }
    146.  
    147.         private void DespawnAll()
    148.         {
    149.             if (instances != null)
    150.             {
    151.                 for (var i = instances.Count - 1; i >= 0; i--)
    152.                 {
    153.                     var instance = instances[i];
    154.  
    155.                     if (instance != null)
    156.                     {
    157.                         SgtHelper.Destroy(instance.gameObject);
    158.                     }
    159.                 }
    160.  
    161.                 instances.Clear();
    162.             }
    163.         }
    164.  
    165.  
    166.  
    167.         private static void BuildSpawnList(List<SgtFloatingObject> floatingObjects)
    168.         {
    169.             if (floatingObjects != null)
    170.             {
    171.                 for (var i = floatingObjects.Count - 1; i >= 0; i--)
    172.                 {
    173.                     var floatingObject = floatingObjects[i];
    174.  
    175.                     if (floatingObject != null)
    176.                     {
    177.                         tempPrefabs.Add(floatingObject);
    178.                     }
    179.                 }
    180.             }
    181.         }
    182.  
    183.         private void UpdateSpawnList(SgtFloatingCamera floatingCamera, Vector3 delta)
    184.         {
    185.             if (!busy)
    186.             {
    187.                 Debug.Log(message: "Look for stuf to spawn");
    188.                 busy = true;
    189.                 var targetPosition = target.transform.position + delta;
    190.  
    191.                 mesh = target.GetMesh();
    192.  
    193.                 var positions = mesh.vertices;
    194.                 var colors = mesh.colors;
    195.                 var normals = mesh.normals;
    196.                 var tangents = mesh.tangents;
    197.                 var coords1 = mesh.uv;
    198.                 var coords2 = mesh.uv2;
    199.                 var indices = mesh.triangles;
    200.                 var minMaxSet = false;
    201.                 var min = default(Vector3);
    202.                 var max = default(Vector3);
    203.                 var count = positions.Length / 4;
    204.                 Debug.Log(message: "nombre de vertices" + count.ToString());
    205.  
    206.                 for (var i = 0; i < count; i++)
    207.                 {
    208.                     var offV = i * 4;
    209.                     var offI = i * 6;
    210.                     var position = positions[offV];
    211.                     var star = new SgtStarfieldStar();
    212.  
    213.                     if (InRange(position))
    214.                     {
    215.                         star.Angle = normals[offV].z;
    216.                         star.Color = colors[offV];
    217.                         star.Position = position;
    218.                         star.Radius = coords2[offV].x;
    219.                         star.Variant = (int) coords1[offV].x;
    220.                         star.PulseOffset = tangents[offV].x;
    221.                         star.PulseRange = tangents[offV].z;
    222.                         star.PulseSpeed = tangents[offV].y;
    223.                         ToSpawn(star);
    224.                     }
    225.  
    226.                     //var star = SgtPoolClass<SgtStarfieldStar>.Pop() ?? new SgtStarfieldStar();
    227.  
    228.                     /*star.Variant     = Random.Range(int.MinValue, int.MaxValue);
    229.                     star.Color       = starColors.Evaluate(Random.value);
    230.                     star.Radius      = Mathf.Lerp(starRadiusMin, starRadiusMax, Mathf.Pow(Random.value, starRadiusBias));
    231.                     star.Angle       = Random.Range(-180.0f, 180.0f);
    232.                     star.Position    = new Vector3(x, y, z);
    233.                     star.PulseRange  = Random.value * starPulseMax;
    234.                     star.PulseSpeed  = Random.value;
    235.                     star.PulseOffset = Random.value;*/
    236.                 }
    237.                 Debug.Log("check ended");
    238.                 busy = false;
    239.             }
    240.         }
    241.  
    242.         private void ToDespawn(Vector3 position)
    243.         {
    244.             throw new System.NotImplementedException();
    245.         }
    246.  
    247.         private void ToSpawn(SgtStarfieldStar star)
    248.         {
    249.             var parentPoint = target;
    250.             var toSpawn = new List<SgtStarfieldStar>();
    251.             if (stars.Count == 0)
    252.             {
    253.                 stars.Add(star);
    254.                 toSpawn.Add(star);
    255.             }
    256.             else
    257.             {
    258.                 for (int i = 0; i < stars.Count; i++)
    259.                 {
    260.                     if (!star.Position.Equals(stars[i].Position))
    261.                     {
    262.                         stars.Add(star);
    263.                         toSpawn.Add(star);
    264.                     }
    265.                 }
    266.             }
    267.  
    268.             for (int i = 0;i< toSpawn.Count;i++)
    269.             {
    270.                 var position = parentPoint.Position;
    271.                 var clone = SpawnAt(position, i + stars.Count - 1);
    272.             }
    273.         }
    274.  
    275.         private bool InRange(Vector3 position)
    276.         {
    277.      
    278.             return true;
    279.         }
    280.  
    281.  
    282.     }
    283. }
    284.  
    285. #if UNITY_EDITOR
    286. namespace SpaceGraphicsToolkit
    287. {
    288.     using UnityEditor;
    289.  
    290.     [CanEditMultipleObjects]
    291.     [CustomEditor(typeof(SgtStarfieldInfiniteSpawner))]
    292.    public class SgtStarfieldInfiniteSpawner_Editor : SgtEditor<SgtStarfieldInfiniteSpawner>
    293.    {
    294.        protected override void OnInspector()
    295.        {
    296.            if (SgtFloatingRoot.InstanceCount == 0)
    297.            {
    298.                if (HelpButton("Your scene contains no SgtFloatingRoot component, so all spawned SgtFloatingSpawnable prefabs will be placed in the scene root.", MessageType.Warning, "Add", 35.0f) == true)
    299.                {
    300.                    new GameObject("Floating Root").AddComponent<SgtFloatingRoot>();
    301.                }
    302.  
    303.                Separator();
    304.            }
    305.  
    306.            Draw("target", "specify witch starfield we use for spawning prefabs");
    307.  
    308.            var missing = true;
    309.  
    310.            if (Any(t => string.IsNullOrEmpty(t.Category) == false))
    311.            {
    312.                missing = false;
    313.            }
    314.  
    315.            if (Any(t => t.Prefabs != null && t.Prefabs.Count > 0))
    316.            {
    317.                missing = false;
    318.            }
    319.  
    320.            Draw("range", "The camera must be within this range for this spawner to activate.");
    321.            BeginError(missing);
    322.            Draw("category", "If you want to define prefabs externally, then you can use the SgtSpawnList component with a matching Category name.");
    323.            EndError();
    324.            Draw("randomizeIndex", "If you disable this then the spawned object will use the same prefab as the spawn index.");
    325.            BeginError(missing);
    326.            Draw("prefabs", "If you aren't using a spawn list category, or just want to augment the spawn list, then define the prefabs you want to spawn here.");
    327.            EndError();
    328.    
    329.    
    330.        }
    331.    }
    332. }
    333. #endif

    i worked a bit more while still not found the method to handle position and range properly.
    also i discovered a strange behavior where spawner doesnt care about new stars outside of the initial starfield...
    Captureinfinite spawn.JPG

    here is the updated code

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3. using System.Collections.Generic;
    4. using FSA = UnityEngine.Serialization.FormerlySerializedAsAttribute;
    5.  
    6. namespace SpaceGraphicsToolkit
    7. {
    8.  
    9.     /// <summary>This is the base class for all starfield infinite spawners, providing a useful methods for spawning and handling prefabs.</summary>
    10.     [RequireComponent(typeof(SgtStarfieldInfinite))]
    11.     [AddComponentMenu(SgtHelper.ComponentMenuPrefix + "Starfield Infinite Spawner")]
    12.     public class SgtStarfieldInfiniteSpawner: MonoBehaviour
    13.     {
    14.         /// <summary>This allows you to set the random seed used during procedural generation. If this object is spawned from an <b>SgtFloatingSpawner___</b> component, then this will automatically be set.</summary>
    15.         public int Seed { set { seed = value; } get { return seed; } } [FSA("Seed")] [SerializeField] [SgtSeed] private int seed;
    16.      
    17.         /// <summary>This is the starfield on witch we want spawn objects.</summary>
    18.         public SgtStarfieldInfinite Target { set { target = value; } get { return target; } } [FSA("Target")] [SerializeField] private SgtStarfieldInfinite target;
    19.  
    20.         /// <summary>The camera must be within this range for this spawner to activate.</summary>
    21.         public SgtLength Range { set { range = value; } get { return range; } } [FSA("Range")] [SerializeField] private SgtLength range = new SgtLength(1.0, SgtLength.ScaleType.AU);
    22.      
    23.         /// <summary>If you want to define prefabs externally, then you can use the SgtSpawnList component with a matching Category name.</summary>
    24.         public string Category { set { category = value; } get { return category; } } [FSA("Category")] [SerializeField] private string category;
    25.  
    26.         /// <summary>If you aren't using a spawn list category, or just want to augment the spawn list, then define the prefabs you want to spawn here.</summary>
    27.         public List<SgtFloatingObject> Prefabs { get { if (prefabs == null) prefabs = new List<SgtFloatingObject>(); return prefabs; } } [FSA("Prefabs")] [SerializeField] private List<SgtFloatingObject> prefabs;
    28.  
    29.         /// <summary>If you disable this then the spawned object will use the same prefab as the spawn index.</summary>
    30.         public bool RandomizeIndex { set { randomizeIndex = value; } get { return randomizeIndex; } } [SerializeField] private bool randomizeIndex = true;
    31.  
    32.         private List<SgtStarfieldStar> stars = new List<SgtStarfieldStar>();
    33.         private List<SgtStarfieldStar> starsToSpawn = new List<SgtStarfieldStar>();
    34.      
    35.         private static List<SgtFloatingObject> tempPrefabs = new List<SgtFloatingObject>();
    36.  
    37.         [SerializeField]
    38.         private List<SgtFloatingObject> instances;
    39.      
    40.         [System.NonSerialized]
    41.         private SgtFloatingObject cachedObject;
    42.  
    43.         [System.NonSerialized]
    44.         private bool cachedObjectSet;
    45.  
    46.         /// <summary>The <b>SgtFloatingObject</b> component alongside this component.</summary>
    47.         public SgtFloatingObject CachedObject
    48.         {
    49.             get
    50.             {
    51.                 if (cachedObjectSet == false)
    52.                 {
    53.                     cachedObject    = GetComponent<SgtFloatingObject>();
    54.                     cachedObjectSet = true;
    55.                 }
    56.  
    57.                 return cachedObject;
    58.             }
    59.         }
    60.      
    61.         private bool spawnIsBusy = false;
    62.      
    63.         [System.NonSerialized]
    64.         private Mesh mesh;
    65.  
    66.         protected virtual void OnEnable()
    67.         {
    68.  
    69.             SgtFloatingCamera.OnSnap += UpdateStarsToSpawnList;
    70.         }
    71.  
    72.         protected virtual void OnDisable()
    73.         {
    74.             SgtFloatingCamera.OnSnap -= UpdateStarsToSpawnList;
    75.          
    76.             DespawnAll();
    77.         }
    78.  
    79.         protected bool BuildSpawnList()
    80.         {
    81.             if (instances == null)
    82.             {
    83.                 instances = new List<SgtFloatingObject>();
    84.             }
    85.  
    86.             tempPrefabs.Clear();
    87.  
    88.             if (string.IsNullOrEmpty(category) == false)
    89.             {
    90.                 var spawnList = SgtSpawnList.FirstInstance;
    91.  
    92.                 while (spawnList != null)
    93.                 {
    94.                     if (spawnList.Category == category)
    95.                     {
    96.                         BuildSpawnList(spawnList.Prefabs);
    97.                     }
    98.  
    99.                     spawnList = spawnList.NextInstance;
    100.                 }
    101.             }
    102.  
    103.             BuildSpawnList(prefabs);
    104.  
    105.             return tempPrefabs.Count > 0;
    106.         }
    107.      
    108.         protected SgtFloatingObject SpawnAt(SgtPosition position, int index)
    109.         {
    110.             if (tempPrefabs.Count > 0)
    111.             {
    112.                 if (randomizeIndex == true)
    113.                 {
    114.                     index = Random.Range(0, tempPrefabs.Count);
    115.                 }
    116.                 else
    117.                 {
    118.                     index %= tempPrefabs.Count;
    119.                 }
    120.  
    121.                 var prefab = tempPrefabs[index];
    122.  
    123.                 if (prefab != null)
    124.                 {
    125.                     var oldSeed        = prefab.Seed;
    126.                     var oldPosition    = prefab.Position;
    127.                     var oldPositionSet = prefab.PositionSet;
    128.  
    129.                     prefab.Seed        = Random.Range(int.MinValue, int.MaxValue);
    130.                     prefab.Position    = position;
    131.                     prefab.PositionSet = true;
    132.  
    133.                     var instance = Instantiate(prefab, SgtFloatingRoot.Root);
    134.  
    135.                     prefab.Seed        = oldSeed;
    136.                     prefab.Position    = oldPosition;
    137.                     prefab.PositionSet = oldPositionSet;
    138.  
    139.                     instances.Add(instance);
    140.  
    141.                     instance.InvokeOnSpawn();
    142.  
    143.                     return instance;
    144.                 }
    145.             }
    146.  
    147.             return null;
    148.         }
    149.  
    150.         private void DespawnAll()
    151.         {
    152.             if (instances != null)
    153.             {
    154.                 for (var i = instances.Count - 1; i >= 0; i--)
    155.                 {
    156.                     var instance = instances[i];
    157.  
    158.                     if (instance != null)
    159.                     {
    160.                         SgtHelper.Destroy(instance.gameObject);
    161.                     }
    162.                 }
    163.  
    164.                 instances.Clear();
    165.             }
    166.         }
    167.      
    168.         private static void BuildSpawnList(List<SgtFloatingObject> floatingObjects)
    169.         {
    170.             if (floatingObjects != null)
    171.             {
    172.                 for (var i = floatingObjects.Count - 1; i >= 0; i--)
    173.                 {
    174.                     var floatingObject = floatingObjects[i];
    175.  
    176.                     if (floatingObject != null)
    177.                     {
    178.                         tempPrefabs.Add(floatingObject);
    179.                     }
    180.                 }
    181.             }
    182.         }
    183.  
    184.         private void UpdateStarsToSpawnList(SgtFloatingCamera floatingCamera, Vector3 delta)
    185.         {
    186.             if (!spawnIsBusy)
    187.             {
    188.                 BuildSpawnList();
    189.      
    190.                 Debug.Log(message: "Look for stuf to spawn");
    191.                 spawnIsBusy = true;
    192.  
    193.              
    194.                 var targetPosition = target.transform.position + delta;
    195.  
    196.                 mesh = target.GetMesh();
    197.  
    198.                 var positions = mesh.vertices;
    199.                 var colors = mesh.colors;
    200.                 var normals = mesh.normals;
    201.                 var tangents = mesh.tangents;
    202.                 var coords1 = mesh.uv;
    203.                 var coords2 = mesh.uv2;
    204.                 var indices = mesh.triangles;
    205.                 //var minMaxSet = false;
    206.                 //var min = default(Vector3);
    207.                 //var max = default(Vector3);
    208.                 var count = positions.Length / 4;
    209.                 Debug.Log(message: "nombre de vertices" + count.ToString());
    210.  
    211.                 for (var i = 0; i < count; i++)
    212.                 {
    213.                     var offV = i * 4;
    214.                     var offI = i * 6;
    215.                     var position = positions[offV];
    216.                     var star = new SgtStarfieldStar();
    217.  
    218.                     if (InRange(position))
    219.                     {
    220.                         star.Angle = normals[offV].z;
    221.                         star.Color = colors[offV];
    222.                         star.Position = position;
    223.                         star.Radius = coords2[offV].x;
    224.                         star.Variant = (int) coords1[offV].x;
    225.                         star.PulseOffset = tangents[offV].x;
    226.                         star.PulseRange = tangents[offV].z;
    227.                         star.PulseSpeed = tangents[offV].y;
    228.                         AddStarToSpawn(star);
    229.                     }
    230.                 }
    231.  
    232.                 for (int i = 0; i < stars.Count; i++)
    233.                 {
    234.                     if (!InRange(stars[i].Position))
    235.                     {
    236.                         StarDespawn(stars[i]);
    237.                     }
    238.                 }
    239.  
    240.                 Debug.Log("check ended");
    241.                 for (int i = 0; i < starsToSpawn.Count ; i++)
    242.                 {
    243.                     StarSpawn(starsToSpawn[i],i+stars.Count);
    244.                     stars.Add(starsToSpawn[i]);
    245.                 }
    246.                 starsToSpawn.Clear();
    247.                 spawnIsBusy = false;
    248.              
    249.             }
    250.         }
    251.  
    252.         private void AddStarToSpawn(SgtStarfieldStar star)
    253.         {
    254.             bool toAdd = true;
    255.  
    256.             for (int i = 0; i < stars.Count; i++)
    257.             {
    258.                 if (star.Position.Equals(stars[i].Position))
    259.                 {
    260.                     toAdd = false;
    261.                 }
    262.             }
    263.          
    264.             for (int i = 0; i < starsToSpawn.Count; i++)
    265.             {
    266.                 if (star.Position.Equals(starsToSpawn[i].Position))
    267.                 {
    268.                     toAdd = false;
    269.                 }
    270.             }
    271.          
    272.             if (toAdd)
    273.             {
    274.                 starsToSpawn.Add(star);
    275.             }
    276.         }
    277.  
    278.         private void StarSpawn(SgtStarfieldStar newStar, int index)
    279.         {
    280.  
    281.                 var floatingCamera = SgtFloatingCamera.Instances.First.Value;
    282.                 var position = new SgtPosition();
    283.                 position.GlobalX = floatingCamera.Position.GlobalX;
    284.                 position.GlobalY = floatingCamera.Position.GlobalY;
    285.                 position.GlobalZ = floatingCamera.Position.GlobalZ;
    286.                 position.LocalX = floatingCamera.Position.LocalX + newStar.Position.x;
    287.                 position.LocalY = floatingCamera.Position.LocalY + newStar.Position.y;
    288.                 position.LocalZ = floatingCamera.Position.LocalZ + newStar.Position.z;
    289.                 var clone = SpawnAt(position, index + stars.Count);
    290.                 //TODO personalise the clone instance of the spawned star
    291.         }
    292.      
    293.      
    294.         private void StarDespawn(SgtStarfieldStar i)
    295.         {
    296.             throw new System.NotImplementedException();
    297.         }
    298.  
    299.         private bool InRange(Vector3 position)
    300.         {
    301.          
    302.          
    303.             return true;
    304.         }
    305.      
    306.      
    307.     }
    308. }
    309.  
    310. #if UNITY_EDITOR
    311. namespace SpaceGraphicsToolkit
    312. {
    313.     using UnityEditor;
    314.  
    315.     [CanEditMultipleObjects]
    316.     [CustomEditor(typeof(SgtStarfieldInfiniteSpawner))]
    317.    public class SgtStarfieldInfiniteSpawner_Editor : SgtEditor<SgtStarfieldInfiniteSpawner>
    318.    {
    319.        protected override void OnInspector()
    320.        {
    321.            if (SgtFloatingRoot.InstanceCount == 0)
    322.            {
    323.                if (HelpButton("Your scene contains no SgtFloatingRoot component, so all spawned SgtFloatingSpawnable prefabs will be placed in the scene root.", MessageType.Warning, "Add", 35.0f) == true)
    324.                {
    325.                    new GameObject("Floating Root").AddComponent<SgtFloatingRoot>();
    326.                }
    327.  
    328.                Separator();
    329.            }
    330.  
    331.            Draw("target", "specify witch starfield we use for spawning prefabs");
    332.  
    333.            var missing = true;
    334.  
    335.            if (Any(t => string.IsNullOrEmpty(t.Category) == false))
    336.            {
    337.                missing = false;
    338.            }
    339.  
    340.            if (Any(t => t.Prefabs != null && t.Prefabs.Count > 0))
    341.            {
    342.                missing = false;
    343.            }
    344.  
    345.            Draw("range", "The camera must be within this range for this spawner to activate.");
    346.            BeginError(missing);
    347.            Draw("category", "If you want to define prefabs externally, then you can use the SgtSpawnList component with a matching Category name.");
    348.            EndError();
    349.            Draw("randomizeIndex", "If you disable this then the spawned object will use the same prefab as the spawn index.");
    350.            BeginError(missing);
    351.            Draw("prefabs", "If you aren't using a spawn list category, or just want to augment the spawn list, then define the prefabs you want to spawn here.");
    352.            EndError();
    353.        
    354.        
    355.        }
    356.    }
    357. }
    358. #endif
    359.  

    and finaly the zipped unity scene configuration
     

    Attached Files:

    Last edited: Mar 23, 2021
  18. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    i just realise may be im not taking the best wayt o achieve my final goal...

    i ask myself and you if it would be better to have a SgtSpawnfield that could be used to be declined the same way as SgtSarfield is (Box / Custom / Dome / Eliptical / Infinite / nebulae / Spiral) instead of just tweaking to add spawn behaviour to infinite starfields.

    this would allow to start with an infinite spawner that spawn smaller spawnfields or SgtFloatingSpawns

    i think with such new spawn feature it will be possible to handle a whole scale semi-realistic (at least credible even if fantasy) universe populated with all objects avalable in the SGT.

    so please if you have good advice to porperly doing it i would be very thanksfull.
    it also would be awesome if you integrate this as next new feature
     
    Last edited: Mar 23, 2021
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I removed the water features from SgtTerrainPlanet for now because I didn't like how it looked. I have some other ideas under development that will hopefully be out in one of the upcoming versions :)

    Regarding infinite starfields and spawning, your idea is certainly one way to go about it. Another is the Debris feature, which is designed to either randomly or procedurally spawn prefabs around the camera. I'm not sure if it works with the origin shifting system though, but it might be a better idea to look into modifying that approach rather than the infinite starfields, since the starfield 'infiniteness' is handled by the shader, and making it work backwards seems like you're making the task more difficult than it should be.

    The current 'intended' way to create a near infinite field of objects using the origin shifting system is to use nested spawners. For example, you spawn 10 objects at the root (perhaps even invisible objects), and when the camera gets within some range of this you spawn 10 more around that in a smaller radius, and recursively do this until you have the object density you require. This would require a bit of custom code to set up, and may have more overhead than other approaches, but it should be a fairly nice way to approach this. You could even implement this idea directly in code without using GameObjects except for the final 'leaf' spawning. This is kind of how the terrain LOD works.
     
    Last edited: Sep 24, 2022
  20. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    thanks @Darkcoder for those remarks

    i will check this side if i find inspiration and if its compatible with floating origin system

    already tried this but performances are massively lower and i have a bottle neck with distances .
    if i try to spawn in a radius over 597 parsec i'm flooded by "Invalid WorldAABB. Object is too large or to far away from the origin." errors
    to far for floating origin system.JPG
    when i warp to the edge i get same errors popping,
    those long distances errors are perf kill at factor 10 when triggered

    so even if i only chose 10 objects to spawn insted of 10 thousands i drop from 1200fps with tweaked starfields to 60fps with nested spawners.

    unfortunately starfield is unable to scale at such hight dimention beceause of unity engine limitations handling meshes, it's why i choose to start with starfieldsInfinite initialy.

    i need to think more about that and check what i can do with Debris before continue with starfields attempts

    for now terrain Planet seem to complex for me tu understand, or maybe i am laisy to investigate
     
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Those errors should only appear if you're trying to render an object at an extreme distance. There's no need to spawn a visible object in a radius of 597 parsecs, at this distance they should be invisible, and when approaching them they should spawn even more invisible objects, etc, until eventually within a reasonable range they become visible objects. Spawning 10,000 from one spawner is far too many, you should be thinking closer to 10, and then each of those can spawn 10 when you get closer, etc. Through the power of a tree structure this will give you effectively millions across the whole scene, while only having a few hundred at most loaded at once. A more optimal way to implement this would be the octree data structure, then you would have no overhead of all the spawners running at the same time.
     
  22. Zorkind

    Zorkind

    Joined:
    May 4, 2015
    Posts:
    55
    Oh man, sorry for the delay reading your reply, been busy :p

    Thanks for the tips tho i appreciate it :D
     
    Darkcoder likes this.
  23. S1m0np3t3r

    S1m0np3t3r

    Joined:
    Dec 22, 2016
    Posts:
    8
    Hi everybody,

    First of all, I have to say, this method is incredibly great, there are a lot of potential in it, but I've just schmoozing with it. I read this forum, and I saw, ones what created with it. I have a question: how can I implement the planet surface with texture tiling, instead of the whole surface texture? I need some help in it. :)
     
  24. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    The "Space Graphics Toolkit\Features\Planet" folder has planet examples. The "03 Detail" example shows you what adding detail maps can look like. This is done by editing the "DETAIL" section of the SGT / Planet shader.
     
    S1m0np3t3r likes this.
  25. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    ok thanks, i've fixed this errors poped by teemporarily disabling SgtFloating Scaler of stars prefabs until i find a way to get something for very larges and very distant objects

    i've also looked around debris Grid and will dig further lately
    after succeding managing all desired spawners i also will check for implementing some kind of procedural noise (may be fast noise based on the same named open lib) to handle spawn properties and or spawned prefabs properties... not clear enouth for now the way to design such a behaviour

    For now, as i made some progress with my starfieldinfinite spawner, i restarted with abstraction layer and lowered the size to 9.461e+18 meters per sides i will adjust size later as it work well with thoses values
    derivate an abstract SgtStarfieldSpawner from SgtStarfield to get a base SpawnFields
    then WIP rebuild all SgtStarfield Derivates for SgtStarfieldSpawner, starting with Box
    it should be compatible with floating origin system and nesting with others Sgt Spawners should be possible too.

    Using this approach, starfields with 10 thousands more visible stars may be rendered blazingly fast while only the few in a choosen range are instanciated as GameObjects (spawners). so i keep a high frame rate, with hight density of visible stars / points (or watherver else), all able to spawn any SgtFloating prefab, using only one instance of this new SgtStarfieldSpawner feature.

    actually Sgt cannot render big/far objects like M81 witch is one of the farest humanly visible objects identified for now at 3679216,7256 parsec, i assume in the deep space whe can see farther, i always keep the reflection for later on how to fake very far objects rendering
     
  26. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Hi @Darkcoder ,

    A minor bug: had to comment out the generic part of class inheritence in SgtSceneManager line 139 for v3.8.2 to compile; you probably missed that one.

    Thank you for SGT, it is an awesome tool. Do you have any plans to support procedural noise instead of noise textures for planet displacement? Or maybe a tool to create height textures for the planets procedurally from 3D noise?

    Cheers.
     
    JFI66 likes this.
  27. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    While not as fully featured, Unity's Mathematics package comes with various types of noise that perform very well when using Burst.

    Great that you got your component rendering at such a large size! Even this size should be enough. You should be able to somehow hook this into the origin shifting system to make its positioning snap with the camera so it's effectively never moving that far away.

    Later this year I plan to do a deeper dive on the Universe features to try and render some larger scale scenes, as the current examples only go up to like 50 lightyears I think. To render galaxies and beyond I imagine I will have to develop some new components and shaders to handle it, so it's a lot of work!

    SgtSceneManager was replaced with SgtDemo in the latest version, maybe the new version works, or your project has the old version, or both?

    The SgtTerrainPlanet component supports both heightmap and procedural height data. The Obsidian Planet demo scene is an example that is mostly procedural. This will of course generate the same kind of terrain everywhere, so the idea is that you create a kind of splat map with the Areas setting, so you can place different kinds of procedural terrain in different areas. It's not quite fully procedural, but then again making it fully procedural would also require a trillion more settings and months of development.
     
    Last edited: Sep 24, 2022
  28. LouskRad

    LouskRad

    Joined:
    Feb 18, 2014
    Posts:
    904
    Yes, then that's the problem as when upgrading from the asset store, the deleted files in the new package will not result in deleting the existing files from the previous version. Problem is, this results in the inability to compile upon upgrading. One way to deal with it is to leave the to-be-deleted file in the update package but comment out its contents.

    As for SGT terrain planets being able to use a procedural heightmap, I am aware of it. I did not mean terrains when I said planets; I meant SGT Planets. I don't want to use a quad tree setup for a far off planet since I don't need planetary landing and don't want to waste CPU resource for that. All I want is to use procedural heighmaps to send to the Planet shader - either with something like the simplex height generator that you have for SGT Terrains, or by some sort of texture generator. I was asking because if you have plans to implement this I will not work on it myself.
     
  29. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I thought I renamed the component to keep the same GUID, so it should carry over, but maybe I made a mistake.

    I see what you mean about the planet heights. The SgtPlanet component is designed to be as simple as possible for a mostly static mesh, so I don't plan to make anything like this. In my experience the SgtPlanet height displacement only looks good when the sphere is fairly high resolution, which would make it expensive to initialize in the first place. Therefore, if you need the planet to look displaced at a medium to far distance you may still be better of using SgtTerrainPlanet, unless perhaps your scene contains many planets.
     
  30. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    i have much difficulties to understand how to calculate distances with SgtPositions and make some computes / derivates betwen stored world positions and local positions (sgtPosition vs transform.position) on non game objects

    can you explain me ?
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You can use the SgtPosition.Distance method to get the distance between two positions in meters. You can use the SgtPosition.Vector method to get the Vector3 difference between two positions in meters. There are also some other helper methods in there.
     
  32. S1m0np3t3r

    S1m0np3t3r

    Joined:
    Dec 22, 2016
    Posts:
    8
    Hi, I bought the Space Graphics Planet pack, and I put it to near to a clean Space Graphics Toolkit, but I had this two error messages:

    · Assets\Space Graphics Toolkit\Features\Shared\Media\SgtSceneManager.cs(139,40): error CS0308: The non-generic type 'SgtEditor' cannot be used with type arguments
    · Assets\Space Graphics Toolkit\Features\Shared\Media\SgtSceneManager.cs(141,27): error CS0115: 'SgtSceneManager_Editor.OnInspector()': no suitable method found to override
     
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Try deleting the SgtSceneManager file it mentions. I will update Space Graphics Planets with the fix in the coming days.
     
  34. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    thanks ! yeah i was so stupid...
    ive found how to convert vector3 to SgtPosition (using transform.position to populate SgtPosition.LocalXYZ and call SnapLocal but not the reverse... i guess there is a method chain logic to do that but have not figured it out
     
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    There's currently no method to do the inverse of this. It could be done by copy+pasting the code for Distance, and instead of the sqrt part you just divide the xyz by the scale you want, and then output it as vector3. Just keep in mind float precision is far lower than double, so it may not be so useful in all scenarios.
     
  36. Ogmios850

    Ogmios850

    Joined:
    Sep 13, 2015
    Posts:
    1
    Loading in the package to a blank URP project in 2020 LTS.

    When opening any of the example scenes under "Packs" I get the following error in the console.

    A Native Collection has not been disposed, resulting in a memory leak. Enable Full StackTraces to get more details.

    Any ideas?
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    This issue is probably due to a hard to track down bug somewhere in the code for the SgtTerrainPlanet component. I think I've noticed it on scenes without this component though, so it may be coming from somewhere else too. I'll track it down eventually, but as far as I know it's more or less harmless so you can ignore it for now.
     
  38. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    sure thanks.

    im managing to get a copy off all starfield stars in a list and refresh it after each material / mesh updates
    im managing to handle the spawnable list at onSnap and update theyre spawn status and then handle instances creation destruction relatively to spawners status.

    i wrote bunch of codes trying to keep close with your way to code SGT
    im pretty close to obtain a good result but at the cost of acceptable performances.after rework to add status check on every existing stars.

    can i send you my WIP to get some recomendation and help for finishing that feature ?
     
    Last edited: Apr 2, 2021
  39. GillesLTB

    GillesLTB

    Joined:
    Nov 14, 2017
    Posts:
    3
    Is there a way to make jovian Gas Giants opaque?

    I'm using my own floating point origin system to generate an accurately sized universe, which works great, except jovians are transparent causing distant moons to be rendered in front when they should be occluded...

    I tried setting the Render Queue on SGTJovian to other values than Transparent(3000) but none of them do what I want (Geometry and AlphaTest makes the SGTBackdrop render on top, which is not what I want).

    I'm using the URP in 2020.3.0f1 with the latest version of the SGT.

    Here's an annotated screenshot that attempts to describe my problem:

    https://gyazo.com/b041226df4e51b93db4fe0c4f69a16c9

    Here's a screenshot of the same scene, but using my old Jupiter material, which does occlude.
    https://gyazo.com/1910357d59e572c18eba77270acd2e83
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Not right now, I'm way too busy to look at any other code!


    How are your distant moons being rendered? It sounds like those may be the issue.

    SgtJovian renders as a normal alpha blending transparent object that reads ZDepth (but not writes). This means it will render after solid geometry, and get occluded by it. For your moons to render in front they must not be writing depth, and they must be drawn after the jovian.

    You can look at the "Jovian" demo scene in the Basic Pack. It has the "Depth" child GameObject which makes it write depth so it can render correctly with the aurora, though it shouldn't be necessary.
     
  41. XyrisKenn

    XyrisKenn

    Joined:
    Dec 8, 2015
    Posts:
    92
    I recall perhaps a few versions back there was a planet shader option to blend additively a planet as if viewed in the sky.
    Might you recommend what to do in URP to produce a more blended result with Enviro skies?
    Thank you. :)
     

    Attached Files:

  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I don't recall there ever being a feature like this. For URP the planet shader was originally made using Shader Graph, which works very similarly to how it does now, except the detail/water/night rendering is a little different.
     
  43. S1m0np3t3r

    S1m0np3t3r

    Joined:
    Dec 22, 2016
    Posts:
    8
    I just got to know with the package, and I made this short video, which is based on one of the demonstration scene. Unfortunately I haven’t reach my goals with the real sized Earth, but the package works well with an 1000 metres diametered planet. In this video, you can see the Vegetation Engine, and some of my own models.



    This was just a short test, I wanted to see, what can do this package, and I’m pleased with it. Temporarily I can’t create the water surface at the real sized planets, or the location of the objects.
     
    Darkcoder likes this.
  44. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    I think I am on the right direction for a real Mars sized planet:

     
    Darkcoder and XyrisKenn like this.
  45. Wawwaa

    Wawwaa

    Joined:
    Sep 30, 2017
    Posts:
    165
    I have a question about SgtTerrainPrefabSpawner (not the project I made the video above, a different one). I use 7-8 instances of this class to decorate the planet with foliage and buildings. In profiler, I get significant peaks. The profiler indicates 150-200 KB amount of garbage collection for this class on the peak points. I suspected the dictionary was causing that and tried to optimize it by replacing it with 2 parallel lists, but it got worse. I reverted back to original script. Any ideas what might cause that GC amount? Any suggestions to make it better on the original script?
     
  46. Darkcoder

    Darkcoder

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

    The "Stars and Planet‪s" app developed by Andrei Nistorescu recently received a massive update for iOS and Android, check it out! It makes great use of SGT's features, and even expands upon the origin shifting system to make it really quite impressive.

    Looks great! I wonder what's causing the stuttering? Is that just the video recording, or something else? You can also try applying the atmosphere material to the trees to make them stand out less.

    Looks great! I assume the brown terrain popping in is a separate mesh spawned on top of the planet? If so, I wonder if you can adjust the base terrain colors to make the transition less abrupt.
     
    Last edited: Sep 24, 2022
  47. kamicth

    kamicth

    Joined:
    Sep 30, 2018
    Posts:
    32
    @Darkcoder can you make fartex and softness avalable for all starfields instead of just infinite ones ?

    In starfield infinite at BuilMesh overrride why have you changed Vector3.one*float.MaxValue (about 3.4e38f) by Vector3.one*1.0e10f ?
     
    Last edited: Apr 12, 2021
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    1 - I can imagine a use for Softness for non-infinite starfields, but not the Far fading. This would make your starfields disappear (but still render) beyond a certain distance?

    2 - float.MaxValue bounds cause the rendering to break in HDRP for some reason. There's probably some value between e10 and e38 that works, or perhaps a modification to SgtStarfieldInfinite to position it to no longer require such large bounds would work. When I have more time I'll look into it.
     
  49. joshua_42

    joshua_42

    Joined:
    Jun 23, 2016
    Posts:
    104
    Concerning starfields; could you add a feature to fade out the stars around the sun-lit edge of a planet? Currently you can see the stars clearly even behind the atmosphere. Would be cool to have a "light-pollution" feature like this.
     
  50. AkhaSkull

    AkhaSkull

    Joined:
    Mar 6, 2014
    Posts:
    10
    Hi.

    I would like to manipulate SgtLengths (convert them, add them, subtract them, etc.) and I am a bit confused by this operator :
    Code (CSharp):
    1. public static implicit operator double(SgtLength length)
    2.         {
    3.             switch (length.Scale)
    4.             {
    5.                 case ScaleType.Meter:      return length.Value;
    6.                 case ScaleType.Kilometer:  return length.Value * 1000.0;
    7.                 case ScaleType.AU:         return length.Value * 149600000000.0;
    8.                 case ScaleType.Lightyear:  return length.Value * 9461000000000000.0;
    9.                 case ScaleType.Parsec:     return length.Value * 30856740000000000.0;
    10.                 case ScaleType.GigaParsec: return length.Value * 30860903000000000000000.0;
    11.             }
    12.  
    13.             return default(double);
    14.         }
    if I have a value in meters and I want to convert it to kilometers I should divide it by 1000, not multiply it.
    This is quite confusing. I must not be doing things correctly.
    It would probably be clearer with a small example, if possible. :)

    Thanks in advance.