   Atmospheric Scattering.
  This is the next thing I want to put in my procedural planet engine, and I think I understand it fairly well. What I want to know is the best way to mix atmospheric scattering with the rest of my rendering pipeline. I converted some of the shaders in GPU Gems 2 from a void main() function to a callable function void CalculateScattering(vec3 vert,.....) which has like 20 parameters. I plan to call this function from my main shaders to calculate the scattering color and secondary color. The problems I foresee are:1) blending space objects2) running out of shader code spaceSo I guess my questions are, how do I blend in objects in space (when the camera is in the atmosphere), or objects behind the atmosphere (when the camera is in space)?Whats the best method for splitting the rendering so that I don't need to create multiple large shaders for all the different combinations of surface from space, surface from atmosphere, space from atmosphere etc for all my already existing shaders? I was looking into defered rendering thinking I could do a multipass render, but its not something I understand that well. I have alot of geometry in my scenes (~14000 poly world model, ~360000 polygon geo clipmap) so I really only want to rasterize it once./edit I plan to go straight to HDR, so solutions can be angled towards that.   