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!

Planetary Atmospheric Scattering

Postby HexiDave » Sun Nov 11, 2007 6:44 am

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
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby oddrose » Sun Nov 11, 2007 9:07 am

that's some really beautiful pictures! nice going!
User avatar
oddrose
Orc
 
Posts: 470
Kudos: 0
Joined: 15 Feb 2007
Location: Gothenburg, Sweden

Postby kcbanner » Sun Nov 11, 2007 9:14 am

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.
kcbanner
Goblin
 
Posts: 208
Kudos: 0
Joined: 05 May 2007

Postby HexiDave » Sun Nov 11, 2007 10:41 am

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
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby Kencho » Sun Nov 11, 2007 12:40 pm

Those shots are amazing. Very good job, and good luck porting them to Ogre :D
Image
User avatar
Kencho
OGRE Retired Moderator
OGRE Retired Moderator
 
Posts: 4011
Kudos: 1
Joined: 19 Sep 2003
Location: Burgos, Spain

Postby HexiDave » Sun Nov 11, 2007 1:38 pm

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
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby Zeal » Sun Nov 11, 2007 2:44 pm

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
Zeal
Ogre Magi
 
Posts: 1260
Kudos: 0
Joined: 07 Aug 2006
Location: Colorado Springs, CO USA

Postby HexiDave » Sun Nov 11, 2007 3:05 pm

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
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby nikki » Sun Nov 11, 2007 3:55 pm

Looks cool! :)

I think you already did, but you should check out the Infinity Project:-
Infinity: The Quest For Earth
User avatar
nikki
Old One
 
Posts: 2730
Kudos: 13
Joined: 17 Sep 2005
Location: Princeton, New Jersey, USA

Postby Brocan » Sun Nov 11, 2007 4:11 pm

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
Brocan
Orc
 
Posts: 441
Kudos: 9
Joined: 01 Aug 2006
Location: Spain!!

Postby HexiDave » Sun Nov 11, 2007 4:54 pm

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
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby trilobite » Sun Nov 11, 2007 6:00 pm

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
trilobite
Silver Sponsor
Silver Sponsor
 
Posts: 135
Kudos: 1
Joined: 13 Jul 2006
Location: San Juan Capistrano, CA, USA

Postby HexiDave » Sun Nov 11, 2007 6:11 pm

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
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby Brocan » Sun Nov 11, 2007 9:56 pm

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
Brocan
Orc
 
Posts: 441
Kudos: 9
Joined: 01 Aug 2006
Location: Spain!!

Postby HexiDave » Sun Nov 11, 2007 10:32 pm

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
Kudos: 1
Joined: 14 Jan 2006

Postby HexiDave » Mon Nov 12, 2007 11:07 am

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
Kudos: 1
Joined: 14 Jan 2006

Postby HexiDave » Mon Nov 12, 2007 7:28 pm

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?)
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby Cobra8472 » Mon Nov 12, 2007 8:26 pm

That is awesome.



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

Keep it up! :D
Cobra8472
Halfling
 
Posts: 83
Kudos: 0
Joined: 02 Jun 2005

Postby HexiDave » Mon Nov 12, 2007 8:29 pm

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.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby jjp » Mon Nov 12, 2007 8:38 pm

That demo already has a cool feeling to it when you move the camera slowly from space to planet surface :)
Enough is never enough.
jjp
Silver Sponsor
Silver Sponsor
 
Posts: 597
Kudos: 0
Joined: 07 Jan 2007
Location: Cologne, Germany

Postby Brocan » Mon Nov 12, 2007 11:29 pm

Awesome work :D
User avatar
Brocan
Orc
 
Posts: 441
Kudos: 9
Joined: 01 Aug 2006
Location: Spain!!

Postby Cobra8472 » Tue Nov 13, 2007 12:12 pm

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.
Cobra8472
Halfling
 
Posts: 83
Kudos: 0
Joined: 02 Jun 2005

Postby HexiDave » Tue Nov 13, 2007 1:08 pm

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.
User avatar
HexiDave
OGRE Expert User
OGRE Expert User
 
Posts: 1538
Kudos: 1
Joined: 14 Jan 2006

Postby cloud » Mon Nov 26, 2007 5:51 pm

Amazing :shock:
cloud
Gremlin
 
Posts: 194
Kudos: 14
Joined: 08 Aug 2006

Postby Zeal » Mon Nov 26, 2007 6:56 pm

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!
User avatar
Zeal
Ogre Magi
 
Posts: 1260
Kudos: 0
Joined: 07 Aug 2006
Location: Colorado Springs, CO USA

Next

Return to Showcase

Who is online

Users browsing this forum: No registered users and 11 guests