Lighting in the virtual world

 Several months ago I decided to go to a disco and because there were so many people the lag was unbearable. So I kept my graphics to a minimum. When I returned to my virtual home, I forgot to put the graphic configuration as I had previously.

I noticed something very strange, it was totally dark but the lights were not on. One of the most basic scripts that can be done is to detect when it is night or day. If it is night, turn on the lights automatically. But my script apparently didn't work, why?

To investigate the matter, I built a tool that marked the position of the sun.

The script comes below:

string GetTimeOfDay(float dayFraction) 
    integer hours = (integer)(dayFraction * 24);
    integer minutes = (integer)(dayFraction * 24 * 60) % 60;
    integer percent = (integer)(dayFraction * 100);
    return (string)hours + ":" + llGetSubString((string)(100+minutes), 1, 2) + " (" + (string)percent + "%)";

        llSetText("", ZERO_VECTOR, 0);
        llSetTimerEvent(5); // Check every 5 seconds
        vector sun = llGetSunDirection();
        integer dayLength = llGetDayLength();
        integer dayOffset = llGetDayOffset();
        string text = "Day Length: " + (string) dayLength + "\n";
        text += "Day Offset: " + (string) dayOffset + "\n";
        text += "Sun position: " + (string) sun + "\n";
        float timeOfDay = (llGetUnixTime() + llGetDayOffset()) % llGetDayLength() * 1.0 / llGetDayLength();
        text += GetTimeOfDay(timeOfDay);
        llSetText(text, <1.0, 1.0, 1.0>, 1.0);


I realized that even when it was daytime I saw everything dark. I came to believe that the day and night cycles in SL were malfunctioning. Until I realized that I had the "Atmospheric shaders" setting turned off. As soon as I enabled that option everything clicked and I realized that the lighting system worked perfectly.

However, when I enabled the "Advanced Lighting Model" option and at the same time the shadows the same thing happened again. The interiors become very dark.

In the real world, the same thing happens, even if it is daytime if you are inside a building without windows you need lighting. But when there are windows at least some light comes in.

All this makes me reflect, that perhaps automatic lighting does not depend only on the sun being above the horizon. There should be a "lux meter" function, but still visitors coming to a site can have different settings.

It is probably best to leave the automatic lighting for outdoors and indoors to always have the light on. Or if there is a script that has three options "Always ON", "Always OFF" and "Automatic"


Popular posts from this blog

Reading headers in a PHP script

Linksets in SecondLife (2)