ericwa / ericw-tools

Quake/Hexen 2 Map compiling tools - branch of http://disenchant.net/utils
http://ericwa.github.io/ericw-tools
GNU General Public License v2.0
329 stars 57 forks source link

light: Add support for LIGHTING_E5BGR9. #421

Closed dsvensson closed 4 months ago

dsvensson commented 5 months ago

Forward port/adaptation of Spike's work in https://github.com/ericwa/ericw-tools/pull/280 and not really fit for merging. Proposing it as draft in hope of getting help to figure out what needs to be done to get it into a mergable state.

The output of these lightmaps is supported by FTE, QSS, QSS-M.

The primary usecase is HDR and iris adaptation that alters the brightness between scenes with a delay of going from outdoors to indoors, but it also reduces banding due to the float nature. From a multiplayer perspective it allows for kicking up the brightness without lightmaps turning into pure garbage.

ericwa commented 5 months ago

Thanks for resurrecting this.

I think it's pretty close to good to merge, I've got a small docs update:

diff --git a/docs/light.rst b/docs/light.rst
index 2454c6c3..810ce0e2 100644
--- a/docs/light.rst
+++ b/docs/light.rst
@@ -315,6 +315,14 @@ Experimental options

    Writes lux data into the bsp itself.

+.. option:: -hdr
+
+   Write .lit file with e5bgr9 data.
+
+.. option:: -bspxhdr
+
+   Writes LIGHTING_E5BGR9 bspx lump.
+
 .. option:: -lmscale n

    Equivalent to "_lightmap_scale" worldspawn key.
diff --git a/light/light.cc b/light/light.cc
index 71a4bf14..fbb6edae 100644
--- a/light/light.cc
+++ b/light/light.cc
@@ -322,7 +322,7 @@ light_settings::light_settings()
           "writes lux data into the bsp itself"},
       hdr{this, "hdr", [&](source) { write_litfile |= lightfile::external; write_litfile |= lightfile::hdr; }, &experimental_group, "write .lit file with e5bgr9 data"},
       bspxhdr{this, "bspxhdr", [&](source) { write_litfile |= lightfile::bspx; write_litfile |= lightfile::hdr; }, &experimental_group,
-          "writes lux data into the bsp itself"},
+          "writes LIGHTING_E5BGR9 bspx lump"},
       bspxonly{this, "bspxonly",
           [&](source source) {
               write_litfile = lightfile::bspx;

I'd like to add a test or two that lights a map with -bspxhdr and then e5rgb9 sample back to a float, we have similar tests for decouple LM, regular Q1 .lit, Q2 vanilla lightmaps, etc.

I should also credit Spike in the final merge commit for the initial patch.

ericwa commented 4 months ago

I'm doing the last batch of changes I wanted to add to this in my branch https://github.com/ericwa/ericw-tools/tree/hdr

I'll hopefully wrap this up soon + merge!

dsvensson commented 4 months ago

Thank you so much for picking this up. Was about to return to this after focusing on another project for the past few weeks. Your improvements look much better than what I would have been able to pull off. 🙏

ericwa commented 4 months ago

Merged this in https://github.com/ericwa/ericw-tools/commit/30868eacb7412a82b6aaa38950afbac1b3c36418