mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2024-11-10 07:12:07 +00:00
files/light: rework R_BuildLightMap code
This commit is contained in:
parent
eb3ea06fc9
commit
8d8034f244
1 changed files with 57 additions and 30 deletions
|
@ -67,11 +67,17 @@ BSPX_LightGridSingleValue(const bspxlightgrid_t *grid, const lightstyle_t *light
|
||||||
//no hdr support
|
//no hdr support
|
||||||
for (i = 0; i < 4; i++)
|
for (i = 0; i < 4; i++)
|
||||||
{
|
{
|
||||||
|
int j;
|
||||||
|
|
||||||
if (samp->map[i].style == ((byte)(~0u)))
|
if (samp->map[i].style == ((byte)(~0u)))
|
||||||
|
{
|
||||||
break; //no more
|
break; //no more
|
||||||
res_diffuse[0] += samp->map[i].rgb[0] * lightstyles[samp->map[i].style].rgb[0] / 255.0;
|
}
|
||||||
res_diffuse[1] += samp->map[i].rgb[1] * lightstyles[samp->map[i].style].rgb[1] / 255.0;
|
|
||||||
res_diffuse[2] += samp->map[i].rgb[2] * lightstyles[samp->map[i].style].rgb[2] / 255.0;
|
for (j = 0; j < 3; j++)
|
||||||
|
{
|
||||||
|
res_diffuse[j] += samp->map[i].rgb[j] * lightstyles[samp->map[i].style].rgb[j] / 255.0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -581,10 +587,9 @@ R_BuildLightMap(const msurface_t *surf, byte *dest, int stride, const refdef_t *
|
||||||
float modulate, int r_framecount)
|
float modulate, int r_framecount)
|
||||||
{
|
{
|
||||||
int smax, tmax;
|
int smax, tmax;
|
||||||
int i, size, numlightmaps;
|
int size, numlightmaps;
|
||||||
byte *lightmap;
|
byte *lightmap;
|
||||||
float scale[4];
|
const float *max_light;
|
||||||
float *bl;
|
|
||||||
|
|
||||||
if (surf->texinfo->flags &
|
if (surf->texinfo->flags &
|
||||||
(SURF_SKY | SURF_TRANSPARENT | SURF_WARP))
|
(SURF_SKY | SURF_TRANSPARENT | SURF_WARP))
|
||||||
|
@ -598,13 +603,21 @@ R_BuildLightMap(const msurface_t *surf, byte *dest, int stride, const refdef_t *
|
||||||
|
|
||||||
R_ResizeTemporaryLMBuffer(size * 3);
|
R_ResizeTemporaryLMBuffer(size * 3);
|
||||||
|
|
||||||
|
max_light = s_blocklights + size * 3;
|
||||||
|
|
||||||
/* set to full bright if no light data */
|
/* set to full bright if no light data */
|
||||||
if (!surf->samples)
|
if (!surf->samples)
|
||||||
{
|
{
|
||||||
for (i = 0; i < size * 3; i++)
|
float *curr_light;
|
||||||
|
|
||||||
|
curr_light = s_blocklights;
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
s_blocklights[i] = 255;
|
*curr_light = 255;
|
||||||
|
curr_light++;
|
||||||
}
|
}
|
||||||
|
while(curr_light < max_light);
|
||||||
|
|
||||||
R_StoreLightMap(dest, stride, smax, tmax);
|
R_StoreLightMap(dest, stride, smax, tmax);
|
||||||
return;
|
return;
|
||||||
|
@ -625,7 +638,11 @@ R_BuildLightMap(const msurface_t *surf, byte *dest, int stride, const refdef_t *
|
||||||
|
|
||||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++)
|
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++)
|
||||||
{
|
{
|
||||||
bl = s_blocklights;
|
float *curr_light;
|
||||||
|
vec3_t scale;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
curr_light = s_blocklights;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
@ -637,24 +654,27 @@ R_BuildLightMap(const msurface_t *surf, byte *dest, int stride, const refdef_t *
|
||||||
(scale[1] == 1.0F) &&
|
(scale[1] == 1.0F) &&
|
||||||
(scale[2] == 1.0F))
|
(scale[2] == 1.0F))
|
||||||
{
|
{
|
||||||
for (i = 0; i < size; i++, bl += 3)
|
do
|
||||||
{
|
{
|
||||||
bl[0] = lightmap[i * 3 + 0];
|
*curr_light = *lightmap;
|
||||||
bl[1] = lightmap[i * 3 + 1];
|
curr_light++;
|
||||||
bl[2] = lightmap[i * 3 + 2];
|
lightmap++;
|
||||||
}
|
}
|
||||||
|
while(curr_light < max_light);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < size; i++, bl += 3)
|
do
|
||||||
{
|
{
|
||||||
bl[0] = lightmap[i * 3 + 0] * scale[0];
|
for (i = 0; i < 3; i++)
|
||||||
bl[1] = lightmap[i * 3 + 1] * scale[1];
|
{
|
||||||
bl[2] = lightmap[i * 3 + 2] * scale[2];
|
*curr_light = *lightmap * scale[i];
|
||||||
|
curr_light++;
|
||||||
|
lightmap++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
while(curr_light < max_light);
|
||||||
}
|
}
|
||||||
|
|
||||||
lightmap += size * 3; /* skip to next lightmap */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -665,7 +685,11 @@ R_BuildLightMap(const msurface_t *surf, byte *dest, int stride, const refdef_t *
|
||||||
|
|
||||||
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++)
|
for (maps = 0; maps < MAXLIGHTMAPS && surf->styles[maps] != 255; maps++)
|
||||||
{
|
{
|
||||||
bl = s_blocklights;
|
float *curr_light;
|
||||||
|
vec3_t scale;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
curr_light = s_blocklights;
|
||||||
|
|
||||||
for (i = 0; i < 3; i++)
|
for (i = 0; i < 3; i++)
|
||||||
{
|
{
|
||||||
|
@ -677,24 +701,27 @@ R_BuildLightMap(const msurface_t *surf, byte *dest, int stride, const refdef_t *
|
||||||
(scale[1] == 1.0F) &&
|
(scale[1] == 1.0F) &&
|
||||||
(scale[2] == 1.0F))
|
(scale[2] == 1.0F))
|
||||||
{
|
{
|
||||||
for (i = 0; i < size; i++, bl += 3)
|
do
|
||||||
{
|
{
|
||||||
bl[0] += lightmap[i * 3 + 0];
|
*curr_light += *lightmap;
|
||||||
bl[1] += lightmap[i * 3 + 1];
|
curr_light++;
|
||||||
bl[2] += lightmap[i * 3 + 2];
|
lightmap++;
|
||||||
}
|
}
|
||||||
|
while(curr_light < max_light);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; i < size; i++, bl += 3)
|
do
|
||||||
{
|
{
|
||||||
bl[0] += lightmap[i * 3 + 0] * scale[0];
|
for (i = 0; i < 3; i++)
|
||||||
bl[1] += lightmap[i * 3 + 1] * scale[1];
|
{
|
||||||
bl[2] += lightmap[i * 3 + 2] * scale[2];
|
*curr_light += *lightmap * scale[i];
|
||||||
|
curr_light++;
|
||||||
|
lightmap++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
while(curr_light < max_light);
|
||||||
}
|
}
|
||||||
|
|
||||||
lightmap += size * 3; /* skip to next lightmap */
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue