Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

Basic stuff, I guess. Can I somehow make a sun out of a light-source in XNA? I would like to be able to see the light, actually, and set it on the upper right corner like a sun.

share|improve this question
    
white polygon right behind the source of light, curved to maximize the reflection... –  ratchet freak Apr 23 '13 at 23:42
    
or inverted sphere centered around the lightsource, exempt from shadowing ofcourse ;) –  ratchet freak Apr 23 '13 at 23:48
    
Wait. The Sun is in the upper right corner? Of the Solar System? –  Laurent Couvidou Apr 24 '13 at 10:33

1 Answer 1

up vote 3 down vote accepted

It's possible to use a point light source for the sun, whether you are wanting to simulate what the sun looks like if you look at it, or the just light it shines.

TLDR; yes, but make it as far as you can away from the player and don't have any light falloff.

Essentially you can think of the sun as being a point light source that is infinitely far away. No the real sun isn't a point nor is it infinitely far away, but it's "close enough" you can think of it that way. The problem is, how do you make a point light source that is "infinitely far away"?

If the point light is too close, then shadows will not all be cast parallel. Image you had a fence with a gap between every board, and the sun was setting behind it. Every beam of light coming through (or board shadow) would be parallel. But if you had a closer point source, the shadows would spread out in a sort of fan, leading back to the point source.

Also if the point light is too close, and it is visible via some kind of lens flare or halo glow, the player will notice their position is different relative to it as they move. Imagine if the real sun were frozen in the sky on the western horizon for a moment. If you start walking south, it's going to basically stay in the same place in the sky unless you walk a very long distance. But if the sun (or your point light) were close up, then you would see it change position in the sky as you walked farther south.

Lastly, for all intents and purposes, the light from the sun doesn't fall off (get dimmer at a distance). Yes it does if you move millions of miles away from it, but if you go hundreds (or thousands) of miles nearer or farther away, it basically stays the same brightness as far as your eye can tell. So you need to make your point light source do the same - not have a falloff where it gets dimmer as you get farther away.

share|improve this answer
3  
A directional light would be a better choice. –  congusbongus Apr 24 '13 at 1:31
    
Cong Xu, I agree. If such a thing is available, this is what you want, as it gets rid of the whole "it has to be far away" issue. –  Tim Holt Apr 24 '13 at 3:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.