Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

light: Add support for LIGHTING_E5BGR9. #421

Closed
wants to merge 1 commit into from

Conversation

dsvensson
Copy link
Contributor

@dsvensson dsvensson commented Apr 26, 2024

Forward port/adaptation of Spike's work in #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.

light/write.cc Outdated Show resolved Hide resolved
@ericwa
Copy link
Owner

ericwa commented Apr 27, 2024

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.

light/write.cc Outdated Show resolved Hide resolved
light/write.cc Show resolved Hide resolved
lit2 = 4
lit2 = 4,
hdr = 8,
bspxhdr = 16,
Copy link
Contributor Author

@dsvensson dsvensson Apr 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a separate enum-entry here to be able to distinguish between rgb and e5bgr9 bspx lump. I'm not particularly happy with the relation between these different flags. Need to have bspxhdr here to be able to write only e5bgr9 data, otherwise both that and rgb data would be written. With this setup -bspxlit and -bspxhdr would write both.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, I'm not sure if the enum class lightfile really does anything useful, thinking of removing it (later on) and just checking flags like light_options.lit.value() directly.

This is not really finished. Currently mutually exclusive with
regular RGBLIGHTING, and not tested with external .lit file.
@ericwa
Copy link
Owner

ericwa commented May 20, 2024

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

  • add a HDR_UnpackE5BRG9 decode function (uint32_t -> qvec3f)
  • tests for HDR_PackE5BRG9 + HDR_UnpackE5BRG9
  • rework HDR_PackE5BRG9 implementation to match opengl spec
  • lightpreview - add brightness slider
  • lightpreview - load + render
    • for .lit hdr format
    • for hdr bspx format
  • add an end-to-end test
    • for .lit hdr format
    • for hdr bspx format
  • final check in QSS/FTE that they have the expected appearance in game, match the appearance of vanilla lightmaps within the [0,255] range
    • for .lit hdr format
    • for hdr bspx format

I'll hopefully wrap this up soon + merge!

@dsvensson
Copy link
Contributor Author

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
Copy link
Owner

ericwa commented May 27, 2024

Merged this in 30868ea

@ericwa ericwa closed this May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants