Planetary Atmospheric Scattering

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Planetary Atmospheric Scattering

Post by HexiDave »

I've been slowly resurrecting my OgrePlanet project and I wanted to try my hand at getting a shader working for it that I failed miserably to get working last time. I'm on a new machine and have a lot more experience with shaders, so here's the results of converting Sean O'Neal's work for Ogre:

*Click for bigger*
Image

Image

Image

This is for a spherical planet, but as you can see in the first picture it would work really well for atmospheric planets if you have flat-terrain or are in space. Was getting about 200-300 FPS on a GeForce 7900 GS (shader could be optimized a bit, certainly).

I'm building a demo for it (there's some mechanics to change materials at certain altitudes), so I'll be releasing the source I've got for the shaders/project. Will probably take a few days.


Download available:
Nov. 12
Download
Last edited by HexiDave on Mon Nov 12, 2007 7:29 pm, edited 1 time in total.
User avatar
oddrose
Orc
Posts: 470
Joined: Thu Feb 15, 2007 2:08 pm
Location: Gothenburg, Sweden
Contact:

Post by oddrose »

that's some really beautiful pictures! nice going!
kcbanner
Goblin
Posts: 208
Joined: Sat May 05, 2007 4:49 pm

Post by kcbanner »

Thats hawt.

I know the way EVE Online does it is render a circle around the planet onto a billboard. I know this because it had a graphical glitch once:
Image

It looks like a billboard to me...might be an idea. Basically it just has to face the camera since the planets are so far away they are pretty much round.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Well the idea is that you can have the atmosphere constantly scattering light even as you enter the atmosphere - just the thing I need when OgrePlanet lives again.

Those shots were from RenderMonkey after I had converted everything I needed, but it looks like Ogre is going to put up a fight again and screw some things up. Currently the light doesn't follow the correct direction and the planet doesn't get the correct angle shading (dunno what the hell that's about).
User avatar
Kencho
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 4011
Joined: Fri Sep 19, 2003 6:28 pm
Location: Burgos, Spain
x 2
Contact:

Post by Kencho »

Those shots are amazing. Very good job, and good luck porting them to Ogre :D
Image
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

When I ported the code over, I changed a few things to make it more customizable at run-time, but I think I can say "screw it" for now because I fouled something up (and it's not my variables - I tried it hard-coded, so it's my code changes I think). Most of the variables are VERY sensitive anyways, so I don't think anyone's going to cry if I just get it working with generic scales (I'll have to modify it later so people can move the planet as the code relies on it being at the center currently).
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Post by Zeal »

Cant wait to see the source for this! Are you gonna include the code for the planet itself as well? Or is it just a simple sphere?
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

OgrePlanet is a separate project which will be released eventually (not setting any deadlines as my time is constrained), but this shader will just have spheres (using the manual-creation code in the Wiki, so you can customize them a bit).
User avatar
nikki
Old One
Posts: 2730
Joined: Sat Sep 17, 2005 10:08 am
Location: San Francisco
x 13
Contact:

Post by nikki »

Looks cool! :)

I think you already did, but you should check out the Infinity Project:-
Infinity: The Quest For Earth
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Post by Brocan »

I tryed to implement Sean O'Neal's work over Ogre, but it never works :( . I can't wait to see your code. :P
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

nikki wrote:Looks cool! :)

I think you already did, but you should check out the Infinity Project:-
Infinity: The Quest For Earth
Ya, I've been there and posted some :)

Brocan: Ya, there's some changes that need to be made to make it Ogre-friendly and I'm still having some issues with scale vs variables. The figures used are INCREDIBLY sensitive, so I need to work it out.
User avatar
trilobite
Silver Sponsor
Silver Sponsor
Posts: 135
Joined: Thu Jul 13, 2006 9:16 pm
Location: San Juan Capistrano, CA, USA
x 1

Post by trilobite »

I am developing an application that can make PERFECT use of your work, Hexidave. Here is a screenshot...

Image

Right now, I am planning two completely separate, interactive environments: 1) orbital view; and 2) surface view.

It would be terrific to be able to blend them together. :D
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Hehe, not really MY work - this is just an adaptation of Sean O'Neil's shaders. I'm still learning how the system functions - I've got most of it down, but some parts are still blowing me out of the water.
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Post by Brocan »

Hexi, and the shaders that you have adapted are for GL or for D3D or both with CG? because, I remenber that Sean O'Neil shader are only GL.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Well, the ones with GPU Gems 2 have Cg files as well as GLSL ones. They're almost a direct port anyways (there isn't THAT much difference in how GLSL and HLSL and Cg are written).

I'm gonna re-write the shaders a bit tomorrow with what I learned today, so hopefully I can pull something demoable out shortly thereafter (basically the scaling is screwing up the calculations and throwing the colors off - I might just have to estimate a metric to adjust the variables for scaling).
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Hmm, well I feel a bit silly now - quoth the book:

[quote]“One significant drawback to this implementation is that the scale function is dependent on the scale height an the ratio between the atmosphere’s thickness and the planet’s radius. If either value changes, you need to calculate a new scale function.â€
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Ok, first demo is up for grabs:
Download

I'll make a video and post it in a bit. There's a Readme.txt included as well as the source, materials, shaders, etc.

Edit: Oh ya, the shaders are for HLSL right now, but I'll port em back to Cg once I figure out what the hell was causing them to go dark on me (and my Cg compiler was complaining about "for" loops for VS 2.0, what's that about?)
Cobra8472
Halfling
Posts: 83
Joined: Thu Jun 02, 2005 4:44 pm

Post by Cobra8472 »

That is awesome.



Planetary rendering like that has been somewhat of a goal ever since I saw Infinity.

Keep it up! :D
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Cobra8472 wrote:That is awesome.



Planetary rendering like that has been somewhat of a goal ever since I saw Infinity.

Keep it up! :D
Do a search for OgrePlanet if you want to see some of my old work towards that end. I've got a new version, rebuilt from scratch, in the works. Dunno completion date, but it'll be up for grabs once it's ready, too.
jjp
Silver Sponsor
Silver Sponsor
Posts: 597
Joined: Sun Jan 07, 2007 11:55 pm
Location: Cologne, Germany
Contact:

Post by jjp »

That demo already has a cool feeling to it when you move the camera slowly from space to planet surface :)
Enough is never enough.
User avatar
Brocan
Orc
Posts: 441
Joined: Tue Aug 01, 2006 1:43 am
Location: Spain!!
x 8

Post by Brocan »

Awesome work :D
Cobra8472
Halfling
Posts: 83
Joined: Thu Jun 02, 2005 4:44 pm

Post by Cobra8472 »

HexiDave wrote:
Cobra8472 wrote:That is awesome.



Planetary rendering like that has been somewhat of a goal ever since I saw Infinity.

Keep it up! :D
Do a search for OgrePlanet if you want to see some of my old work towards that end. I've got a new version, rebuilt from scratch, in the works. Dunno completion date, but it'll be up for grabs once it's ready, too.
Yeah, I checked out the progress in that thread. I'd love to use it, but unfortunately, I'm a far too novice programmer. Some day :)

Looking forward to the new version.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
Posts: 1538
Joined: Sat Jan 14, 2006 8:00 pm
x 1

Post by HexiDave »

Cobra8472 wrote:
HexiDave wrote:
Cobra8472 wrote:That is awesome.



Planetary rendering like that has been somewhat of a goal ever since I saw Infinity.

Keep it up! :D
Do a search for OgrePlanet if you want to see some of my old work towards that end. I've got a new version, rebuilt from scratch, in the works. Dunno completion date, but it'll be up for grabs once it's ready, too.
Yeah, I checked out the progress in that thread. I'd love to use it, but unfortunately, I'm a far too novice programmer. Some day :)

Looking forward to the new version.
Well, this is what it looks like right now:
Image

Not much to look at, is it? That's the corrected quad-tree structure working with a cube (i.e. I split a node on the front and it propagates the neighborhood splitting to keep it balanced on all sides - very important for LOD stitching.)

As for the atmospheric scattering, I notice that the sunset is REALLY hard to get right, due to the nature of the finicky parameters, so I might create a look-up table based on angle and height (sort of like Sean O'Neil does it) to adjust the parameters automatically.
cloud
Gremlin
Posts: 196
Joined: Tue Aug 08, 2006 6:45 pm
x 14

Post by cloud »

Amazing :shock:
User avatar
Zeal
Ogre Magi
Posts: 1260
Joined: Mon Aug 07, 2006 6:16 am
Location: Colorado Springs, CO USA

Post by Zeal »

A bit off topic -

I see youre using a cube for your planet. I started that way, but got furstrated with all the distortion at the corners, so I made a switch to the mighty icosahedron instead. What a nightmare that was. After a month or so of banging my head against the wall, I realized cubes are the way to go, hands down. Cubes let you use regular 2d grids, and you just cant underestimate that. So, good call :)

And as for the corner distortionm I came across this...

http://fl-tw.com/InfinityForums/viewtopic.php?t=2305

which really helps with that particular problem. Incase you didnt already know.

Anyway, keep up the work on the sky scattering! I plan to use this baby myself!
Post Reply