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
    It's an issue of Depth Buffer Precision. Basically, the planet and the atmosphere layer are two flat surfaces that are very close to each other, so the z depth values of each pixel will interfere when the camera is far away from them.

    You can simulate this yourself by creating two quad GameObjects and placing them very close to each other, you'll notice that the farther away the quads are, the harder it is to produce the flickering.

    There are a few ways to work around this issue, but obviously all have their tradeoffs:

    1 - Increase the near clip range, and/or decrease the far clip range

    2 - Use two cameras, one for close objects, one for far objects (with an increased near clip range, etc)

    3 - Increase the atmosphere height, or make the height based on camera distance

    4 - Add the 'offset' parameter to the atmosphere shaders (this will essentially shift the z depth values)

    5 - Disable z buffer writing for the atmosphere and put it on an earlier render queue (you probably don't want to do this)


    I would advise you try option 4, because it's probably the easiest to do. Take a look HERE for info on the feature, though there are a lot of atmosphere shader files you must go through for this.
     
  2. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    I just had a complete "DOH!" moment.

    It's actually within my original concepting work to use two seperate cameras, one for the distant objects and one for the nearby ones. So aye, solution 2 would deffo be a solid fix. :D

    Thanks again for the help.
     
  3. BES

    BES

    Joined:
    Feb 26, 2013
    Posts:
    212
    I have been repeatedly asking about this for a while with vague answers ...and I must not have been asking the question correctly...

    I would like to be able to land on and walk around on my planets made with SGT.... like in this video https://www.youtube.com/watch?v=Cngr6JUfkD4 ...see how the terrain looks horizontal? ..no visible curve?(unless flying of course) ...but it still has mountains and such..

    I keep trying it and its just not working ...place a character on the surface ...everything is too small ...it doesn't scale ...I see the planets curve ..character gets stuck in the terrain and character falls off the planet into space..

    I think this is along the lines of scaling the planet based on camera distance ...so I wont have to make the planets massive ...

    Im still no good at C# stuff ...I been making basic things ..like an inventory system for objects ...but this other stuff is above my skill still...also im no good in math..

    Help would be appreciated ..
     
    Last edited: Jan 15, 2014
  4. RyuMaster

    RyuMaster

    Joined:
    Sep 13, 2010
    Posts:
    468
    Hi! Is it possible to place some plane mesh on the backround skysphere to act as billboard i.e. I want to display vortex texture with particle emitter attched to it. Or currently there are no easy ways through existing components set?
     
  5. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    To make planets larger you either need to increase the Radius setting in the SGT_Planet component, or make your characters smaller, there's nothing else to it. I just made a test scene using the surface tessellator, and I can produce a planet that looks similar to the one in your video. However, there are rendering and physics system limits to how large you can make your planets before things start breaking. Dynamically scaling the planet can fix some of the rendering issues, but you can't realistically change the scale of a planet with a mesh collider in realtime.

    If you look at the 'SurfaceTessellator' scene and increase the Surface Tessellator/Patch/Max Levels, then isn't that pretty much what you want? If you approach Earth then the curvature mostly disappears, and you can still see mountains. You can then add the Surface Tessellator Collider for collision, and increase the radius a bit if need be.


    Make an empty GameObject and attach: Component/Space Graphics Toolkit/Example/Follow. Then enable the Position checkbox, and drag your Main Camera into the Target field. Now attach your billboard and particle emitter to this GameObject and offset their position towhever in the sky you want them, it should now follow the camera and be in the background.
     
  6. BES

    BES

    Joined:
    Feb 26, 2013
    Posts:
    212
    I meant ..like in this web player demo(arrow keys and mouse): https://dl.dropboxusercontent.com/u/45391150/Web.html can freely walk around on the surface in any direction ..without the character having any issues with getting stuck in the terrain....or falling anywhere ..

    But I was told I need to make a custom character for this type of stuff ...instead of trying to use anything from UFPS or any pre-made FPS related controllers....
     
  7. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Oh, right. You might have to make your own character controller, it really depends on how they were written. You can try using the SGT_SnapToSurface component to rotate a character controller to the surface, and use the SGT_GravitySource/Receiver components to add planetary gravity to it. If this doesn't work then you can try adding the aforementioned components to an empty GameObject, then you add your character as a child of that. If none of this works then the character controller you're using must be making some assumptions about which direction is up, thus will probably require some code editing. I'd be surprised if UFPS doesn't support arbitrary up axes.
     
  8. FreeTimeDev

    FreeTimeDev

    Joined:
    Jul 7, 2012
    Posts:
    64
    After updating to the latest version (from an unknown version of unity) then updating to the newest version of your SGT i have the following error:
    and

    I had this error before and after updating SGT.

    (btw, when I updated I noticed I never rated SGT; it's stellar and it received five stars)
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    These errors were fixed in the latest version of SGT. It's possible that you need to delete your cache and redownload SGT. If you want to fix them yourself, then find the lines it's complaining about and replace null with default(string)
     
  10. michaljabrzyk

    michaljabrzyk

    Joined:
    Apr 15, 2013
    Posts:
    57
    How to draw a orbit in play time for sgt planet? Trail Render is good but for a small object's but for a big it is a problem.
     
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    You can try using the SGT_Ring component and scaling it across one axis for oblateness.
     
  12. michaljabrzyk

    michaljabrzyk

    Joined:
    Apr 15, 2013
    Posts:
    57
    I try this but it not work. I think that will be better if I use some script who will draw orbit in GUI mode becouse of floating point and constant ring scale.
    Other way ring should be scaled in realtime (any time when camera go to object and when object in camera view is small).
     
  13. michaljabrzyk

    michaljabrzyk

    Joined:
    Apr 15, 2013
    Posts:
    57
    Darkcoder is this imposible to use this code from SimpleOrbit.cs and use this procedure for draw orbit in GUI?
    ther way wtite some code hire in

     
    Last edited: Jan 20, 2014
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    If you use the GL class then you could draw the orbit in LateUpdate. If you look at that code, it uses the Handles class to draw lines in the scene view, so you would have to convert it.
     
  15. Deleted User

    Deleted User

    Guest

    Hi Darkcoder!
    I noticed one interesting thing - 3D text can be seen through the star component.Just look:
    How it looks in Play Mode:
    $editor.PNG
    Scene view,i selected camera,so you can see where is camera,text,star.
    $scene.PNG
    Any ideas?
     
  16. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    By default, GUIText uses the 'GUI/Text Shader' shader, which is designed to draw on top of things. If you want it to draw using 3D depth, then you have to change the material.
     
  17. Cornotiberious

    Cornotiberious

    Joined:
    Dec 5, 2012
    Posts:
    6
    Hi! do you know if it's possible to have a normal map(and a specular) along with the detail map for the planet shader? this would make the close up planet textures look really good!
     
  18. Deleted User

    Deleted User

    Guest

    Thanks!
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    You mean apply a normal map and specular map to the detail map? If so, then no. There's simply not enough space in the pixel shader to add these with the current normal and specular maps. However, it would be possible to change the shader a bit so that the current normal and specular maps are applied to the detail map instead of the main planet texture.
     
  20. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I am trying to upgrade my project (built in 4.2.2) to 4.3 (only because it has the new iPad Air/Mini generations), but SGT throws errors in 4.3, so I'm trying to do the absolute minimal upgrade of SGT to fix the errors. (I don't want to do the normal process -- delete SGT and download/import the new version, because that typically breaks a lot of stuff,and I have some 60 scenes with SGT stuff in it). So I deleted the "/Required/Scripts" folder and imported just those files from the update. But now I get the error below, over and over again. Can I fix that without doing the full import?

    IndexOutOfRangeException: Array index is out of range.
    SGT_StarfieldStarVariant.RecalculateCoords (Int32 tx, Int32 ty, Int32 i) (at Assets/SpaceGraphicsToolkit/Required/Scripts/Library/SGT_StarfieldStarVariant.cs:173)
    SGT_Starfield.RecalculateCoords () (at Assets/SpaceGraphicsToolkit/Required/Scripts/Player/SGT_Starfield_Procedural.cs:62)
    SGT_Starfield.Regenerate () (at Assets/SpaceGraphicsToolkit/Required/Scripts/Player/SGT_Starfield_Procedural.cs:20)
    SGT_Starfield.LateUpdate () (at Assets/SpaceGraphicsToolkit/Required/Scripts/Player/SGT_Starfield_Messages.cs:27)
     
  21. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    I changed the way starfields work, and that particular error is caused by the 'coords' field not being initialized. If that's the only error then you can open up SGT_StarfieldStarVariant.cs and find the 'RecalculateCoords' method and replace it with:

    Code (csharp):
    1.     public void RecalculateCoords(int tx, int ty, int i)
    2.     {
    3.         var w = 1.0f / (float)tx;
    4.         var h = 1.0f / (float)ty;
    5.         var x = w * (i % tx);
    6.         var y = h * (i / tx);
    7.        
    8.         if (coords == null || coords.Length != 4) coords = new Vector2[4];
    9.        
    10.         coords[0] = new Vector2(x    , y + h);
    11.         coords[1] = new Vector2(x + w, y + h);
    12.         coords[2] = new Vector2(x    , y    );
    13.         coords[3] = new Vector2(x + w, y    );
    14.        
    15.         uv = new Rect(x, y, w, h);
    16.     }
     
  22. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Thanks!!! That got rid of the error. I had to go into each scene and reassign the starfield texture, but at least nothing else broke. Much appreciated.
     
  23. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    I had some trouble with my project, so had to go to backup and upgrade to 4.3 again...and now I get this error (with both the edited and unedited version of the StarfieldStarVarient.cs file):

    Assets/SpaceGraphicsToolkit/Required/Scripts/Library/SGT_StarfieldStarVariant.cs(55,40): error CS0200: Property or indexer `SGT_Starfield.Modified' cannot be assigned to (it is read only)

    What should I do?

    thanks
    Dave
     
  24. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,241
    Any suggestions on my problem with "read only"? I've tried the upgrade for 4.3 again and I get the same error.
     
  25. smival

    smival

    Joined:
    Dec 15, 2013
    Posts:
    2
    could you make a wormhole? with examples it would be cool!
     
  26. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    There's no wormhole feature in the current version, though there is the accretion disc preview. If you want a copy of it then send me a PM or e-mail. Just keep in mind it's an experimental feature that isn't strictly compatible with SGT (has different Unity version requirements, etc).
     
  27. Antigono

    Antigono

    Joined:
    Oct 20, 2013
    Posts:
    63
    Hello how are you?
    I'm interested in this package and would like to resolve a question. Sorry if this was already answered

    It is possible to use a real and/or realistic proportionally scale and thus have a simulation between sizes of planets, distance between them, etc?

    Thank you and sorry for my english
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Yes, but that really depends on your programming skill, and the range of scale you need to simulate. e.g. if you're making a simple solar system simulation and the camera can only ever view planets from a very high orbit, then you might be able to just place planets using standard 3d coordinates (i.e. transform.position). But if you need to be able to approach the planets and maybe land on them, then you need to write some custom code to handle the different scales, because using transform.position alone won't be sufficient (due to floating point inaccuracies).
     
  29. SiBlack

    SiBlack

    Joined:
    Jun 12, 2013
    Posts:
    22
    Hi,

    I've got a shadow rendering issue with the toolkit.

    I'm using the SGT_planet component to display a moon while on a terrain surface that's lit by a direction light with the deferred renderer and getting tons of shadow flicker.

    The moon is on it's own layer that is excluded from the light and the moon orbits the terrain outside the radius of the direction light placement. I've edited the planet's shader to exclude it from the terrain fog.

    If I use the forward renderer or disable the moon everything is fine ( So general scale/bias is not the issue.). But I need to use deferred for various other effects.

    Any thoughts or aid greatly appreciated.

    Thanks.
     
  30. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    I'm having a hard time replicating the scene setup you have. Could you send me a unitypackage of a scene showing the issue using the SGT media?
     
  31. CAISLOC

    CAISLOC

    Joined:
    Mar 2, 2014
    Posts:
    1
    Question: This components ca be used into an AR -Augmented Reality- project, that use Vuforia package assets, like ARCamera?
     
  32. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    I can't think of any reason why they wouldn't work together.
     
  33. TheDevGuy

    TheDevGuy

    Joined:
    Mar 3, 2014
    Posts:
    78
    Code (csharp):
    1. Assets/SpaceGraphicsToolkit/Required/Scripts/Editor/SGT_EditorGUI_Draw.cs(249,35): error CS0121: The call is ambiguous between the following methods or properties: `UnityEditor.EditorGUI.Vector2Field(UnityEngine.Rect, UnityEngine.GUIContent, UnityEngine.Vector2)' and `UnityEditor.EditorGUI.Vector2Field(UnityEngine.Rect, string, UnityEngine.Vector2)'

    Code (csharp):
    1. Assets/SpaceGraphicsToolkit/Required/Scripts/Editor/SGT_EditorGUI_Draw.cs(260,35): error CS0121: The call is ambiguous between the following methods or properties: `UnityEditor.EditorGUI.Vector3Field(UnityEngine.Rect, UnityEngine.GUIContent, UnityEngine.Vector3)' and `UnityEditor.EditorGUI.Vector3Field(UnityEngine.Rect, string, UnityEngine.Vector3)'
    I am getting this error on import of the package. I just upgraded unity and now i got this error?
     
  34. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Find the lines it's complaining about and replace null with default(string)

    I'm pretty sure I fixed this in the latest version, I'll test it later.
     
  35. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    @Darkcoder: Is it possible to generate space junk around a planet? At the moment, i am making a game that needs the application of being able to randomly generate space junk around a planet at the start of a level. (Of course, i have written a script to do this already, but the space junk's on the inside of my Earth too! I wouldn't mind a little help in making a code snippet that could get my junk out of the planet's core!)
     
  36. Quadgnim

    Quadgnim

    Joined:
    Sep 10, 2012
    Posts:
    132
    I suspect you're using some randomization to place the junk. If the planet has a radius of 100, then just add +/- 100 to whatever is generated and it'll be outside the planet.

    ie: 1, 50, 200 == 100, 150, 300
    -10, 40, -20 == -110, 140, -120
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    As Quadgnim says, you want to use a radius in your random calculations.

    I would use something like:

    Code (csharp):
    1. var randomAngle    = Random.Range(-Mathf.PI, Mathf.PI);
    2. var randomDistance = Random.Range(50.0f, 100.0f);
    3.  
    4. transform.position = new Vector3(Mathf.Sin(randomAngle), 0.0f, Mathf.Cos(randomAngle)) * randomDistance;
    That will randomly place your GameObject around a circle with a radius of 50 to 100 units.
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    Hey guys, SGT has been chosen for Unity Asset Store's 24 hour deals. It will appear tomorrow (25th) for 65% off.

    If you know someone that might find it useful then please tell them to check it out :)
     
  39. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I see all sorts of interesting things in the asset packing list, but no mention of the Moon. Am I overlooking it?

    I'm thinking at some point I might want to work on a "mission to the Moon" scenario, and that would require a preferably realistic, recognizable Moon body that can be approached, possibly orbited and landed upon (though the landing could be finessed off-camera). Then a walkabout on the Moon.

    How much of that can be done with the SGT? It sounds like there is Earth-from-space imagery and a starfield from the Earth's point of view, including the Sun. But I'm not sure how much - if any - of the Moon is available in the kit.
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    The moon is included as part of the Solar Eclipse demo scene. However, I wasn't able to find public domain surface textures that covered the whole surface, so I had to take public domain pictures of the front side and re-project it to a cylindrical map. This means I had to photoshop it a bit to fill in the missing areas, so it's not a true moon surface map. However, there are many moon texture sources online that you can use in your projects, most of them require attribution though, which is why I couldn't include them in SGT.
     
  41. hopeful

    hopeful

    Joined:
    Nov 20, 2013
    Posts:
    5,686
    I suspected as much. Thanks for the response! :)
     
  42. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    Nice asset,

    How is the performance and how much memory is needed for IOS. Iphone 4.

    Cheers.
     
  43. nomax5

    nomax5

    Joined:
    Jan 27, 2011
    Posts:
    365
    Will this solve my falling off the edge of the world problem? does this make a spherical terrains?
    I have always had this problem and never found an adequate solution, currently I put mountain ranges all around my map then huge colliders to make sure that no one can fall off the edge of the map. But when you get close to the edge of the map you can tell its the edge.

    $edge_of_world_example.jpg

    The ultimate solution would be a spherical terrain where when you run in one direction for long enough you will end up back where you started.

    I'm not bothered about the zooming in to a planet from outer space (at the moment) I would probably do a re-entry thing with flames and shaking then Loading Please Wait and load the more detailed planet scene.

    I just want a spherical terrain where I can put buildings, rocks, tress, unity water, the terrain doesn't have to be detailed as long as I can place huge rock models on it.

    Sorry if this has been answered I spent ages searching every page on this post.
     
  44. UAF

    UAF

    Joined:
    Jun 24, 2013
    Posts:
    8
    Hello,
    How adapted is the tool for games that require random generation of planets and star systems and basically space?

    Are there scripts that generate a random star system / planet?
    If there aren't, will it be easy to create such scripts?
     
  45. softrare

    softrare

    Joined:
    Jun 12, 2011
    Posts:
    444
    Hi! I just bought this because of your LOD webplayer demo. There are a lot of demo scenes in the package, but seemingly none of them has this type of setup. Also there are a lot of different manuals (pdfs). Now, how would I go about to redesign a scene using the LOD ? Or in which pdf is the description for that? Thanks a lot!
     
  46. softrare

    softrare

    Joined:
    Jun 12, 2011
    Posts:
    444
    Nevermind, found it. For all that have the same question: its the SurfaceTessallator scenes. Looks nice, thanks! :)
     
  47. FunkyCoder

    FunkyCoder

    Joined:
    Feb 25, 2014
    Posts:
    10
    Hello space lovers!...I'm using the old Freelancer game as an exact! example...would SGT be especially suited for this sort of design. Manual placement of uniquely designed statically placed (SGT)planets , asteroids, space junk, with a Sun, as per one level with jump gate locations this all using SGT travel within solar system as like Freelacer (ie can you fly around planets ..not land...and traverse solar system in realtime as in Freelancer..jump gate goes to another level design...to another star ... which leads to the same type of static set up as previous level...every solar system object would manually placed planets, asteroids, sun,debris etc. In other words is SGT especially suited for desigining an exact replica of the Freelancer universe setup..If so, would you explain why and if not please explain that? I would appreciate comments from anyone on my questions though Im directly targeting my question to the developer. Thanks in advance
     
  48. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,414
    The shaders are fairly well optimized, and depending on the features you need, the shader will be swapped in/out, so there isn't much that can be improved there. The memory usage is also quite low, especially in the latest version. The majority of the memory usage will be in the planet surface textures, which you have full control over.


    Yes, all the terrains in SGT are spherical (check out the Web Player demos on the first post, or asset store). To create a terrain you basically select a sphere (e.g. a 50k triangle geosphere that comes with the package), and then select a heightmap, and SGT will deform the vertices on the sphere to create a spherical planet will mountains and such. If you need higher resolution mesh then SGT can also procedurally generate the mesh so the areas near the camera are higher resolution. I also created a Web Player demo showing this off too :)


    SGT comes with an example scene that procedurally generates a star system with various random parameters (e.g. orbit radius, speed, planet radius, atmosphere colours, etc). But there's no demo to procedurally generate planet textures, for that you need to look into 3D simplex noise.


    The Surface Tessellator scene shows you how to set up a really simple LOD planet. I don't think I've written any detailed documentation on how to make a scene like it, but there is a PDF doc with the same name covering all the component parameters.


    Yes, SGT would be perfect for creating a replica of Freelancer. In fact, it would be fairly easy to make something that looks a lot better. However, certain aspects of it would quite a bit of extra code. For example, in Freelancer there are specific types of debris in different areas of each system. SGT doesn't come with a script to handle this kind of situation, but I designed the Debris Spawner component to be easily used to create this kind of effect.

    If you have more questions regarding this then let me know!
     
  49. FunkyCoder

    FunkyCoder

    Joined:
    Feb 25, 2014
    Posts:
    10
    Just purchased SGT...been waiting for a sale on an excellent product...tks
     
  50. He Dares

    He Dares

    Joined:
    Mar 21, 2014
    Posts:
    1
    IIs their a way to get an array or something that has all the asteroids in an asteroid ring so i can get their positions in order to path to them? and mine them etc?