R_LightPoint: share between renders

This commit is contained in:
Denis Pauk 2023-10-07 01:41:18 +03:00
parent 262a1ee5ef
commit f81e339efc
12 changed files with 57 additions and 298 deletions

View File

@ -93,7 +93,7 @@ BSPX_LightGridValue(const bspxlightgrid_t *grid, const lightstyle_t *lightstyles
VectorScale(res_diffuse, 1.0/s, res_diffuse); //average the successful ones
}
int
static int
R_RecursiveLightPoint(const msurface_t *surfaces, const mnode_t *node,
const lightstyle_t *lightstyles, const vec3_t start, const vec3_t end,
vec3_t pointcolor, vec3_t lightspot, float modulate)
@ -215,3 +215,55 @@ R_RecursiveLightPoint(const msurface_t *surfaces, const mnode_t *node,
return R_RecursiveLightPoint(surfaces, node->children[!side],
lightstyles, mid, end, pointcolor, lightspot, modulate);
}
void
R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot)
{
vec3_t end, dist, pointcolor = {0, 0, 0};
float r;
int lnum;
dlight_t *dl;
if (!currententity)
{
color[0] = color[1] = color[2] = 1.0;
return;
}
end[0] = p[0];
end[1] = p[1];
end[2] = p[2] - 2048;
r = R_RecursiveLightPoint(surfaces, nodes, refdef->lightstyles,
p, end, pointcolor, lightspot, modulate);
if (r == -1)
{
VectorCopy(vec3_origin, color);
}
else
{
VectorCopy(pointcolor, color);
}
/* add dynamic lights */
dl = refdef->dlights;
for (lnum = 0; lnum < refdef->num_dlights; lnum++, dl++)
{
float add;
VectorSubtract(currententity->origin,
dl->origin, dist);
add = dl->intensity - VectorLength(dist);
add *= (1.0f / 256.0f);
if (add > 0)
{
VectorMA(color, add, dl->color, color);
}
}
VectorScale(color, modulate, color);
}

View File

@ -178,58 +178,6 @@ R_PushDlights(void)
}
}
void
R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot)
{
vec3_t end, dist, pointcolor = {0, 0, 0};
float r;
int lnum;
dlight_t *dl;
if (!currententity)
{
color[0] = color[1] = color[2] = 1.0;
return;
}
end[0] = p[0];
end[1] = p[1];
end[2] = p[2] - 2048;
r = R_RecursiveLightPoint(surfaces, nodes, refdef->lightstyles,
p, end, pointcolor, lightspot, modulate);
if (r == -1)
{
VectorCopy(vec3_origin, color);
}
else
{
VectorCopy(pointcolor, color);
}
/* add dynamic lights */
dl = refdef->dlights;
for (lnum = 0; lnum < refdef->num_dlights; lnum++, dl++)
{
float add;
VectorSubtract(currententity->origin,
dl->origin, dist);
add = dl->intensity - VectorLength(dist);
add *= (1.0f / 256.0f);
if (add > 0)
{
VectorMA(color, add, dl->color, color);
}
}
VectorScale(color, modulate, color);
}
static void
R_AddDynamicLights(msurface_t *surf)
{

View File

@ -233,8 +233,6 @@ void R_Bind(int texnum);
void R_TexEnv(GLenum value);
void R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);
void R_PushDlights(void);
extern float *s_blocklights, *s_blocklights_max;

View File

@ -105,59 +105,6 @@ GL3_PushDlights(void)
GL3_UpdateUBOLights();
}
void
R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot)
{
vec3_t end, dist, pointcolor = {0, 0, 0};
float r;
int lnum;
dlight_t *dl;
if (!currententity)
{
color[0] = color[1] = color[2] = 1.0;
return;
}
end[0] = p[0];
end[1] = p[1];
end[2] = p[2] - 2048;
r = R_RecursiveLightPoint(surfaces, nodes, refdef->lightstyles,
p, end, pointcolor, lightspot, modulate);
if (r == -1)
{
VectorCopy(vec3_origin, color);
}
else
{
VectorCopy(pointcolor, color);
}
/* add dynamic lights */
dl = refdef->dlights;
for (lnum = 0; lnum < refdef->num_dlights; lnum++, dl++)
{
float add;
VectorSubtract(currententity->origin,
dl->origin, dist);
add = dl->intensity - VectorLength(dist);
add *= (1.0f / 256.0f);
if (add > 0)
{
VectorMA(color, add, dl->color, color);
}
}
VectorScale(color, modulate, color);
}
/*
* Combine and scale multiple lightmaps into the floating format in blocklights
*/

View File

@ -459,8 +459,6 @@ extern int r_dlightframecount;
extern void GL3_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node,
int r_dlightframecount);
extern void GL3_PushDlights(void);
extern void R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);
extern void GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride);
// gl3_lightmap.c

View File

@ -105,59 +105,6 @@ GL4_PushDlights(void)
GL4_UpdateUBOLights();
}
void
R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot)
{
vec3_t end, dist, pointcolor = {0, 0, 0};
float r;
int lnum;
dlight_t *dl;
if (!currententity)
{
color[0] = color[1] = color[2] = 1.0;
return;
}
end[0] = p[0];
end[1] = p[1];
end[2] = p[2] - 2048;
r = R_RecursiveLightPoint(surfaces, nodes, refdef->lightstyles,
p, end, pointcolor, lightspot, modulate);
if (r == -1)
{
VectorCopy(vec3_origin, color);
}
else
{
VectorCopy(pointcolor, color);
}
/* add dynamic lights */
dl = refdef->dlights;
for (lnum = 0; lnum < refdef->num_dlights; lnum++, dl++)
{
float add;
VectorSubtract(currententity->origin,
dl->origin, dist);
add = dl->intensity - VectorLength(dist);
add *= (1.0f / 256.0f);
if (add > 0)
{
VectorMA(color, add, dl->color, color);
}
}
VectorScale(color, modulate, color);
}
/*
* Combine and scale multiple lightmaps into the floating format in blocklights
*/

View File

@ -459,8 +459,6 @@ extern int r_dlightframecount;
extern void GL4_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node,
int r_dlightframecount);
extern void GL4_PushDlights(void);
extern void R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);
extern void GL4_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride);
// gl4_lightmap.c

View File

@ -375,8 +375,7 @@ extern void R_BoundPoly(int numverts, float *verts, vec3_t mins, vec3_t maxs);
extern bspxlightgrid_t *BSPX_LightGridLoad(const bspx_header_t *bspx_header, const byte *mod_base);
extern void BSPX_LightGridValue(const bspxlightgrid_t *grid, const lightstyle_t *lightstyles,
const vec3_t point, vec3_t res_diffuse);
extern int R_RecursiveLightPoint(const msurface_t *surfaces, const mnode_t *node,
const lightstyle_t *lightstyles, const vec3_t start, const vec3_t end,
vec3_t pointcolor, vec3_t lightspot, float modulate);
extern void R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */

View File

@ -524,8 +524,6 @@ extern vec3_t lightspot;
void R_PrintAliasStats (void);
void R_PrintTimes (void);
void R_PrintDSpeeds (void);
void R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);
void R_SetupFrame (void);
extern refdef_t r_newrefdef;

View File

@ -22,6 +22,7 @@
#include "header/local.h"
vec3_t lightspot;
light_t *blocklights = NULL, *blocklight_max = NULL;
/*
=============================================================================
@ -69,81 +70,8 @@ R_PushDlights (const model_t *model)
}
}
/*
=============================================================================
LIGHT SAMPLING
=============================================================================
*/
vec3_t lightspot;
void
R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot)
{
vec3_t end, dist, pointcolor = {0, 0, 0};
float r;
int lnum;
dlight_t *dl;
if (!currententity)
{
color[0] = color[1] = color[2] = 1.0;
return;
}
end[0] = p[0];
end[1] = p[1];
end[2] = p[2] - 2048;
r = R_RecursiveLightPoint(surfaces, nodes, refdef->lightstyles,
p, end, pointcolor, lightspot, modulate);
if (r == -1)
{
VectorCopy(vec3_origin, color);
}
else
{
VectorCopy(pointcolor, color);
}
/* add dynamic lights */
dl = refdef->dlights;
for (lnum = 0; lnum < refdef->num_dlights; lnum++, dl++)
{
float add;
VectorSubtract(currententity->origin,
dl->origin, dist);
add = dl->intensity - VectorLength(dist);
add *= (1.0f / 256.0f);
if (add > 0)
{
VectorMA(color, add, dl->color, color);
}
}
VectorScale(color, modulate, color);
}
//===================================================================
light_t *blocklights = NULL, *blocklight_max = NULL;
/*
===============
R_AddDynamicLights
===============
*/
static void
R_AddDynamicLights (drawsurf_t* drawsurf)
R_AddDynamicLights(drawsurf_t* drawsurf)
{
msurface_t *surf;
int lnum;

View File

@ -185,8 +185,6 @@ void Vk_ScreenShot_f (void);
void Vk_Strings_f(void);
void Vk_Mem_f(void);
void R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);
void R_PushDlights(void);
void R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel);

View File

@ -168,58 +168,6 @@ R_PushDlights(void)
}
}
void
R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot)
{
vec3_t end, dist, pointcolor = {0, 0, 0};
float r;
int lnum;
dlight_t *dl;
if (!currententity)
{
color[0] = color[1] = color[2] = 1.0;
return;
}
end[0] = p[0];
end[1] = p[1];
end[2] = p[2] - 2048;
r = R_RecursiveLightPoint(surfaces, nodes, refdef->lightstyles,
p, end, pointcolor, lightspot, modulate);
if (r == -1)
{
VectorCopy(vec3_origin, color);
}
else
{
VectorCopy(pointcolor, color);
}
/* add dynamic lights */
dl = refdef->dlights;
for (lnum = 0; lnum < refdef->num_dlights; lnum++, dl++)
{
float add;
VectorSubtract(currententity->origin,
dl->origin, dist);
add = dl->intensity - VectorLength(dist);
add *= (1.0f / 256.0f);
if (add > 0)
{
VectorMA(color, add, dl->color, color);
}
}
VectorScale(color, modulate, color);
}
static void
R_AddDynamicLights(msurface_t *surf)
{