mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
soft: LIGHTMAPS: Add support for LMSHIFT.
Could be extended to support the LMSHIFT BSPX blob. Currently mostly a cleanup to make DECOUPLEDLM changes more readable.
This commit is contained in:
parent
d3f0fde1ae
commit
bbf4a9f189
4 changed files with 17 additions and 16 deletions
|
@ -59,6 +59,7 @@ typedef struct msurface_s
|
||||||
|
|
||||||
short texturemins[2];
|
short texturemins[2];
|
||||||
short extents[2];
|
short extents[2];
|
||||||
|
short lmshift;
|
||||||
|
|
||||||
mtexinfo_t *texinfo;
|
mtexinfo_t *texinfo;
|
||||||
|
|
||||||
|
|
|
@ -141,13 +141,13 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end, vec3_t pointcolor)
|
||||||
if (!surf->samples)
|
if (!surf->samples)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
ds >>= 4;
|
ds >>= surf->lmshift;
|
||||||
dt >>= 4;
|
dt >>= surf->lmshift;
|
||||||
|
|
||||||
lightmap = surf->samples;
|
lightmap = surf->samples;
|
||||||
VectorCopy (vec3_origin, pointcolor);
|
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 < MAXLIGHTMAPS && surf->styles[maps] != 255 ;
|
for (maps = 0 ; maps < MAXLIGHTMAPS && surf->styles[maps] != 255 ;
|
||||||
maps++)
|
maps++)
|
||||||
|
@ -166,8 +166,8 @@ RecursiveLightPoint (mnode_t *node, vec3_t start, vec3_t end, vec3_t pointcolor)
|
||||||
pointcolor[j] += lightmap[j] * scale * (1.0 / 255);
|
pointcolor[j] += lightmap[j] * scale * (1.0 / 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
lightmap += 3 * ((surf->extents[0] >> 4) + 1) *
|
lightmap += 3 * ((surf->extents[0] >> surf->lmshift) + 1) *
|
||||||
((surf->extents[1] >> 4) + 1);
|
((surf->extents[1] >> surf->lmshift) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -252,8 +252,8 @@ R_AddDynamicLights (drawsurf_t* drawsurf)
|
||||||
mtexinfo_t *tex;
|
mtexinfo_t *tex;
|
||||||
|
|
||||||
surf = drawsurf->surf;
|
surf = drawsurf->surf;
|
||||||
smax = (surf->extents[0]>>4)+1;
|
smax = (surf->extents[0] >> surf->lmshift) + 1;
|
||||||
tmax = (surf->extents[1]>>4)+1;
|
tmax = (surf->extents[1] >> surf->lmshift) + 1;
|
||||||
tex = surf->texinfo;
|
tex = surf->texinfo;
|
||||||
|
|
||||||
if (blocklight_max <= blocklights + smax*tmax*3)
|
if (blocklight_max <= blocklights + smax*tmax*3)
|
||||||
|
@ -318,24 +318,23 @@ R_AddDynamicLights (drawsurf_t* drawsurf)
|
||||||
local[0] -= surf->texturemins[0];
|
local[0] -= surf->texturemins[0];
|
||||||
local[1] -= surf->texturemins[1];
|
local[1] -= surf->texturemins[1];
|
||||||
|
|
||||||
for (t = 0 ; t<tmax ; t++)
|
for (t = 0 ; t < tmax ; t++)
|
||||||
{
|
{
|
||||||
int s, td;
|
int s, td;
|
||||||
|
td = local[1] - t * (1 << surf->lmshift);
|
||||||
td = local[1] - t*16;
|
|
||||||
if (td < 0)
|
if (td < 0)
|
||||||
td = -td;
|
td = -td;
|
||||||
for (s=0 ; s<smax ; s++)
|
for (s=0 ; s<smax ; s++)
|
||||||
{
|
{
|
||||||
int sd;
|
int sd;
|
||||||
|
|
||||||
sd = local[0] - s*16;
|
sd = local[0] - s * (1 << surf->lmshift);
|
||||||
if (sd < 0)
|
if (sd < 0)
|
||||||
sd = -sd;
|
sd = -sd;
|
||||||
if (sd > td)
|
if (sd > td)
|
||||||
dist = sd + (td>>1);
|
dist = sd + (td >> 1);
|
||||||
else
|
else
|
||||||
dist = td + (sd>>1);
|
dist = td + (sd >> 1);
|
||||||
|
|
||||||
for (i=0; i<3; i++)
|
for (i=0; i<3; i++)
|
||||||
{
|
{
|
||||||
|
@ -378,8 +377,8 @@ R_BuildLightMap (drawsurf_t* drawsurf)
|
||||||
|
|
||||||
surf = drawsurf->surf;
|
surf = drawsurf->surf;
|
||||||
|
|
||||||
smax = (surf->extents[0]>>4)+1;
|
smax = (surf->extents[0] >> surf->lmshift) + 1;
|
||||||
tmax = (surf->extents[1]>>4)+1;
|
tmax = (surf->extents[1] >> surf->lmshift) + 1;
|
||||||
size = smax*tmax*3;
|
size = smax*tmax*3;
|
||||||
|
|
||||||
if (blocklight_max <= blocklights + size)
|
if (blocklight_max <= blocklights + size)
|
||||||
|
|
|
@ -447,6 +447,7 @@ Mod_LoadFaces (model_t *loadmodel, byte *mod_base, lump_t *l)
|
||||||
ri.Sys_Error(ERR_DROP, "%s: bad texinfo number", __func__);
|
ri.Sys_Error(ERR_DROP, "%s: bad texinfo number", __func__);
|
||||||
}
|
}
|
||||||
out->texinfo = loadmodel->texinfo + ti;
|
out->texinfo = loadmodel->texinfo + ti;
|
||||||
|
out->lmshift = DEFAULT_LMSHIFT;
|
||||||
|
|
||||||
CalcSurfaceExtents (loadmodel, out);
|
CalcSurfaceExtents (loadmodel, out);
|
||||||
|
|
||||||
|
|
|
@ -197,7 +197,7 @@ R_DrawSurface (drawsurf_t *drawsurf)
|
||||||
blocksize = 16 >> drawsurf->surfmip;
|
blocksize = 16 >> drawsurf->surfmip;
|
||||||
blockdivshift = NUM_MIPS - drawsurf->surfmip;
|
blockdivshift = NUM_MIPS - drawsurf->surfmip;
|
||||||
|
|
||||||
r_lightwidth = (drawsurf->surf->extents[0]>>4)+1;
|
r_lightwidth = (drawsurf->surf->extents[0] >> drawsurf->surf->lmshift) + 1;
|
||||||
|
|
||||||
r_numhblocks = drawsurf->surfwidth >> blockdivshift;
|
r_numhblocks = drawsurf->surfwidth >> blockdivshift;
|
||||||
r_numvblocks = drawsurf->surfheight >> blockdivshift;
|
r_numvblocks = drawsurf->surfheight >> blockdivshift;
|
||||||
|
|
Loading…
Reference in a new issue