diff --git a/src/client/refresh/gl4/gl4_light.c b/src/client/refresh/gl4/gl4_light.c index f60ea058..cd47e43e 100644 --- a/src/client/refresh/gl4/gl4_light.c +++ b/src/client/refresh/gl4/gl4_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 @@ GL4_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride) ri.Sys_Error(ERR_DROP, "GL4_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); diff --git a/src/client/refresh/gl4/gl4_lightmap.c b/src/client/refresh/gl4/gl4_lightmap.c index 5509d15b..f0706442 100644 --- a/src/client/refresh/gl4/gl4_lightmap.c +++ b/src/client/refresh/gl4/gl4_lightmap.c @@ -182,15 +182,15 @@ GL4_LM_BuildPolygonFromSurface(gl4model_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 @@ GL4_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 (!GL4_LM_AllocBlock(smax, tmax, &surf->light_s, &surf->light_t)) { diff --git a/src/client/refresh/gl4/gl4_model.c b/src/client/refresh/gl4/gl4_model.c index 09b0f7fc..b2a36115 100644 --- a/src/client/refresh/gl4/gl4_model.c +++ b/src/client/refresh/gl4/gl4_model.c @@ -373,6 +373,7 @@ Mod_LoadFaces(gl4model_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/gl4/header/model.h b/src/client/refresh/gl4/header/model.h index 0fc8a304..2528de80 100644 --- a/src/client/refresh/gl4/header/model.h +++ b/src/client/refresh/gl4/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 */