pioneerspacesim/pioneer — pull request #1391 by Ae-2222 (2012-07-23 12:53:30+00:00)
Title: Render building models with atmospheres (builds on building illumination branch #1390.)

This PR is based on:
* Fade building illumination depending on time of day and atmosphere branch #1390
* Pull request #1357 Atmosphere scale patch from tomm, third time (with an additional commit 96783f5c0e02e96dd91990ab67a23750e5b630e0 in the branch #1278 Tomm's Atmosphere scale height2 (updated).

It's preferred if this branch is merged rather than the #1390 Building illumination one as it expands and comments things. If there's an issue with the atmospheres only that takes time to resolve, that branch can be updated and merged. #1390 contains details about lighting and other issues that came up that needed to be documented somewhere.

***

A new atmosphere and model shader is created and used to render models which are on planet surfaces in atmospheres.

From the code comments:

For orbital starports: renders as normal
For surface starports:
* Lighting: Calculates available light for model and splits light between directly and ambiently lit
* Lighting is done by manipulating global lights or setting uniforms in atmospheric models shader
* Adds an ambient light at close ranges if dark by manipulating the global ambient level
* Atmosphere: Models are rendered using models-in-atmosphere shader if it is enabled in options
* For models-in-atmosphere shaders lighting is done in shader, for non-shaders and without models-in-atmosphere shaders lighting is done by manipulating global lights fpor space station and city.

Atmospheric shaders are activated by EnableModelsInAtmosphereShader. This should allow people whose graphics cards cannot handle it to turn it off (very unlikely as SM 3.0+ card is required to run normal atmosphere shaders, although Tomm did run into some issues with number of variables used etc. IIRC).

Code:
* Atmosphere shader uniform is moved to it's own function.
* LmrObjParams has a bool to indicate if model is atmospheric (set to false by constructor), as well as the required uniforms.
* Non per-frame uniforms are saved by SpaceStation::InitStation() and per-frame uniforms are saved in SpaceStation::Render.
* There are two new files, models-in-atmosphere shader files.

Screenshots:
Normal atmospheric density:
![](http://i.imgur.com/wwlMc.png)

Exaggerated atmospheric density:
![](http://i.imgur.com/Zs48s.png)