Skip to content

Commit

Permalink
light: Add support for LIGHTING_E5BGR9.
Browse files Browse the repository at this point in the history
This is not really finished. Currently mutually exclusive with
regular RGBLIGHTING, and not tested with external .lit file.
  • Loading branch information
dsvensson committed Apr 28, 2024
1 parent e61630d commit 2ec4aca
Show file tree
Hide file tree
Showing 6 changed files with 185 additions and 60 deletions.
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,
};

/* 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

0 comments on commit 2ec4aca

Please sign in to comment.