Renegade Projects Network Forums
About lighting - Printable Version

+- Renegade Projects Network Forums (https://forums.renegadeprojects.com)
+-- Forum: Modding (https://forums.renegadeprojects.com/forumdisplay.php?fid=3)
+--- Forum: C&C Modding Encyclopedia (https://forums.renegadeprojects.com/forumdisplay.php?fid=7)
+--- Thread: About lighting (/showthread.php?tid=365)



About lighting - pd - 16.08.2006

I'm requesting some information about the lighting tags right now Tongue

What the hell are:
- Ambient
- AmbientChangeRate
- Ground
- Level
?

I firstly want to update my SW clone pages, secondly this is something ModEnc really should cover... I believe I'm not the only person not knowing what those values mean.


RE: About lighting - Bobingabout - 16.08.2006

i can't remember exactly, but they all do stuff.

gound i think is a yes/no tag, meaning at ground level

ambient and level are both tags that adjust brightness.

i can't remember excatly how they work, i used to just tweak values.


RE: About lighting - Renegade - 16.08.2006

http://www.modenc.renegadeprojects.com/Ambient
http://www.modenc.renegadeprojects.com/AmbientChangeRate
http://www.modenc.renegadeprojects.com/Ground
http://www.modenc.renegadeprojects.com/Level

...I don't quite see your problem.


RE: About lighting - DCoder - 17.08.2006

Yes, there are about 1700 pages we need to update ... takes time and dedication.

Btw, http://www.cncgames.com/maps_tut_lights_rvmech.shtml covers that stuff in more detail.


RE: About lighting - Guest - 19.06.2008

I'm not sure what you've already gathered, but I can tell you this:

When rendering pallets, the game needs the map's lighting settings.
The values in the map are multiplied by the values in the palet files. Ambient is the number of brightness added per higher level (tiles that have higher z-index).

Here's some code that calculates the used palets from the lighting section.

Code:
struct Lighting {
    double level;
    double ambient;
    double red;
    double green;
    double blue;
    Lighting();
    Lighting(const INI_Section& ini);
    void Read(const INI_Section& ini);
};

void Palet::Initialize(shared_ptr<File> f, const Lighting& l, bool greyscale) {
    // Level is the ammount of "more white" that is gained by highening tiles
    // Ambient is the overall ammount of light/darkness
    // Red, green and blue define alterations in respective colors

    // Initialize palet from file
    vector<unsigned char> data;
    f->read(data, 768);

    // load greyscales if needed
    if (greyscale)
        memcpy(&data[16*3], greyscales, 16 * 3);

    double ambient = l.ambient;

    // Add colors for 15 heights, each time adding level to ambient
    for (int j = 0; j < 15; j++) {
        // Three bytes per color, 256 colors
        for (int i = 0; i < 768; i += 3) {

            // shift 2 bits, only first 6 are used
            // don't go over 255, that'd look weird :D
            unsigned char r = std::min(
                255, static_cast<int>(ambient * l.red   * (data[i+0]<<2)));
            unsigned char g = std::min(
                255, static_cast<int>(ambient * l.green * (data[i+1]<<2)));
            unsigned char b = std::min(
                255, static_cast<int>(ambient * l.blue  * (data[i+2]<<2)));

            // Stored as int, although only first 24 bits are going to be used
            // Alignment required anyway
            colors.push_back(b + 256 * g + 65536 * r);
        }
        ambient += l.level;
    }
}

// returns pointer to a modified palet, can be used to draw SHP/TMP
// images with some adjusted form of light
int* Palet::Get_Colors(int Height) {
    return &colors[0] + 256 * Height;
}



Lighting L(myMap.Get_INI_Section("Lighting"));
Palet p_iso;
p_iso.Initialize(vfs.open("isosno.pal"), L);