Hi all,
I have a question. I'm working on a space engine at the moment, and I have successfully created geodesic grid sphere's for planets and have all the appropriate physics for space ships (using a physics engine). So far I have a very rough draft/clone of Kerbal Space Program (but years behind their progress, not intending to compete with their product. But rather as a hobbyist just playing around with graphics API/physics APIs and trying to bind them together.)
Now that I have the basics down, I've realized that my planet graphics are really bad and I want to improve it. The first thing I want to do is create an atmosphere.
I have a technique down and I just want to bump it off you guys, as I have no real idea how to implement it. I am guessing I'd do it in HLSL.
So what I'm thinking is to create another geodesic grid sphere around the planet's surface with a larger radius. But rather than just make it a blue color, which of course won't give a good gradient or depth to the atmosphere, to do something else with it:
What I'm thinking of doing is make this atmosphere surface 2 sided and also transparent. Then calculate the amount of distance between the start of the atmosphere and either the planet itself or the backside of this new atmosphere sphere. The more distance or pixels between the start and the backside, the more atmosphere is present and color the pixel according (blue for earth).
Now the question is this: How do I implement that in a shader? I assume I may have to render like a shadow map, and write the depth of the start of the atmosphere and compare that to the object behind it, much like you do with shadow mapping. Would this be the best approach? Before I waste days trying to implement this, can you guys maybe point me in a better direction if you may have one?
Thanks.