Search Unity

Space Graphics Toolkit & Planets

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

  1. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Good to know.

    How might you create a massive nebula (or set of nebulas) with random lightning in it?
     
  2. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    SGT Nebulas are emissive, and don't receive lighting. If you just want to randomly change the colors of the nebula clouds then you would have to either modify the SgtNebulaStarfield component, or make a new component that derives from this and make it implement its own code to pick colors.
     
  3. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Do you know of any assets that can create a nebula that reacts to lighting?
     
  4. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Nope, with some modifications to the starfield shader it could probably be added though.
     
  5. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Hi, I've been playing around with a lot of different atmosphere shaders, and I really like how yours has the ability to change colors along a gradient as the camera moves towards the dark side of a planet. However, once the atmosphere reaches the black area of the Lighting Brightness around the dark side of a planet, you can still see a fuzzy black atmosphere outline around the planet instead of it being transparent like in other atmosphere shaders.

    Is it possible to not render the atmosphere on the dark side of planets or have it be transparent using the alpha value on the black area of the Lighting Brightness gradient?
     
  6. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    The atmosphere shader is currently designed so that if you make the left side of the Lighting Brightness gradient transparent, the sky will be transparent on the dark side of the planet. However, this transparency doesn't change the horizon, which will always have a dark glow to it. This dark horizon glow is designed to simulate light absorption, and removing it would require changing the whole lighting system which I'd rather not do.

    If you want to modify the lighting system yourself then the important parts are SgtAtmosphereOuter.shader line 159, where the atmosphere desnsity/optical depth is written to the color.a, and in the next block of code you can see that the light RGB (and A if you have scattering) contributions are added. Similarly, the SgtAtmosphereInner.shader line 160 does the same stuff.
     
    Korindian likes this.
  7. jejacks0n

    jejacks0n

    Joined:
    Jul 28, 2013
    Posts:
    8
    Darkcoder, thanks for this library. I'm playing around with the Starfield script, and think the Stretch To Observers effect is pretty rad. The behavior is currently that the stars "collapse" to nothing and are no longer visible when there is no movement, but I'd like to clamp that to a min value (e.g. let's assume 1) so they look normal when there is no movement, and only stretch when there is movement -- as in only positive stretching. I'm about to jump into that script to try and accomplish that, and figured you might have some insights for me. Anything I'm missing about it?
     
  8. jejacks0n

    jejacks0n

    Joined:
    Jul 28, 2013
    Posts:
    8
    Oh, yeah, after poking around, it seems to be in the shader, and messing around in there didn't result in any good solutions. Any advice you could provide would be great. Thanks again.
     
  9. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    If you look at the 'Infinite Starfield 3D Warp' scene, you can see that I use two starfields with similar settings to achieve this. The implementation of the stretching doesn't allow it to revert to its 'normal' state when the speed approaches 0. Although it's possible to clamp the size to normal, its rotation will not look good.
     
  10. jejacks0n

    jejacks0n

    Joined:
    Jul 28, 2013
    Posts:
    8
    Yeah, that's pretty much what I figured out.. e.g. -1 vs. 1. Thanks for the insight.
     
    Darkcoder likes this.
  11. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Hey guys, I'm currently working on the next update to SGT, which will improve memory usage, generation speed, and runtime overhead for many of the components.
     
    Last edited: Jun 9, 2016
    chelnok, schmosef and hopeful like this.
  12. schmosef

    schmosef

    Joined:
    Mar 6, 2012
    Posts:
    852
    Had my eye on this for a while. Glad to find it on sale today.

    Gotta say: It's beautiful. The screenshots don't do it justice.
     
    Last edited: Jun 8, 2016
    Darkcoder likes this.
  13. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    Can you provide a manual. I'm interested but I'd like to know more about the mesh detail system. I'd like to create a game where the player lands on a planet. I'm using MapMagic to generate an infinite terrain. I wonder how hard would be to integrate them...
     
  14. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Sure, HERE's the current component documentation. For the mesh detail you want to look at the Terrain.pdf & Terrain Cylindrical/Displacer/Simplex.pdf.

    I'm not familiar with MapMagic, but if it's an infinite terrain in the x/z axis then it may not be compatible with the SGT mesh system, because this system is designed for planets (i.e. finite size), and therefore you need to have data that can wrap around a sphere somehow. SGT comes with the SgtTerrainDisplacer component which displaces the dynamic mesh based on a height map, but if you want to displace using it using a different source (e.g. procedural data) then you would ether have to use the SgtTerrainSimplex component, modify these components, or make a new component based on these (requires some C# knowledge, but it's not that advanced).
     
  15. raydekk

    raydekk

    Joined:
    Mar 14, 2013
    Posts:
    100
    Space Graphics Toolkit is THE best space asset for Unity.
    It has so many features, you could easily make 100 or more different games/apps with it. Glad SGT is on sale again, hope more people buy this wonderful asset.

    I have a feature request, I know there must be a lot of more important stuff on your to-do list but here goes:
    I'd love to see a pulsar animation like the accretion disk in a future version of SGT - something like https://www3.amherst.edu/~gsgreenstein/progs/animations/pulsar_beacon/

    Many thanks,
    Raydekk
     
  16. swiftest

    swiftest

    Joined:
    Apr 30, 2009
    Posts:
    75
    Darkcoder, what's the best way to upgrade from an older SGT version, say 2.0 to 2.7.6? (Yes, we're still using Unity 4 for the time being.) Do I just extract the scripts in an empty project and copy & replace the existing ones in the real project?

    Just importing the package causes quite a mess with the two versions colliding. Deleting the old one, and then adding the new package causes scripts to no longer be attached to game objects.

    The difficulty comes from the fact that we moved the directories and put some of them under plugins, for example, to deal with order of execution. So I suspect the importer isn't smart enough to automagically update those scripts.

    Thanks for any pointers and a great asset!
     
    Last edited: Jun 9, 2016
  17. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Thanks. I haven't researched much about pulsars, but to get that kind of flashing light effect I imagine it could easily be done with a component that scales some kind of bright effect based on the angle between the camera and the direction of the poles of the pulsar. I'll do a bit more research on the effect and see if I can make a decent demo of it.


    The only way to upgrade an SGT 2.X project to an SGT 3.X one is to re-create your GameObjects. The reason why is because SGT 3 was pretty much a complete rewrite, and many of the settings were changed, so there is no way to migrate most of the data. You should be able to install SGT 2 and 3 at the same time (so you can upgrade your GameObjects as needed and slowly phase out your usage of SGT 2), so I'm not sure what you mean by them colliding (they have different install directories, and all the shaders/classes have different names). Can you provide more information about the exact errors you get when you install them both?
     
  18. astearon

    astearon

    Joined:
    May 9, 2016
    Posts:
    18
    Just bought SGT last night and downloaded the extra examples. I have to say, this looks pretty awesome!

    I do have a few questions though:
    - I have read on a page back that it is possible to have the dark side of a planet with atmosphere transparent so you can see the stars. Is there an Example map with a planet I can test see this on ?
    -I know you have created a few ways to generate Galaxies and Star Fields but are they only backdrops or can they be used for example to represent an actual Star Map of your game, where each point can store actual solar system info?
    -How close to full size can the normal planets (not the Jovian ones) be ? Would a full size planet require a heightmap too big for a mobile oriented game ?
    - This is more of an addition to the above, How can you obtain multiple levels of detail so that even if the standard Height map for a planet is not so big you can add the details as you get closer to the surface ?
    I am thinking of something along the lines of how much detail Elite Dangerous has for the planet surface.

    How well does SGT fair in regards to a multiplayer style game ? Is there any limitation in this regard ?

    I do know a bit of C# and i will be getting help from someone who knows c# really well so if there's any technical aspects you need to explain go right ahead!

    I plan on adding quite a few features to my space demo :)

    Sorry for the long post , just one more thing, I have not bought any assets from the Unity Store , everything I and my friends made where from scratch. How many updates will I have access to in regards to SGT ?
     
  19. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I don't think any of the example scenes do this, but you can achieve this by adjusting the alpha in the Lighting Brightness gradient. Just make the alpha of the left side 0.


    It can be used for both. The 'Follow Observers' setting is used to lock it to the camera, otherwise it's just a normal 3D starfield that you can move around. If you want to get the star positions then you'll want to use the SgtCustomStarfield though, which you can make via the 'Make Editable Copy' context menu.


    It depends on your texture memory budget, device power, and resolution requirements. A full sized planet (e.g. Earth) that looks good up close would be very unrealistic though. Something closer to Spore would be more realistic.


    You can use the SgtSimplex component (or combine them) to add simplex noise on top of the height map to add more procedural detail. This feature is still quite basic though, but you can easily modify the components to add more features.


    There's no code to help or prevent multiplayer games, you just have to handle synchronization yourself and it should work.
     
  20. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Just curious - have you played SPAZ?

    They use layers of nebulas and I'm wondering if there is a way to do something like this with SGT.



     
  21. swiftest

    swiftest

    Joined:
    Apr 30, 2009
    Posts:
    75
    Darkcoder, I'm actually upgrading from SGT 2.0 to 2.7.8. How would you recommend doing that? (I'm still using Unity 4.x)
     
  22. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    @Darkcoder Great effects in the package.

    I'm seeing a lot of GC Allocation in the updates in a lot of the scripts. I've optimized all my scripts so far to be allocation free... would you be willing to do this for SGT as well?

    Here are the scripts I'm seeing Update() allocation for in the Profiler in the example scenes:

    SgtAccretion
    SgtBelt
    SgtCloudsphere
    SgtCorona
    SgtGravitySource
    SgtProminence
    SgtJovian
    SgtSpacetime
    SgtSingularity
    SgtLightingSpawner
    SgtRing

    There is also varying amounts of allocation happening on Camera.FireOnPreCull() in every scene. Can this be addressed please?
     
  23. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Nope, but I want to. If I get it I fear I'll spend all my free time playing it!

    To me this looks like a combination of static particles (e.g. something you could make with the SgtNebulaStarfield component), and some animated particles that randomly spawn (e.g. something you could make with Shuriken). Or am I missing something?



    Oh right, in that case I'm not sure, because the last time I touched that code was probably over 2 years ago. I imagine upgrading between those versions will basically require you to delete the old version, install the new one, and redo most of your GameObjects. From what I recall in the 2.X versions I added a lot of features to the components that required you to set new settings, or even redo things in some cases. A lot of the code back then was also fairly well linked together, so updating the components one at a time would be difficult without fairly good C# knowledge.

    Yes, I'm currently working on this for the next version. I've already done the SgtStarfield and SgtBelt component families, as well as made their regeneration speed much faster, and I'll do the same for the rest soon.
     
    chelnok, Korindian and schmosef like this.
  24. swiftest

    swiftest

    Joined:
    Apr 30, 2009
    Posts:
    75
    Could you explain how I use the SGT_Light Source? I created an empty object and put that script on there. But for things that ask for it (like the SGT_Planet script), it shows: "Planet Light Source: None (SGT_Light Source). It doesn't let me select a normal light or the object with the SGT_LightSource script.
     
  25. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    From what I recall you had to drag and drop that Component/GameObject into the light source field on the planet. I believe changing the light color wasn't a feature at the time, so there was no need to associate it with an actual Unity light.
     
  26. swiftest

    swiftest

    Joined:
    Apr 30, 2009
    Posts:
    75
    For the time being, I was able to simply replace the SGT 2.0 Shaders/ directory with the 2.7.6 one, and that fixed the long build times due to the shader compiler taking forever. So now I can work on the game proper. Thanks for the awesome support, even for the older versions. :)
     
    Darkcoder likes this.
  27. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    Hi Darkcoder/Carlos,

    I tried to buy Space Graphics Toolkit on the 24h sale. It was a last minute decision.

    The problem was Unity's Asset Store is buggy. Although my session said the price was 49 dollars when I purchased, it charged me the full price (99, the server price). No warning that the price had already changed. It probably was a question of seconds.

    The order is OR302528573, so you can check what happened if needed. You can check the time and that I still didn't download anything.

    So, I'm asking you to issue a partial refund. If not possible, please issue a full refund. Because, as I said, I didn't download anything until this issue is settled.

    Regards,
    Rod
     
  28. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I sent a message to Unity, I'll let you know what they say.
     
  29. Rod-Galvao

    Rod-Galvao

    Joined:
    Dec 12, 2008
    Posts:
    210
    (I'm replying here so everyone can see what an amazing support Darkcoder has)

    Hi Darkcoder,

    Thank you for your attention and support on this issue.
    Also, thanks for the voucher of a free copy you offered, but no need for it though. I think it wouldn't be fair to you because of an asset store's glitch.

    Regards,
    Rod
     
    Darkcoder likes this.
  30. REEFY

    REEFY

    Joined:
    May 9, 2013
    Posts:
    13
    Hey I was wondering not sure if it's a bug or anything, I bought the toolkit a long time ago, finally came back to unity a week ago and redownloaded the toolkit but it's stuck at version 3.1.2 from my downloads page. Is this normal because I see version 3.2.0 on the asset store. Also can you tell me any new things you can remember implementing from these two versions.

    Thanks
    Regards
     
  31. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    If you click the version "3.2.0" number then it shows you the change log between all the updates. As long as you're trying to download using Unity 5 then it should allow you to download the latest.
     
  32. REEFY

    REEFY

    Joined:
    May 9, 2013
    Posts:
    13
    Hmm I'm using the latest version of unity standalone, it still won't update to version 3.2.0.
    What would be a line of code or a way to have a zoom function in the orbit camera ( Sgt Mouse Look (script) Or the camera named Camera Pivot. For mouse zoom wheel and or touch screen for ios
    Thanks
     

    Attached Files:

    Last edited: Jun 26, 2016
  33. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You should contact Unity support then, as I don't really have any control over how the package download system works.

    If you look at the scenes with the orbit camera, you'll see that I just place the camera as a child of the rotating parent, and use the local z position to set the orbit distance. So to make this distance adjustable you'll need to write a script that changes this local z position based on the mouse wheel or pinch gestures.
     
  34. LightenFor

    LightenFor

    Joined:
    Dec 26, 2013
    Posts:
    26
    Greetings! I added Logarithmic depth fix for atmosphere shaders to have opportunity to show huge worlds without zfighting. I have two variant shaders (simple and logarithmic) for each: inner, outer and depth shaders from your pack. When camera close to planet, I replace shaders to simple variant, when far to logarithmic. Inner and outer log shaders work well, but I can't find place in code where you add depth shaders to Inner Renderers. I need this point to replace them. Please help!!!!
     
  35. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    The corona/atmosphere shaders don't perform any special depth checking, because they are rendered in the transparent render queue, which works fine assuming the surface is in the geometry group. However, in situations where the ground is also transparent I commented out the 'Offset -1, -1' line, which can be used to make it draw on top.
     
  36. LightenFor

    LightenFor

    Joined:
    Dec 26, 2013
    Posts:
    26
    I'm using custom depth output in my shader. I need to get control of replacing atmosphereInner shader to changed by me same shader! to switch them by command from other behaviour script. And changing all materials on Geospher, on InnerRenderers... Please, tell me what to do!

    PS: It works well separately. When I just replace code of sgtAtmosphereInner and outer shaders by my logarithmic depth - It's ok. But when I'm trying to switch, shader does not apply!
     
  37. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Oh I see, then you just want to change the yourAtmosphere.InnerMaterial.shader value when you want to switch. This property is publically accessible, and should always have the current material applied to all inner renderers.
     
  38. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413

    Hey guys, version 3.2.1 has just been released!

    You can check the change log for more detailed information, but basically this update removes most of the runtime GC usage, and improves mesh generation speed a lot. This update changes lots of code, so as always, make sure you back up your projects before updating.

    Keep in mind that optimizing the starfield & belt generation speed required changing the way they work, and because there is no longer any SgtStarfieldGroup or SgtBeltGroup components, you should delete the old 'Group' child GameObjects of these components. You will also have to set up the 'Main Tex' and other fields to get them working the same again, but the speed gains should be worth the time required to update.

    If you encounter any issues or bugs then please let me know!
     
    Korindian and hopeful like this.
  39. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    After importing the latest update, I get this error:

    Assets/Packages/Space Graphics Toolkit/Scripts/Player/SgtBeltGroup.cs(33,39): error CS1061: Type `SgtBeltModel' does not contain a definition for `ManualUpdate' and no extension method `ManualUpdate' of type `SgtBeltModel' could be found (are you missing a using directive or an assembly reference?)
     
  40. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    This script no longer exists, so delete the SGT folder (or just the Scripts folder)and reimport it. Make sure you back everything up!
     
  41. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
  42. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    What's that? This window isn't part of SGT.
     
  43. Tiberius1701

    Tiberius1701

    Joined:
    Sep 16, 2014
    Posts:
    71
    Just a quick question about the sun object - is there any way to animate the activity on the sun or solar flares? Is the object scalable?
     
  44. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    You can change the scale/height of the SgtProminence effect, and replace the texture to make it animate, but there's no built-in animation feature for this. I could add some kind of animation though, as I imagine some sort of scrolling texture would look nice. I'll have to experiment with that for the next version.
     
  45. Tiberius1701

    Tiberius1701

    Joined:
    Sep 16, 2014
    Posts:
    71
    Awesome - very exciting - I'll be purchasing this toolkit later today and trying it out!

    Thanks!
     
    Darkcoder likes this.
  46. LightenFor

    LightenFor

    Joined:
    Dec 26, 2013
    Posts:
    26
    On sgtAtmosphere... Is any way to make two sky colors on heigh direction. I know it can be many colors when light to dark side of planet transition happen... But can I make two colors from ground to space? Or one gradient from ultra light blue (like white) to darker blue. Or change some shaders to make more realistic scattering... As in real world... please help! Need like here!
     
  47. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    Yes, the DensityColor gradient is used for this. You will probably have to spend some time tweaking all the relevant values to get something looking like your reference images.
     
  48. Korindian

    Korindian

    Joined:
    Jun 25, 2013
    Posts:
    584
    Hi @Darkcoder , thanks for optimizing the scripts.

    I'm still seeing GC allocations every frame whenever any component is calling SgtHelper.WriteLights() or SgtHelper.WriteShadows() due to String.Concat().

    Couldn't these be eliminated completely using Shader.PropertyToID? Most of the scripts calling those methods have a maxShadows/maxLights count of 2, so couldn't those shader properties be turned from strings to ints and stored at runtime (since the ids change on every run), letting you use the int version for the first argument of any Material.Set*** function.

    Actually, in any place where SetTexture, SetFloat, SetColor, SetMatrix, SetInt, SetVector, etc. uses a string could use the version of the method without strings to avoid allocation.

    Unless there is a specific reason you chose not to use it already due to complications.
     
    Last edited: Jul 23, 2016
  49. Darkcoder

    Darkcoder

    Joined:
    Apr 13, 2011
    Posts:
    3,413
    I used strings because it makes the code much simpler and shorter. There are ways to still use strings but avoid these allocs though, or wrap the ID usage while still keeping the code pretty sane. However, it's still quite a lot of code that needs to be changed, so I'll leave it for the next-next version. For the next version I'm focusing on polishing the existing code some more, and adding one or two new visual features.
     
    Korindian likes this.
  50. rapidrunner

    rapidrunner

    Joined:
    Jun 11, 2008
    Posts:
    944
    Hi, I was looking at the examples in the package, but I do not see something that show how to make a space to terrain transition.
    I am looking at the displaced terrain scene in the basic pack, but I am not sure how do you change resolution for the LOD...when you get very close, the texture show a lots of dot artifacts, instead of a proper geometry. Thanks!