Q2-specific fix; -1 lightmaps are always fullbright, which can cause actual full-dark areas to be full bright by mistake
This commit is contained in:
parent
14ac139cce
commit
85f25bbc78
|
|
@ -58,5 +58,5 @@ bool Face_IsLightmapped(const mbsp_t *bsp, const mface_t *face);
|
|||
void DirectLightFace(const mbsp_t *bsp, lightsurf_t &lightsurf, const settings::worldspawn_keys &cfg);
|
||||
void IndirectLightFace(const mbsp_t *bsp, lightsurf_t &lightsurf, const settings::worldspawn_keys &cfg);
|
||||
void FinishLightmapSurface(const mbsp_t *bsp, lightsurf_t *lightsurf);
|
||||
void SaveLightmapSurface(const mbsp_t *bsp, mface_t *face, facesup_t *facesup, const lightsurf_t *lightsurf,
|
||||
void SaveLightmapSurface(const mbsp_t *bsp, mface_t *face, facesup_t *facesup, lightsurf_t *lightsurf,
|
||||
const faceextents_t &extents, const faceextents_t &output_extents);
|
||||
|
|
|
|||
|
|
@ -2701,10 +2701,10 @@ static void WriteSingleLightmap(const mbsp_t *bsp, const mface_t *face, const li
|
|||
}
|
||||
}
|
||||
|
||||
void SaveLightmapSurface(const mbsp_t *bsp, mface_t *face, facesup_t *facesup, const lightsurf_t *lightsurf,
|
||||
void SaveLightmapSurface(const mbsp_t *bsp, mface_t *face, facesup_t *facesup, lightsurf_t *lightsurf,
|
||||
const faceextents_t &extents, const faceextents_t &output_extents)
|
||||
{
|
||||
const lightmapdict_t &lightmaps = lightsurf->lightmapsByStyle;
|
||||
lightmapdict_t &lightmaps = lightsurf->lightmapsByStyle;
|
||||
const int actual_width = extents.width();
|
||||
const int actual_height = extents.height();
|
||||
const int output_width = output_extents.width();
|
||||
|
|
@ -2795,6 +2795,17 @@ void SaveLightmapSurface(const mbsp_t *bsp, mface_t *face, facesup_t *facesup, c
|
|||
sortable.emplace_back(avgb, &lightmap);
|
||||
}
|
||||
|
||||
// HACK: in Q2, if lightofs is -1, then it's drawn fullbright,
|
||||
// so we can't optimize away unused portions of the lightmap.
|
||||
if (bsp->loadversion->game->id == GAME_QUAKE_II) {
|
||||
if (!sortable.size()) {
|
||||
lightmap_t *lm = Lightmap_ForStyle(&lightmaps, 0, lightsurf);
|
||||
lm->style = 0;
|
||||
std::fill(lightsurf->occluded.begin(), lightsurf->occluded.end(), false);
|
||||
sortable.emplace_back(0, lm);
|
||||
}
|
||||
}
|
||||
|
||||
// sort in descending order of average brightness
|
||||
std::sort(sortable.begin(), sortable.end());
|
||||
std::reverse(sortable.begin(), sortable.end());
|
||||
|
|
@ -2831,6 +2842,10 @@ void SaveLightmapSurface(const mbsp_t *bsp, mface_t *face, facesup_t *facesup, c
|
|||
const int numstyles = static_cast<int>(sorted.size());
|
||||
Q_assert(numstyles <= MAXLIGHTMAPSSUP);
|
||||
|
||||
if (bsp->loadversion->game->id == GAME_QUAKE_II) {
|
||||
Q_assert(numstyles > 0);
|
||||
}
|
||||
|
||||
/* update face info (either core data or supplementary stuff) */
|
||||
if (facesup) {
|
||||
facesup->extent[0] = output_width;
|
||||
|
|
|
|||
Loading…
Reference in New Issue