[MDX] Planetary Atmosphere Glow
Alright, when you look at a picture of a planet from space... you see this little glow effect around it (if it has an atmosphere). What would be the best way to simulate this effect? More details = Better.
-E
that effect is called atmospheric scattering google it up you should get some tutorials or code on it.
regards,
m4gnus
regards,
m4gnus
er... no, I'm not so sure it is. When I look up Atmospheric Scattering, it relates to when viewing on the planet surface... I'm referring to viewing a planet from space...
I found an image that closely resembles what I am referring to from EVE Online.
Notice that the part of the planet in the sunlight has a glow? I want to do that same effect in game.
I found an image that closely resembles what I am referring to from EVE Online.
Notice that the part of the planet in the sunlight has a glow? I want to do that same effect in game.
What you could do is using your eye vector. Calculate a ratio between your eye vector and your normal.
float3 ratio = 1 - saturate( dot(-eyeVector, normal) );
You subtract it by 1, cause you want the opposite value.
Then you calculate the atmosphere of your planet by modulating a certain color by the ratio.
float3 atmosphere = 0.5* float3(.3, .5, 1) * pow(ratio, 2);
Add this atmosphere to your final color in the pixel shader
color += atmosphere;
I hope this helps.
Take care.
float3 ratio = 1 - saturate( dot(-eyeVector, normal) );
You subtract it by 1, cause you want the opposite value.
Then you calculate the atmosphere of your planet by modulating a certain color by the ratio.
float3 atmosphere = 0.5* float3(.3, .5, 1) * pow(ratio, 2);
Add this atmosphere to your final color in the pixel shader
color += atmosphere;
I hope this helps.
Take care.
You could also implement this as a post-process effect (Gaussian blur/bloom) for the planet using edge detection so it does not perturb the center of the planets body from any viewpoint.
Or alternatively, you could just render a concentric, alpha-blended sphere slightly larger than your planet that serves as the atmosphere and use a method like Armadon suggested to give the atmosphere sphere its alpha value based on the dot product of the view vector and the surface normal.
Or alternatively, you could just render a concentric, alpha-blended sphere slightly larger than your planet that serves as the atmosphere and use a method like Armadon suggested to give the atmosphere sphere its alpha value based on the dot product of the view vector and the surface normal.
Ok, sounds great. So how do I do it? :)
I've never worked with shaders before so I'm completely new at it. I am using VB.NET but I can read C# and unmanaged C++ DX code easily.
-E
I've never worked with shaders before so I'm completely new at it. I am using VB.NET but I can read C# and unmanaged C++ DX code easily.
-E
Here (the blur sample) is a great sample for post-processing. The C++ sample that comes with the DXSDK is nice to mess around with but is way too complicated to be a sample, it seems more like the programmer(s) got caught up in the pretty pictures and forgot to teach anyone anything. The blur sample gets the idea across while still being a sample, not a full-blown application.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement