diff --git a/src/client/refresh/gl1/header/model.h b/src/client/refresh/gl1/header/model.h index a4b36e0d..8f38e0c0 100644 --- a/src/client/refresh/gl1/header/model.h +++ b/src/client/refresh/gl1/header/model.h @@ -28,7 +28,6 @@ #define REF_MODEL_H #define VERTEXSIZE 7 -#define DEFAULT_LMSHIFT 4 /* in memory representation */ @@ -53,7 +52,6 @@ typedef struct msurface_s short texturemins[2]; short extents[2]; - short lmshift; int light_s, light_t; /* gl lightmap coordinates */ diff --git a/src/client/refresh/gl3/gl3_light.c b/src/client/refresh/gl3/gl3_light.c index b3ed1f5c..895cdb91 100644 --- a/src/client/refresh/gl3/gl3_light.c +++ b/src/client/refresh/gl3/gl3_light.c @@ -193,13 +193,13 @@ RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end) return 0; } - ds >>= 4; - dt >>= 4; + ds >>= surf->lmshift; + dt >>= surf->lmshift; lightmap = surf->samples; VectorCopy(vec3_origin, pointcolor); - lightmap += 3 * (dt * ((surf->extents[0] >> 4) + 1) + ds); + lightmap += 3 * (dt * ((surf->extents[0] >> surf->lmshift) + 1) + ds); for (maps = 0; maps < MAX_LIGHTMAPS_PER_SURFACE && surf->styles[maps] != 255; maps++) @@ -218,8 +218,8 @@ RecursiveLightPoint(mnode_t *node, vec3_t start, vec3_t end) pointcolor[j] += lightmap[j] * scale * (1.0 / 255); } - lightmap += 3 * ((surf->extents[0] >> 4) + 1) * - ((surf->extents[1] >> 4) + 1); + lightmap += 3 * ((surf->extents[0] >> surf->lmshift) + 1) * + ((surf->extents[1] >> surf->lmshift) + 1); } return 1; @@ -300,8 +300,8 @@ GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride) ri.Sys_Error(ERR_DROP, "GL3_BuildLightMap called for non-lit surface"); } - smax = (surf->extents[0] >> 4) + 1; - tmax = (surf->extents[1] >> 4) + 1; + smax = (surf->extents[0] >> surf->lmshift) + 1; + tmax = (surf->extents[1] >> surf->lmshift) + 1; size = smax * tmax; stride -= (smax << 2); @@ -333,8 +333,8 @@ GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride) for (i = 0; i < tmax; i++, dest += stride) { - memset(dest, c, 4*smax); - dest += 4*smax; + memset(dest, c, 4 * smax); + dest += 4 * smax; } } diff --git a/src/client/refresh/gl3/gl3_lightmap.c b/src/client/refresh/gl3/gl3_lightmap.c index 80d93b62..b508150a 100644 --- a/src/client/refresh/gl3/gl3_lightmap.c +++ b/src/client/refresh/gl3/gl3_lightmap.c @@ -182,15 +182,15 @@ GL3_LM_BuildPolygonFromSurface(gl3model_t *currentmodel, msurface_t *fa) /* lightmap texture coordinates */ s = DotProduct(vec, fa->texinfo->vecs[0]) + fa->texinfo->vecs[0][3]; s -= fa->texturemins[0]; - s += fa->light_s * 16; - s += 8; - s /= BLOCK_WIDTH * 16; /* fa->texinfo->texture->width; */ + s += fa->light_s * (1 << fa->lmshift); + s += (1 << fa->lmshift) * 0.5; + s /= BLOCK_WIDTH * (1 << fa->lmshift); t = DotProduct(vec, fa->texinfo->vecs[1]) + fa->texinfo->vecs[1][3]; t -= fa->texturemins[1]; - t += fa->light_t * 16; - t += 8; - t /= BLOCK_HEIGHT * 16; /* fa->texinfo->texture->height; */ + t += fa->light_t * (1 << fa->lmshift); + t += (1 << fa->lmshift) * 0.5; + t /= BLOCK_HEIGHT * (1 << fa->lmshift); vert->lmTexCoord[0] = s; vert->lmTexCoord[1] = t; @@ -210,8 +210,8 @@ GL3_LM_CreateSurfaceLightmap(msurface_t *surf) return; } - smax = (surf->extents[0] >> 4) + 1; - tmax = (surf->extents[1] >> 4) + 1; + smax = (surf->extents[0] >> surf->lmshift) + 1; + tmax = (surf->extents[1] >> surf->lmshift) + 1; if (!GL3_LM_AllocBlock(smax, tmax, &surf->light_s, &surf->light_t)) { diff --git a/src/client/refresh/gl3/gl3_model.c b/src/client/refresh/gl3/gl3_model.c index caaab74c..17683a85 100644 --- a/src/client/refresh/gl3/gl3_model.c +++ b/src/client/refresh/gl3/gl3_model.c @@ -373,6 +373,7 @@ Mod_LoadFaces(gl3model_t *loadmodel, byte *mod_base, lump_t *l) } out->texinfo = loadmodel->texinfo + ti; + out->lmshift = DEFAULT_LMSHIFT; Mod_CalcSurfaceExtents(loadmodel, out); diff --git a/src/client/refresh/gl3/header/model.h b/src/client/refresh/gl3/header/model.h index 738ff50a..81d8b297 100644 --- a/src/client/refresh/gl3/header/model.h +++ b/src/client/refresh/gl3/header/model.h @@ -67,6 +67,7 @@ typedef struct msurface_s short texturemins[2]; short extents[2]; + short lmshift; int light_s, light_t; /* gl lightmap coordinates */ int dlight_s, dlight_t; /* gl lightmap coordinates for dynamic lightmaps */ diff --git a/src/client/refresh/ref_shared.h b/src/client/refresh/ref_shared.h index b9aaa097..d1af9c3d 100644 --- a/src/client/refresh/ref_shared.h +++ b/src/client/refresh/ref_shared.h @@ -75,6 +75,8 @@ typedef enum #define MAX_LBM_HEIGHT 480 #define DEFAULT_NOLERP_LIST "pics/conchars.* pics/ch1.* pics/ch2. pics/ch3.*" +#define DEFAULT_LMSHIFT 4 + extern void R_Printf(int level, const char* msg, ...) PRINTF_ATTR(2, 3); /* Shared images load */ diff --git a/src/client/refresh/vk/header/model.h b/src/client/refresh/vk/header/model.h index b24d20bc..312af1ce 100644 --- a/src/client/refresh/vk/header/model.h +++ b/src/client/refresh/vk/header/model.h @@ -49,7 +49,6 @@ BRUSH MODELS // #define VERTEXSIZE 7 -#define DEFAULT_LMSHIFT 4 typedef struct vkpoly_s {