Planetary Atmospheric Scattering
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
Planetary Atmospheric Scattering
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*
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
*Click for bigger*
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.
-
- Orc
- Posts: 470
- Joined: Thu Feb 15, 2007 2:08 pm
- Location: Gothenburg, Sweden
-
- Goblin
- Posts: 208
- Joined: Sat May 05, 2007 4:49 pm
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:
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.
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:
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.
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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).
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).
-
- OGRE Retired Moderator
- Posts: 4011
- Joined: Fri Sep 19, 2003 6:28 pm
- Location: Burgos, Spain
- x 2
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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).
-
- Ogre Magi
- Posts: 1260
- Joined: Mon Aug 07, 2006 6:16 am
- Location: Colorado Springs, CO USA
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
-
- Orc
- Posts: 441
- Joined: Tue Aug 01, 2006 1:43 am
- Location: Spain!!
- x 8
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
Ya, I've been there and posted somenikki wrote:Looks cool!
I think you already did, but you should check out the Infinity Project:-
Infinity: The Quest For Earth
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.
-
- Silver Sponsor
- Posts: 135
- Joined: Thu Jul 13, 2006 9:16 pm
- Location: San Juan Capistrano, CA, USA
- x 1
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
-
- Orc
- Posts: 441
- Joined: Tue Aug 01, 2006 1:43 am
- Location: Spain!!
- x 8
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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).
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).
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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.â€
[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.â€
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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?)
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?)
-
- Halfling
- Posts: 83
- Joined: Thu Jun 02, 2005 4:44 pm
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
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.Cobra8472 wrote:That is awesome.
Planetary rendering like that has been somewhat of a goal ever since I saw Infinity.
Keep it up!
-
- Silver Sponsor
- Posts: 597
- Joined: Sun Jan 07, 2007 11:55 pm
- Location: Cologne, Germany
-
- Halfling
- Posts: 83
- Joined: Thu Jun 02, 2005 4:44 pm
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 dayHexiDave wrote: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.Cobra8472 wrote:That is awesome.
Planetary rendering like that has been somewhat of a goal ever since I saw Infinity.
Keep it up!
Looking forward to the new version.
-
- OGRE Expert User
- Posts: 1538
- Joined: Sat Jan 14, 2006 8:00 pm
- x 1
Well, this is what it looks like right now:Cobra8472 wrote: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 dayHexiDave wrote: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.Cobra8472 wrote:That is awesome.
Planetary rendering like that has been somewhat of a goal ever since I saw Infinity.
Keep it up!
Looking forward to the new version.
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.
-
- Ogre Magi
- Posts: 1260
- Joined: Mon Aug 07, 2006 6:16 am
- Location: Colorado Springs, CO USA
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!
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!