Real-time secondary lighting color

As you've probably noticed, SE doesn't take into account the color of the planet when it calculates the illumination of moons, and vice versa (except for real planets - planet script have the parameter 'Color' for this purpose). Now I've fixed this. The method is very tricky. Analytic calculation of color of the planet is almost impossible - it should take into account the color table used for the surface texture generation, clouds and water coverage, and atmosphere color. So I made things easier - I just render a planet into a small texture (viewed from sun, so it's at full phase), then it read this texture back to CPU and sum up all pixels to calculate the average color. This gives the true color of the planet taking into account all its features - real surface texture, clouds pattern, atmosphere and even rings!
This procedure is fast enough, so it even can be used for real-time update of planet's color. I've implemented several modes: compute color once, when planet first comes into view of field; update color every half second; and disable color updating. In the real-time updating mode, the effect fixes issues with total eclipses - if the moon is completely in the shadow of the planet, it does not illuminate the planet. However, lighting in totality could be solved analytically, by upgrading the eclipse code.
Another thing is the distance from which the color should be calculated. Now we should be able to approach the planet to see its disk. After that, if you leave the planet, its star-like particle will have the proper color. It is possible to calculate the color for every object from any distance, but this may hit performance, because there are hundreds of objects in a typical planetary system. It is also possible to calculate a color for every body when a planetary system is being generated, but this will significantly increase the generation time.
Below are screenshots showing the same scene, before and after a planet's color calculation. The first two are a view on a blue gas giant from its moon, and the next two are from far away, where it looks like a star (note the color of some small yellow moon near the gas giant):