Light Source i.e. Sun?

57 views
Skip to first unread message

Darren Enns

unread,
Apr 29, 2013, 4:34:22 PM4/29/13
to webgl...@googlegroups.com
[newbie here]

Any idea how difficult it would be to create a light source, so that the Earth globe has a 'light' and 'dark' side, as if illuminated from the Sun?  In the rest of my code, I already know the 'sub-solar' geographic lat/long (the point on the Earth directly under the Sun).

Perhaps alternatively, if I could code the coordinates of a circle representing the current dark side of the Earth, and make it transparently 'dark', and overlay it as a layer on top of the Earth, that would be another (more difficult) way of doing this. 

Thanks for any assistance/advise!

Petr Sloup - Klokan Technologies GmbH

unread,
Apr 30, 2013, 3:08:13 AM4/30/13
to webgl...@googlegroups.com
Hello,

the proper way of implementing this would be to modify the fragment shader so that it receives information about the direction of incoming sunlight and calculates the "illumination factor" using the simplest http://en.wikipedia.org/wiki/Lambert's_cosine_law .

Overlaying transparent dark "circle" would be very tricky and inefficient.

Hope this helps.

Best regards,
Petr

Darren Enns

unread,
Apr 30, 2013, 8:36:58 AM4/30/13
to webgl...@googlegroups.com
Thanks for the reply! 

I am not sure that I am clever enough to 'modify the fragment shader' as you suggest (BTW, are there docs for how to use the shader as it is?).

On the other hand, I was able to use the clumsier method of generating and overlaying a dark circle (is the 'polygon' API documented anywhere?  I found someone using it and figured out how that way).  It looked like it was going to work fine -- but then I realized that instead of generating a round polygon that layed on *top* of the Earth sphere, it was instead creating a (large) flat disk that *cut through* the earth -- which totally would not work for me.  My only other previous experience with doing this sort of thing was with OSM, but in that case the polygon layed nicely on top of the Earth.  Hmmm...
Reply all
Reply to author
Forward
0 new messages