Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Atmospheric Scattering In Unity from GPU Gems 2

Discussion in 'Made With Unity' started by Russian Madman, Sep 28, 2009.

  1. Russian Madman

    Russian Madman

    Joined:
    Apr 20, 2009
    Posts:
    29

    Attached Files:

  2. jonaphin

    jonaphin

    Joined:
    Dec 31, 2008
    Posts:
    209
    Amazing work!
     
  3. chaos1986

    chaos1986

    Joined:
    Mar 29, 2009
    Posts:
    230
    You could make a sky day/night cycle using this method
     
  4. fallingbrickwork

    fallingbrickwork

    Joined:
    Mar 16, 2009
    Posts:
    1,072
    This is superb!

    Matt.
     
  5. Russian Madman

    Russian Madman

    Joined:
    Apr 20, 2009
    Posts:
    29
    Yes of course!
     
  6. chadchat

    chadchat

    Joined:
    Apr 5, 2008
    Posts:
    154
    nice work
     
  7. chaos1986

    chaos1986

    Joined:
    Mar 29, 2009
    Posts:
    230
    Would this work in unity indie? and how does one accomplish this effect? i'd only need it for a large (flat) level not a spherical world
     
  8. Russian Madman

    Russian Madman

    Joined:
    Apr 20, 2009
    Posts:
    29
    This is just a Vertex Shader ( simply fragment), work on Shader Model 2.0...
     
  9. chaos1986

    chaos1986

    Joined:
    Mar 29, 2009
    Posts:
    230
    Kool, i don't know much about how shaders work (except basic shaders).

    Where would i start if i wanted this effect in the sky?
     
  10. Russian Madman

    Russian Madman

    Joined:
    Apr 20, 2009
    Posts:
    29
    Here =)... http://http.developer.nvidia.com/CgTutorial/cg_tutorial_chapter01.html
     
  11. PRD

    PRD

    Joined:
    Jan 31, 2008
    Posts:
    29
    Awesome work Russian Madman. I've implemented the same method on a visualization I did for NASA. http://climate.jpl.nasa.gov/Eyes/eyes.html

    I toned down the effect to not take away from the Blue Marble. I noticed your map looked a bit low res, if you are looking for a hi res texture map of the earth, go here: http://visibleearth.nasa.gov/view_set.php?categoryID=2363

    Someone mentioned a day/night cycle earlier in the post. You can find a hi res texture map on that BlueMarble site as well.

    If anyone is wondering on how to implement this effect in Unity, check out this thread: http://forum.unity3d.com/viewtopic.php?t=13076

    Like I mentioned earlier, the effect is toned down, I would ask Russian Madman for his parameters if you want it to look like his.

    Russian Madman, would you be willing to post your shader code, I would like to see how yours works. Again, awesome work!

    --Paul
     
  12. PRD

    PRD

    Joined:
    Jan 31, 2008
    Posts:
    29
    I forgot to mention, I really like your implementation of the atmospheric scattering from the ground!

    --Paul
     
  13. Daniel_Brauer

    Daniel_Brauer

    Unity Technologies

    Joined:
    Aug 11, 2006
    Posts:
    3,356
    That's a very nice visualization. Playing around with the camera close to the surface is quite fun. The only thing bothering me is the ugly, built-in lens flare. I think it would look better without one, or perhaps try one of these: Lens Flare examples.
     
  14. Russian Madman

    Russian Madman

    Joined:
    Apr 20, 2009
    Posts:
    29
    Wow! Thanks for examples =)..Now I'am working around exposition, and maybe later I will share my code for SkyFromGround shader.
     
  15. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
  16. U2

    U2

    Joined:
    Aug 12, 2008
    Posts:
    215
    I have taken the sample project from the other thread and have been messing around with it. I would like to apply this shader to my own scene which is currently of a planet orbiting a star. The star is drawn as a "point" light which means it is no longer visible when the planet passes between the camera and the star. In the sample project it takes a static direction of forward from a directional light positioned inside the planet itself. If you move this light around, ie up or down during test play the flare never moves. I'm totally at a loss here.

    If you would be willing to post your code Mr. Russian it would be an absolute life saver. I believe in your project you could fly around the planet etc.. which is basically what I have in mind.
     
  17. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
  18. U2

    U2

    Joined:
    Aug 12, 2008
    Posts:
    215
    For some reason when I visit your link it says it failed to update unity web player. I have updated to the latest version but still no go. Kinda strange.

    I'm guessing though it's basically what I have in mind. I have say a planet slowly orbiting a star, a station and a moon orbiting the planet. I click a "moon" button and my camera flies over to the moon and goes into orbit, if I click the "planet" button it makes that the new target and goes into orbit around that etc.. The current example project I have found for this scattering works with the exception of the light source. My light source is at the origin (0,0,0) with everything orbiting it. It is a point light.
     
  19. nikko

    nikko

    Joined:
    Mar 20, 2009
    Posts:
    436
    oh, I see, it is made with the beta 6 :( sorry... you will have to wait a little bit to see it hopefully not too much.

    Anyway the example is working great for me, why don't you place the light far in the distance. Mine is at 5000 away (do not forget to set the camera distance to +5000 to see the sun)

    Also something else, be carefull with the sphere collision as it may hide the sun (remove the collision or make it smaller than the planet)

    It should work.
     
  20. U2

    U2

    Joined:
    Aug 12, 2008
    Posts:
    215
    Not sure we are on the same page here...

    I was messing around with the project that PRD posted which was very kind of him. The light source is inside the sphere in that project, everything is located at 0,0,0. When I move the light source far away nothing changes in the scene.

    The reason I would like to use a point light source is I want the planet to hide the sun when the camera passes behind it. With the directional light it doesn't seem to do this so the sun shines through the planet.

    Nikko did you set yours up from scratch or did you go off of PRD's example too? I'm wondering if there is two different implementations going on here and if so what is the difference.
     
  21. LoneWolfGabo

    LoneWolfGabo

    Joined:
    May 6, 2010
    Posts:
    172
    sorry to re-wake an old post. I was wondering if you (Russian Madman) could share the shader. I beeing looking to implement an atmosphere scattering as seen from ground in a full sphere (planet) All i found is PRD's shaders that are intended just for a from space view. I did try to somehow "flip" it but no luck at all. the Cull Off doesn't seem to work neither fliping the normals of the sphere.
    Or if anyone has something i could use?

    thx.
     
  22. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    @LoneWolfGabo: Try this thread: LINK Scrawk made a port of the GPU gems atmo scattering and posted a link here to it. There are also a couple of amazing assets that have even better scattering, but most of those aren't free...

    Here's an example of what i did with Scrawk's shaders:
    $Epic Planet Screenie.png
    If you would like to play a demo of this, PM me, and i will give you what i have done so far. this game isn't complete though, and at the moment, you just fly around in an extremely quiet solar system...

    Also like how you pointed out PBR's shader, and wouldn't mind trying it, if only the links weren't dead...
     
    Last edited: Mar 9, 2014
  23. JamesLeeNZ

    JamesLeeNZ

    Joined:
    Nov 15, 2011
    Posts:
    5,615
    Congratulations on the necro bump!

    YAY! SO EYES!
     
  24. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    @JamesLeeNZ: this might sound n00bish, but what is a necro bump? are you critiquing my post? and sorry, what do you mean by "YAY! SO EYES!" Anyway, if this is positive feedback, thank you!
     
  25. Kaji-Atsushi

    Kaji-Atsushi

    Joined:
    Oct 6, 2012
    Posts:
    234
    Necro typically means death if I'm not mistaken, and seeing that this is kind is a 4 year old topic...I think it's safe to assume that's what he was refering to. You bumping up a dead topic. I'm not sure what "YAY SO EYES" mean though. But no worries, people make mistakes from time to time. Just keep an eye out on how old the latest post it, especially if you're replying to it ;).
     
  26. Kridian

    Kridian

    Joined:
    Jan 24, 2012
    Posts:
    55
    A four year old thread bumped! That has to be a record(?)

    It's why the internet is full of these pictures:


    *Edit
    He just bumped one from 5 years ago. nvm
     
    Last edited: Mar 10, 2014
  27. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,869
    Aha, ok! Now that i know what Necro means, that means this thread has been necro bumped twice! LoneWolfGabo posted his a year after this thread died, and of course, mine i posted recently, which makes a double bump with 4 years between bumps!
     
unityunity