AnalyticalGraphicsInc/cesium — pull request #367 by kring (2012-12-11 03:48:40+00:00)
Title: Make 2D and Columbus View lighting match 3D

Yes, this is a pull request into the terrain branch. I'm doing this so that @pjcozzi and anyone else interested can take a look at these lighting changes separately from the terrain changes. The terrain branch (specifically the water) is very useful for testing this, but now that it's working I could separate it from terrain and create a pull request against master pretty easily if desired. Just let me know.

Ok, so what does this actually do?

Basically I've changed the way lighting is computed in 2D and Columbus View so that it matches 3D. Given a camera position and orientation in 2D, I find the "equivalent" camera position and orientation in 3D. The position is computed simply by unprojecting, i.e. 2D world coordinates -> longitude/latitude/height -> 3D world coordinates. Orientation is computed by treating the 2D camera's direction, right, and up vectors as if they're specified the camera's local East-North-Up axes. Then, all lighting is computed using this synthetic position and orientation, along with the real, 3D positions of the light sources.

The overall effect lies somewhere between totally weird and totally awesome. I'm curious what you guys think. With real sun and moon positions, it would probably be firmly in the awesome category. With the current faked ones I'm not as certain.

Oh and this makes the water look right in Columbus View.