Sun Lighting

How exactly does a true “Or similar” Sun light work? I have no real clue on how to do this so what I have done multiple times is just have the Sun follow the character which resulted in a completely unnatural shadows.

How can a sun like beam work and completely effect all objects in the world?

What is wrong with setting the lamp type to Sun?

it got a limited range, you can increase the size but still it wont light up the whole scene (with shadows for example)
i wonder the same thing as the topic starter.


How big is your scene?

If I’m getting your question right, you’re asking how a sun lamp works? If so, then I read somewhere that a sun lamp works be shooting infinite beams at the place you specify. for example. if a sun lamp is pointing at a box, then the lamp with emit beams starting on that plane (where the lamp starts) and then point all of them with the same “slope” toward the box

nope, what you’re talking about is similar to ray tracing. bge creates a camera at each lamp to process the shadows (correct me if I’m wrong, I’m not an opengl expert).

That or parenting the sun to the camera is generally how you would handle orthographic lighting. How large is the scene you’re trying to light that you want to light all at the same time.

atm 1000x1000 blender units. the shadow map will be to big to cover it.

You want you Sun lamp to follow a position in front of your camera. That way you always have it shadow in front of you

ok so vertex parent or parent it to an empty so it wont rotate, guess that will do the trick, else if player turns shadows turn with it.

To have that distance LOD thing, you could have several shadow-only sun lamps covering the full camera frustrum, the more distant the lamp from the camera, the bigger you make the lamp’s shadow’s frustrum size. Not sure how many of those you can make before there is a noticeable impact in the FPS though. Use a copy rotation constraint on all the shadow lamps to keep them aligned with a no shadow sun lamp to keep the lighting consistent.

I’m not sure what would be the best way to keep the shadow lamps in the right place though; parenting to the camera could make them go underground if you tilt the camera down; and if it is just copying the X and Y of empties parented to the camera the shadow lamps would get squeezed together when you look up or down; and don’t forget you need to take the lamps orientation into consideration as well…

Oh, wait, we’re talking about the game engine? Hm, do constraints work inside the game engine?

No constrains do not work in the game engine, that is why I posted the script above. It will do the same as constraints.

Ehm, I am not quite sure if that will work. Anyhow, that is why I posted a blend with the python setup. Take a look at it, I think it will solve your problems.

As a side-note, vertex parenting will work to keep the sun object following the camera, but not rotating with it.

I apologize for the late reply… game development is still a must do so not a lot of free time for me. I tried several different techniques and so far its much more complicated than I ever expected I am also not sure if the size of the level is a problem the level itself is very big its not even inside the grid any more and I cant shrink it either because it causes character speed issues and other game problems. I seen people stretch Spots but I have no luck with it.

As Solar Lune said ““As a side-note, vertex parenting will work to keep the sun object following the camera, but not rotating with it.”” this was my first attempt but with the lack of rotation it failed.

So far I am having a hard time with shadows than with any other thing at the time being.

Have you tried my setup?