RagnarokFileFormats
RagnarokFileFormats copied to clipboard
Research the RSW ambient light source's properties
My rendition didn't look quite right. I think the angles were calculated incorrectly, so let's find out what they're actually doing. It also appears they used the colors differently than I would expect.
Dumping my notes here so they're archived and I can delete them:
Ambient Light WIP
For a given map, the RSW file includes information about the map's ambient light source (global illumination)
- Diffuse color: This is the color of the ambient light source
- Direction (latitude and longitude)
- Fog (optional): FogParameterTable?
Light Sources
- RGBA is stored as FLOAT32, not INT (FlavioJS/ROB are wrong)
- range = falloff OR hide? I think it's the latter? OR are they not used at all?
Unused by client, but can be used to reconstruct the dynamic lights used to generate the lightmaps (including shadows on walls/slopes)?
Weirdly aligned, on a plane centered at the ORIGIN and Y values form a plane/rotated slope? (45 degree in Y?) Solutions/workarounds? Either set to GAT height, or rotate and abs to make sure they're above ground? Tricky... Also, shifted via offset?
Light Falloff (BrowEdit)
First light: Put it up in the middle of the map, high in the air, big enough to cover the whole thing. Intensity should be 127, light falloff should be 0.01. Make sure it doesn't cast shadows. This is the light that makes your map not pitch-black.
Second light: If you mentally divide your map into four quadrants, put this light somewhere high up in the bottom-left one, but not right at the corner of the map. Set the intensity to 100, make sure it's big enough to cover the whole map. Light falloff should again be 0.01. Make sure this one casts shadows- That's what it's there for.
Now calculate lights, and -bam-, that is literally all you need to do for to get basic shadows on 99% of your maps, ever. Cool, huh?
Bonus points: Put down some canopy models right on the floor, and calculate the lights. When the shadows are down, delete these- You'll be left with that cool canopy effect that they have in Payon in-game. (If you ever looked at Payon without shadows, you'd be surprised how much of it is just empty space.)
As you 'll notice there is now a Diffuse Light Section and a Ambient Light Section. Both sections will give you control over the lighting and how much you want. It's more of changing it to how you best think it should look and trying it out ingame. You best option is to probably think of the 2 sections like this, The diffused light is your source light and coming from the opposite direction is the ambient light which lightens up the shadows of the objects and hillsides.
Diffuse Light (Color): Used to change the lighting of your map and is set in a Red, Green, Blue layout with 1 being 100% and 0 being 0%.
Diffuse Light (Longitude angle): This sets the horizontal angle in which your light source comes from this allows you to change the ambient light from it's default angle or something like 45° to a different side for walls and objects to have their shadows on. Usefull for maps with the sun coming from the south / east or north / east direction instead of the normal south / west direction.
Diffuse Light (Latitude angle): This sets the vertical angle in which your light source comes from this allows you to change the ambient light from it's default angle or something like 45° to a higher or lower angle for high noon sun or setting sun type maps.
Ambient Light (Color): Used to change the lighting of the shadows on your map and is set in a Red, Green, Blue layout with 1 being 100% and 0 being 0%.
Ambient Light (Intensity): This is kind of like the brightness of your source light, 1 being 100% bright and 0 having no light at all (Your light will then only come from the Diffuse Light settings if you set this to ).
References
-
this.ambientLight.color = (new THREE.Color).setRGB( Math.min(1.0, 0.75 * this.rswFileObject.header.diffuseCol[0] + 0.75 * this.rswFileObject.header.ambientCol[0]), Math.min(1.0, 0.75 * this.rswFileObject.header.diffuseCol[1] + 0.75 * this.rswFileObject.header.ambientCol[1]), Math.min(1.0, 0.75 * this.rswFileObject.header.diffuseCol[2] + 0.75 * this.rswFileObject.header.ambientCol[2]) );
That's from RagnarokJS, obviously. No idea if it's correct, haven't looked into this more.
Also, the RSW spec should include details on both light sources and how they're to be used. One to be multiplied with textures (diffuse), and the other to be applied to shadows (ambient?).
RoBrowser uses yet another different setting, but it also doesn't look quite correct.
My guess after reviewing this issue with some distance would be to check first if Borf already figured this one out. If BrowEdit's rendition is "good enough" that would already be sufficient for most intents and purposes.