[iortcw] 132/152: All: Rend2: Non-square merged lightmaps
Simon McVittie
smcv at debian.org
Fri Sep 8 10:40:24 UTC 2017
This is an automated email from the git hooks/post-receive script.
smcv pushed a commit to annotated tag 1.5a
in repository iortcw.
commit fda688b597d03fd0a53c71017018b0d9be8fccf1
Author: MAN-AT-ARMS <M4N4T4RMS at gmail.com>
Date: Sat Oct 15 11:03:19 2016 -0400
All: Rend2: Non-square merged lightmaps
---
MP/code/rend2/tr_bsp.c | 128 +++++++++++++++++------------------------------
MP/code/rend2/tr_local.h | 4 +-
SP/code/rend2/tr_bsp.c | 128 +++++++++++++++++------------------------------
SP/code/rend2/tr_local.h | 4 +-
4 files changed, 94 insertions(+), 170 deletions(-)
diff --git a/MP/code/rend2/tr_bsp.c b/MP/code/rend2/tr_bsp.c
index 719766e..a22d8f4 100644
--- a/MP/code/rend2/tr_bsp.c
+++ b/MP/code/rend2/tr_bsp.c
@@ -207,13 +207,14 @@ R_LoadLightmaps
===============
*/
#define DEFAULT_LIGHTMAP_SIZE 128
-#define MAX_LIGHTMAP_PAGES 2
static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
+ imgFlags_t imgFlags = IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE;
byte *buf, *buf_p;
dsurface_t *surf;
int len;
byte *image;
int i, j, numLightmaps, textureInternalFormat = 0;
+ int numLightmapsPerPage = 16;
float maxIntensity = 0;
double sumIntensity = 0;
@@ -253,36 +254,24 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (tr.worldDeluxeMapping)
numLightmaps >>= 1;
- if(numLightmaps == 1)
- {
- //FIXME: HACK: maps with only one lightmap turn up fullbright for some reason.
- //this avoids this, but isn't the correct solution.
- numLightmaps++;
- }
- else if (r_mergeLightmaps->integer && numLightmaps >= 1024 )
- {
- // FIXME: fat light maps don't support more than 1024 light maps
- ri.Printf(PRINT_WARNING, "WARNING: number of lightmaps > 1024\n");
- numLightmaps = 1024;
- }
-
- // use fat lightmaps of an appropriate size
+ // Use fat lightmaps of an appropriate size.
if (r_mergeLightmaps->integer)
{
- tr.fatLightmapSize = 512;
- tr.fatLightmapStep = tr.fatLightmapSize / tr.lightmapSize;
+ int maxLightmapsPerAxis = glConfig.maxTextureSize / tr.lightmapSize;
+ int lightmapCols = 4, lightmapRows = 4;
- // at most MAX_LIGHTMAP_PAGES
- while (tr.fatLightmapStep * tr.fatLightmapStep * MAX_LIGHTMAP_PAGES < numLightmaps && tr.fatLightmapSize != glConfig.maxTextureSize )
- {
- tr.fatLightmapSize <<= 1;
- tr.fatLightmapStep = tr.fatLightmapSize / tr.lightmapSize;
- }
+ // Increase width at first, then height.
+ while (lightmapCols * lightmapRows < numLightmaps && lightmapCols != maxLightmapsPerAxis)
+ lightmapCols <<= 1;
- tr.numLightmaps = numLightmaps / (tr.fatLightmapStep * tr.fatLightmapStep);
+ while (lightmapCols * lightmapRows < numLightmaps && lightmapRows != maxLightmapsPerAxis)
+ lightmapRows <<= 1;
- if (numLightmaps % (tr.fatLightmapStep * tr.fatLightmapStep) != 0)
- tr.numLightmaps++;
+ tr.fatLightmapCols = lightmapCols;
+ tr.fatLightmapRows = lightmapRows;
+ numLightmapsPerPage = lightmapCols * lightmapRows;
+
+ tr.numLightmaps = (numLightmaps + (numLightmapsPerPage - 1)) / numLightmapsPerPage;
}
else
{
@@ -292,9 +281,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
tr.lightmaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low );
if (tr.worldDeluxeMapping)
- {
tr.deluxemaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low );
- }
if (glRefConfig.floatLightmap)
textureInternalFormat = GL_RGBA16F_ARB;
@@ -303,14 +290,15 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (r_mergeLightmaps->integer)
{
+ int width = tr.fatLightmapCols * tr.lightmapSize;
+ int height = tr.fatLightmapRows * tr.lightmapSize;
+
for (i = 0; i < tr.numLightmaps; i++)
{
- tr.lightmaps[i] = R_CreateImage(va("_fatlightmap%d", i), NULL, tr.fatLightmapSize, tr.fatLightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat );
+ tr.lightmaps[i] = R_CreateImage(va("_fatlightmap%d", i), NULL, width, height, IMGTYPE_COLORALPHA, imgFlags, textureInternalFormat);
if (tr.worldDeluxeMapping)
- {
- tr.deluxemaps[i] = R_CreateImage(va("_fatdeluxemap%d", i), NULL, tr.fatLightmapSize, tr.fatLightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 );
- }
+ tr.deluxemaps[i] = R_CreateImage(va("_fatdeluxemap%d", i), NULL, width, height, IMGTYPE_DELUXE, imgFlags, 0);
}
}
@@ -322,11 +310,11 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (r_mergeLightmaps->integer)
{
- int lightmaponpage = i % (tr.fatLightmapStep * tr.fatLightmapStep);
- xoff = (lightmaponpage % tr.fatLightmapStep) * tr.lightmapSize;
- yoff = (lightmaponpage / tr.fatLightmapStep) * tr.lightmapSize;
+ int lightmaponpage = i % numLightmapsPerPage;
+ xoff = (lightmaponpage % tr.fatLightmapCols) * tr.lightmapSize;
+ yoff = (lightmaponpage / tr.fatLightmapCols) * tr.lightmapSize;
- lightmapnum /= (tr.fatLightmapStep * tr.fatLightmapStep);
+ lightmapnum /= numLightmapsPerPage;
}
// if (tr.worldLightmapping)
@@ -346,47 +334,37 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (hdrLightmap)
{
- byte *p = hdrLightmap;
+ byte *p = hdrLightmap, *end = hdrLightmap + size;
//ri.Printf(PRINT_ALL, "found!\n");
/* FIXME: don't just skip over this header and actually parse it */
- while (size && !(*p == '\n' && *(p+1) == '\n'))
- {
- size--;
+ while (p < end && !(*p == '\n' && *(p+1) == '\n'))
p++;
- }
-
- if (!size)
- ri.Error(ERR_DROP, "Bad header for %s!", filename);
- size -= 2;
p += 2;
- while (size && !(*p == '\n'))
- {
- size--;
+ while (p < end && !(*p == '\n'))
p++;
- }
- size--;
p++;
- buf_p = (byte *)p;
+ if (p >= end)
+ ri.Error(ERR_DROP, "Bad header for %s!", filename);
+
+ buf_p = p;
#if 0 // HDRFILE_RGBE
- if (size != tr.lightmapSize * tr.lightmapSize * 4)
+ if ((int)(end - hdrLightmap) != tr.lightmapSize * tr.lightmapSize * 4)
ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size);
#else // HDRFILE_FLOAT
- if (size != tr.lightmapSize * tr.lightmapSize * 12)
+ if ((int)(end - hdrLightmap) != tr.lightmapSize * tr.lightmapSize * 12)
ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size);
#endif
}
else
{
- if (tr.worldDeluxeMapping)
- buf_p = buf + (i * 2) * tr.lightmapSize * tr.lightmapSize * 3;
- else
- buf_p = buf + i * tr.lightmapSize * tr.lightmapSize * 3;
+ int imgOffset = tr.worldDeluxeMapping ? i * 2 : i;
+ buf_p = buf + imgOffset * tr.lightmapSize * tr.lightmapSize * 3;
}
for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ )
@@ -480,7 +458,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (r_mergeLightmaps->integer)
R_UpdateSubImage(tr.lightmaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize);
else
- tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat );
+ tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_COLORALPHA, imgFlags, textureInternalFormat );
if (hdrLightmap)
ri.FS_FreeFile(hdrLightmap);
@@ -507,13 +485,9 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
}
if (r_mergeLightmaps->integer)
- {
R_UpdateSubImage(tr.deluxemaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize );
- }
else
- {
- tr.deluxemaps[i] = R_CreateImage(va("*deluxemap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 );
- }
+ tr.deluxemaps[i] = R_CreateImage(va("*deluxemap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_DELUXE, imgFlags, 0 );
}
}
@@ -532,15 +506,10 @@ static float FatPackU(float input, int lightmapnum)
if (tr.worldDeluxeMapping)
lightmapnum >>= 1;
- if(tr.fatLightmapSize > 0)
+ if (tr.fatLightmapCols > 0)
{
- int x;
-
- lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep);
-
- x = lightmapnum % tr.fatLightmapStep;
-
- return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)x);
+ lightmapnum %= (tr.fatLightmapCols * tr.fatLightmapRows);
+ return (input + (lightmapnum % tr.fatLightmapCols)) / (float)(tr.fatLightmapCols);
}
return input;
@@ -554,15 +523,10 @@ static float FatPackV(float input, int lightmapnum)
if (tr.worldDeluxeMapping)
lightmapnum >>= 1;
- if(tr.fatLightmapSize > 0)
+ if (tr.fatLightmapCols > 0)
{
- int y;
-
- lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep);
-
- y = lightmapnum / tr.fatLightmapStep;
-
- return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)y);
+ lightmapnum %= (tr.fatLightmapCols * tr.fatLightmapRows);
+ return (input + (lightmapnum / tr.fatLightmapCols)) / (float)(tr.fatLightmapRows);
}
return input;
@@ -577,10 +541,8 @@ static int FatLightmap(int lightmapnum)
if (tr.worldDeluxeMapping)
lightmapnum >>= 1;
- if (tr.fatLightmapSize > 0)
- {
- return lightmapnum / (tr.fatLightmapStep * tr.fatLightmapStep);
- }
+ if (tr.fatLightmapCols > 0)
+ return lightmapnum / (tr.fatLightmapCols * tr.fatLightmapRows);
return lightmapnum;
}
diff --git a/MP/code/rend2/tr_local.h b/MP/code/rend2/tr_local.h
index 7283a6b..a766b21 100644
--- a/MP/code/rend2/tr_local.h
+++ b/MP/code/rend2/tr_local.h
@@ -1683,8 +1683,8 @@ typedef struct {
image_t **lightmaps;
image_t **deluxemaps;
- int fatLightmapSize;
- int fatLightmapStep;
+ int fatLightmapCols;
+ int fatLightmapRows;
int numCubemaps;
cubemap_t *cubemaps;
diff --git a/SP/code/rend2/tr_bsp.c b/SP/code/rend2/tr_bsp.c
index 5331b34..d5c4858 100644
--- a/SP/code/rend2/tr_bsp.c
+++ b/SP/code/rend2/tr_bsp.c
@@ -207,13 +207,14 @@ R_LoadLightmaps
===============
*/
#define DEFAULT_LIGHTMAP_SIZE 128
-#define MAX_LIGHTMAP_PAGES 2
static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
+ imgFlags_t imgFlags = IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE;
byte *buf, *buf_p;
dsurface_t *surf;
int len;
byte *image;
int i, j, numLightmaps, textureInternalFormat = 0;
+ int numLightmapsPerPage = 16;
float maxIntensity = 0;
double sumIntensity = 0;
@@ -253,36 +254,24 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (tr.worldDeluxeMapping)
numLightmaps >>= 1;
- if(numLightmaps == 1)
- {
- //FIXME: HACK: maps with only one lightmap turn up fullbright for some reason.
- //this avoids this, but isn't the correct solution.
- numLightmaps++;
- }
- else if (r_mergeLightmaps->integer && numLightmaps >= 1024 )
- {
- // FIXME: fat light maps don't support more than 1024 light maps
- ri.Printf(PRINT_WARNING, "WARNING: number of lightmaps > 1024\n");
- numLightmaps = 1024;
- }
-
- // use fat lightmaps of an appropriate size
+ // Use fat lightmaps of an appropriate size.
if (r_mergeLightmaps->integer)
{
- tr.fatLightmapSize = 512;
- tr.fatLightmapStep = tr.fatLightmapSize / tr.lightmapSize;
+ int maxLightmapsPerAxis = glConfig.maxTextureSize / tr.lightmapSize;
+ int lightmapCols = 4, lightmapRows = 4;
- // at most MAX_LIGHTMAP_PAGES
- while (tr.fatLightmapStep * tr.fatLightmapStep * MAX_LIGHTMAP_PAGES < numLightmaps && tr.fatLightmapSize != glConfig.maxTextureSize )
- {
- tr.fatLightmapSize <<= 1;
- tr.fatLightmapStep = tr.fatLightmapSize / tr.lightmapSize;
- }
+ // Increase width at first, then height.
+ while (lightmapCols * lightmapRows < numLightmaps && lightmapCols != maxLightmapsPerAxis)
+ lightmapCols <<= 1;
- tr.numLightmaps = numLightmaps / (tr.fatLightmapStep * tr.fatLightmapStep);
+ while (lightmapCols * lightmapRows < numLightmaps && lightmapRows != maxLightmapsPerAxis)
+ lightmapRows <<= 1;
- if (numLightmaps % (tr.fatLightmapStep * tr.fatLightmapStep) != 0)
- tr.numLightmaps++;
+ tr.fatLightmapCols = lightmapCols;
+ tr.fatLightmapRows = lightmapRows;
+ numLightmapsPerPage = lightmapCols * lightmapRows;
+
+ tr.numLightmaps = (numLightmaps + (numLightmapsPerPage - 1)) / numLightmapsPerPage;
}
else
{
@@ -291,9 +280,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
tr.lightmaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low );
if (tr.worldDeluxeMapping)
- {
tr.deluxemaps = ri.Hunk_Alloc( tr.numLightmaps * sizeof(image_t *), h_low );
- }
if (glRefConfig.floatLightmap)
textureInternalFormat = GL_RGBA16F_ARB;
@@ -302,14 +289,15 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (r_mergeLightmaps->integer)
{
+ int width = tr.fatLightmapCols * tr.lightmapSize;
+ int height = tr.fatLightmapRows * tr.lightmapSize;
+
for (i = 0; i < tr.numLightmaps; i++)
{
- tr.lightmaps[i] = R_CreateImage(va("_fatlightmap%d", i), NULL, tr.fatLightmapSize, tr.fatLightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat );
+ tr.lightmaps[i] = R_CreateImage(va("_fatlightmap%d", i), NULL, width, height, IMGTYPE_COLORALPHA, imgFlags, textureInternalFormat);
if (tr.worldDeluxeMapping)
- {
- tr.deluxemaps[i] = R_CreateImage(va("_fatdeluxemap%d", i), NULL, tr.fatLightmapSize, tr.fatLightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 );
- }
+ tr.deluxemaps[i] = R_CreateImage(va("_fatdeluxemap%d", i), NULL, width, height, IMGTYPE_DELUXE, imgFlags, 0);
}
}
@@ -320,11 +308,11 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
// expand the 24 bit on-disk to 32 bit
if (r_mergeLightmaps->integer)
{
- int lightmaponpage = i % (tr.fatLightmapStep * tr.fatLightmapStep);
- xoff = (lightmaponpage % tr.fatLightmapStep) * tr.lightmapSize;
- yoff = (lightmaponpage / tr.fatLightmapStep) * tr.lightmapSize;
+ int lightmaponpage = i % numLightmapsPerPage;
+ xoff = (lightmaponpage % tr.fatLightmapCols) * tr.lightmapSize;
+ yoff = (lightmaponpage / tr.fatLightmapCols) * tr.lightmapSize;
- lightmapnum /= (tr.fatLightmapStep * tr.fatLightmapStep);
+ lightmapnum /= numLightmapsPerPage;
}
// if (tr.worldLightmapping)
@@ -344,47 +332,37 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (hdrLightmap)
{
- byte *p = hdrLightmap;
+ byte *p = hdrLightmap, *end = hdrLightmap + size;
//ri.Printf(PRINT_ALL, "found!\n");
/* FIXME: don't just skip over this header and actually parse it */
- while (size && !(*p == '\n' && *(p+1) == '\n'))
- {
- size--;
+ while (p < end && !(*p == '\n' && *(p+1) == '\n'))
p++;
- }
-
- if (!size)
- ri.Error(ERR_DROP, "Bad header for %s!", filename);
- size -= 2;
p += 2;
- while (size && !(*p == '\n'))
- {
- size--;
+ while (p < end && !(*p == '\n'))
p++;
- }
- size--;
p++;
- buf_p = (byte *)p;
+ if (p >= end)
+ ri.Error(ERR_DROP, "Bad header for %s!", filename);
+
+ buf_p = p;
#if 0 // HDRFILE_RGBE
- if (size != tr.lightmapSize * tr.lightmapSize * 4)
+ if ((int)(end - hdrLightmap) != tr.lightmapSize * tr.lightmapSize * 4)
ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size);
#else // HDRFILE_FLOAT
- if (size != tr.lightmapSize * tr.lightmapSize * 12)
+ if ((int)(end - hdrLightmap) != tr.lightmapSize * tr.lightmapSize * 12)
ri.Error(ERR_DROP, "Bad size for %s (%i)!", filename, size);
#endif
}
else
{
- if (tr.worldDeluxeMapping)
- buf_p = buf + (i * 2) * tr.lightmapSize * tr.lightmapSize * 3;
- else
- buf_p = buf + i * tr.lightmapSize * tr.lightmapSize * 3;
+ int imgOffset = tr.worldDeluxeMapping ? i * 2 : i;
+ buf_p = buf + imgOffset * tr.lightmapSize * tr.lightmapSize * 3;
}
for ( j = 0 ; j < tr.lightmapSize * tr.lightmapSize; j++ )
@@ -479,7 +457,7 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
if (r_mergeLightmaps->integer)
R_UpdateSubImage(tr.lightmaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize);
else
- tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_COLORALPHA, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, textureInternalFormat );
+ tr.lightmaps[i] = R_CreateImage(va("*lightmap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_COLORALPHA, imgFlags, textureInternalFormat );
if (hdrLightmap)
ri.FS_FreeFile(hdrLightmap);
@@ -506,13 +484,9 @@ static void R_LoadLightmaps( lump_t *l, lump_t *surfs ) {
}
if (r_mergeLightmaps->integer)
- {
R_UpdateSubImage(tr.deluxemaps[lightmapnum], image, xoff, yoff, tr.lightmapSize, tr.lightmapSize );
- }
else
- {
- tr.deluxemaps[i] = R_CreateImage(va("*deluxemap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_DELUXE, IMGFLAG_NOLIGHTSCALE | IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, 0 );
- }
+ tr.deluxemaps[i] = R_CreateImage(va("*deluxemap%d", i), image, tr.lightmapSize, tr.lightmapSize, IMGTYPE_DELUXE, imgFlags, 0 );
}
}
@@ -531,15 +505,10 @@ static float FatPackU(float input, int lightmapnum)
if (tr.worldDeluxeMapping)
lightmapnum >>= 1;
- if(tr.fatLightmapSize > 0)
+ if (tr.fatLightmapCols > 0)
{
- int x;
-
- lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep);
-
- x = lightmapnum % tr.fatLightmapStep;
-
- return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)x);
+ lightmapnum %= (tr.fatLightmapCols * tr.fatLightmapRows);
+ return (input + (lightmapnum % tr.fatLightmapCols)) / (float)(tr.fatLightmapCols);
}
return input;
@@ -553,15 +522,10 @@ static float FatPackV(float input, int lightmapnum)
if (tr.worldDeluxeMapping)
lightmapnum >>= 1;
- if(tr.fatLightmapSize > 0)
+ if (tr.fatLightmapCols > 0)
{
- int y;
-
- lightmapnum %= (tr.fatLightmapStep * tr.fatLightmapStep);
-
- y = lightmapnum / tr.fatLightmapStep;
-
- return (input / ((float)tr.fatLightmapStep)) + ((1.0 / ((float)tr.fatLightmapStep)) * (float)y);
+ lightmapnum %= (tr.fatLightmapCols * tr.fatLightmapRows);
+ return (input + (lightmapnum / tr.fatLightmapCols)) / (float)(tr.fatLightmapRows);
}
return input;
@@ -576,10 +540,8 @@ static int FatLightmap(int lightmapnum)
if (tr.worldDeluxeMapping)
lightmapnum >>= 1;
- if (tr.fatLightmapSize > 0)
- {
- return lightmapnum / (tr.fatLightmapStep * tr.fatLightmapStep);
- }
+ if (tr.fatLightmapCols > 0)
+ return lightmapnum / (tr.fatLightmapCols * tr.fatLightmapRows);
return lightmapnum;
}
diff --git a/SP/code/rend2/tr_local.h b/SP/code/rend2/tr_local.h
index bfa92d9..0f48b4d 100644
--- a/SP/code/rend2/tr_local.h
+++ b/SP/code/rend2/tr_local.h
@@ -1697,8 +1697,8 @@ typedef struct {
image_t **lightmaps;
image_t **deluxemaps;
- int fatLightmapSize;
- int fatLightmapStep;
+ int fatLightmapCols;
+ int fatLightmapRows;
int numCubemaps;
cubemap_t *cubemaps;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/iortcw.git
More information about the Pkg-games-commits
mailing list