Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Robbo

How to render atmosphere? (screenshot)

This topic is 5256 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''ve managed to get my billboards working, to show stars and my skybox looks ok (showing nebula), just wondering how on earth I render an "atmosphere" around the edge of a planet (sphere). As you can see from the screenshot, I''ve tried billboarding a "ring" texture, but I can''t seem to get the radius or position correct so it fits! (picture top of page) http://www.robinmj.0catch.com Anyone done anything like this before? Cheers.

Share this post


Link to post
Share on other sites
Advertisement
That looks pretty impressive as is, but anyways, for the atmosphere effect you COULD use pixel shaders to create volume fog, that should create the right effect, search msdn and nvidia''s site you should find plenty of crap on volume fog (its also in the dx sdk )

Share this post


Link to post
Share on other sites

Well thats my intention for when the player goes into an atmosphere (in a gas giant for example), but in this case, what I want is haze around the silhouette of the planet - for when the eyepoint is at a distance much greater than the atmosphere.

Share this post


Link to post
Share on other sites
I think,you need to use correct size/distance for billboard,not equal to radius/distance of center of sphere.
Just draw on paper camera close to planet,planet,and billboard.
You will see that planet are seen with bigger angle than billboard.


Also,you coult try,after rendering of planet surface,use relatively simple pixelshader on all screen(and do that only if planet are close,of course). Say,shader could pick color from special texture at

x=dotproduct(NormalizedRay,V)
y=abs(crossproduct(NormalizedRay,V) )

where
l= | VectorToPlanet | ;
V=VectorToPlanet ;
and texture corners at
-MaxPlanetDist,0
,MaxPlanetDist,MaxPlanetDist;
if you want you could use V=|VectorToPlanet|*SomeFunction(l);


Texture pixel with polar coordinates (alpha,r) stores color of atmosphere at [angle between planet and ray]=alpha ,[distance to planet] = r; and alpha value that are then used to blend it with billboard(so pixelshader will be smoothly replaced withbillboard).Alpha should smoothly vary from 1 to 0 as r varies from 0 to MaxPlanetDist.

That texture should contain pre-calculated atmosphere to planet 'raytracing' results.Result are as accurate as raytraced volumetric atmosphere!

Let c=(color from texture) and bc=(color from billboard);

pc.rgb=(c.rgb*c.alpha+bc.rgb*bc.alpha)/(c.alpha+bc.alpha) .
pc.alpha=c.alpha+bc.alpha
blend pc to screen.

Inform me if you will use that

Regards,

Dmytry Lavrov.


...

[edited by - Dmytry on February 23, 2004 1:44:09 AM]

Share this post


Link to post
Share on other sites
Woah, that does look very nice! Let us know how if you work out a solution (it does look like the radius/size of the billboard is incorrect).

Is that ring just a texture which is mostly transparent, but has a ring around the edge? And do you just draw it at the centre of the planet with a size such that the edge of the texture is outside the planet?

sam

Share this post


Link to post
Share on other sites

The ring is a billboard texture, centered at the planet. I think I''ll never get it to fit properly, even when I calculate the horizon point and place it there it doesn''t fit!

What I''m going to do is use ring geometry - rotate it billboard style and fit it around the horizon. Will get back to you all on whether it works or not!

Share this post


Link to post
Share on other sites
You just have to intersect a sphere with a plane, centered at the planet''s origin, with the normal pointing in the direction of the camera. This intersection gives you a set of line segments in 3D, which you can then scale to the planet''s radius. This gives you a first set of vertices. Set alpha to 1 for these vertices. Now do the same, but with a bigger scale, and set these vertices to alpha 0. Use a nice gradiant texture, and voila.

Y.

Share this post


Link to post
Share on other sites
quote:
Original post by Ysaneya
You just have to intersect a sphere with a plane, centered at the planet''s origin, with the normal pointing in the direction of the camera. This intersection gives you a set of line segments in 3D, which you can then scale to the planet''s radius. This gives you a first set of vertices. Set alpha to 1 for these vertices. Now do the same, but with a bigger scale, and set these vertices to alpha 0. Use a nice gradiant texture, and voila.

Y.



Isn''t that the same as kind-of drawing a circle on a plane? ie. a normal circle transformed to the orientation of the plane? Also, I need to place the object around the horizon, rather than the centroid of the sphere. I thought about pre-generated geometry (just a ring) that I scale to the horizon and rotate by the inverse of the camera view matrix. Err, thats probably wrong (geometry isn''t my strong point), but I''ll give it a go.

Share this post


Link to post
Share on other sites
quote:

Isn''t that the same as kind-of drawing a circle on a plane?



Yes, that''s what the intersection of a sphere and a plane is

quote:

I need to place the object around the horizon, rather than the centroid of the sphere.



That''s why i said you should scale your sphere to the planet''s radius.

The "ring" is formed of two circular pieces; the inner one is the circle with the planet''s radius; the outter one, the radius of the planet plus the atmosphere thickness.. this will give you a ring in 3D that is always oriented towards the camera (like a billboard).

Y.

Share this post


Link to post
Share on other sites
I kind of understand what you mean, but I don''t think I can afford to do a per-frame sphere/plane intersection clip! At least, I''ll pre-do the intersection by generating the ring. Now we are both talking the same language. The only thing that is different is that the ring cannot be centered at origin of the sphere, or just be scaled to its radius, because the horizon is usually closer to the eyepoint than the center, if you see what I mean. This is what is complicating matters somewhat

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!