Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/light.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,14 @@ Experimental options

Writes both rgb and directions data *only* into the bsp itself.

.. option:: -hdr

Write .lit file with e5bgr9 data.

.. option:: -bspxhdr

Writes e5bgr9 data into the bsp itself.

.. option:: -novanilla

Fallback scaled lighting will be omitted. Standard grey lighting will
Expand Down
6 changes: 5 additions & 1 deletion include/light/light.hh
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ enum class lightfile
external = 1,
bspx = 2,
both = external | bspx,
lit2 = 4
lit2 = 4,
hdr = 8,
bspxhdr = 16,

@dsvensson dsvensson Apr 28, 2024

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown
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.

};

/* tracelist is a std::vector of pointers to modelinfo_t to use for LOS tests */
Expand Down Expand Up @@ -393,6 +395,8 @@ public:
setting_func bspxlux;
setting_func bspxonly;
setting_func bspx;
setting_func hdr;
setting_func bspxhdr;
setting_scalar world_units_per_luxel;
setting_bool litonly;
setting_bool nolights;
Expand Down
3 changes: 2 additions & 1 deletion include/light/write.hh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct mbsp_t;
struct bspdata_t;

constexpr int32_t LIT_VERSION = 1;
constexpr int32_t LIT_VERSION_E5BGR9 = (0x00010000 | LIT_VERSION);

struct litheader_t
{
Expand Down Expand Up @@ -67,7 +68,7 @@ struct facesup_t
twosided<uint16_t> extent;
};

void WriteLitFile(const mbsp_t *bsp, const std::vector<facesup_t> &facesup, const fs::path &filename, int version, const std::vector<uint8_t> &lit_filebase, const std::vector<uint8_t> &lux_filebase);
void WriteLitFile(const mbsp_t *bsp, const std::vector<facesup_t> &facesup, const fs::path &filename, int version, const std::vector<uint8_t> &lit_filebase, const std::vector<uint8_t> &lux_filebase, const std::vector<uint8_t> &hdr_filebase);
void WriteLuxFile(const mbsp_t *bsp, const fs::path &filename, int version, const std::vector<uint8_t> &lux_filebase);

void SaveLightmapSurfaces(bspdata_t *bspdata, const fs::path &source);
12 changes: 12 additions & 0 deletions light/light.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,18 @@ light_settings::light_settings()
write_luxfile = lightfile::bspx;
},
&experimental_group, "writes both rgb and directions 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::hdr;
write_litfile |= lightfile::bspxhdr;
},
&experimental_group, "writes e5bgr9 data into the bsp itself"},
world_units_per_luxel{
this, "world_units_per_luxel", 0, 0, 1024, &output_group, "enables output of DECOUPLED_LM BSPX lump"},
litonly{this, "litonly", false, &output_group, "only write .lit file, don't modify BSP"},
Expand Down
8 changes: 0 additions & 8 deletions light/ltface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2453,14 +2453,6 @@ static void LightPoint_ScaleAndClamp(qvec3f &color)
c = pow(c / 255.0f, 1.0f / cfg.lightmapgamma.value()) * 255.0f;
}
}

// clamp
// FIXME: should this be a brightness clamp?
float maxcolor = qv::max(color);

if (maxcolor > 255.0f) {
color *= (255.0f / maxcolor);
}
}

static void LightPoint_ScaleAndClamp(lightgrid_samples_t &result)
Expand Down
Loading