mirror of
https://github.com/yquake2/yquake2remaster.git
synced 2025-02-22 03:41:19 +00:00
R_LightPoint: share between renders
This commit is contained in:
parent
262a1ee5ef
commit
f81e339efc
12 changed files with 57 additions and 298 deletions
|
@ -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
|
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,
|
R_RecursiveLightPoint(const msurface_t *surfaces, const mnode_t *node,
|
||||||
const lightstyle_t *lightstyles, const vec3_t start, const vec3_t end,
|
const lightstyle_t *lightstyles, const vec3_t start, const vec3_t end,
|
||||||
vec3_t pointcolor, vec3_t lightspot, float modulate)
|
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],
|
return R_RecursiveLightPoint(surfaces, node->children[!side],
|
||||||
lightstyles, mid, end, pointcolor, lightspot, modulate);
|
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);
|
||||||
|
}
|
||||||
|
|
|
@ -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
|
static void
|
||||||
R_AddDynamicLights(msurface_t *surf)
|
R_AddDynamicLights(msurface_t *surf)
|
||||||
{
|
{
|
||||||
|
|
|
@ -233,8 +233,6 @@ void R_Bind(int texnum);
|
||||||
|
|
||||||
void R_TexEnv(GLenum value);
|
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);
|
void R_PushDlights(void);
|
||||||
|
|
||||||
extern float *s_blocklights, *s_blocklights_max;
|
extern float *s_blocklights, *s_blocklights_max;
|
||||||
|
|
|
@ -105,59 +105,6 @@ GL3_PushDlights(void)
|
||||||
GL3_UpdateUBOLights();
|
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
|
* Combine and scale multiple lightmaps into the floating format in blocklights
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -459,8 +459,6 @@ extern int r_dlightframecount;
|
||||||
extern void GL3_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node,
|
extern void GL3_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node,
|
||||||
int r_dlightframecount);
|
int r_dlightframecount);
|
||||||
extern void GL3_PushDlights(void);
|
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);
|
extern void GL3_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride);
|
||||||
|
|
||||||
// gl3_lightmap.c
|
// gl3_lightmap.c
|
||||||
|
|
|
@ -105,59 +105,6 @@ GL4_PushDlights(void)
|
||||||
GL4_UpdateUBOLights();
|
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
|
* Combine and scale multiple lightmaps into the floating format in blocklights
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -459,8 +459,6 @@ extern int r_dlightframecount;
|
||||||
extern void GL4_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node,
|
extern void GL4_MarkSurfaceLights(dlight_t *light, int bit, mnode_t *node,
|
||||||
int r_dlightframecount);
|
int r_dlightframecount);
|
||||||
extern void GL4_PushDlights(void);
|
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);
|
extern void GL4_BuildLightMap(msurface_t *surf, int offsetInLMbuf, int stride);
|
||||||
|
|
||||||
// gl4_lightmap.c
|
// gl4_lightmap.c
|
||||||
|
|
|
@ -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 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,
|
extern void BSPX_LightGridValue(const bspxlightgrid_t *grid, const lightstyle_t *lightstyles,
|
||||||
const vec3_t point, vec3_t res_diffuse);
|
const vec3_t point, vec3_t res_diffuse);
|
||||||
extern int R_RecursiveLightPoint(const msurface_t *surfaces, const mnode_t *node,
|
extern void R_LightPoint(const entity_t *currententity, refdef_t *refdef, const msurface_t *surfaces,
|
||||||
const lightstyle_t *lightstyles, const vec3_t start, const vec3_t end,
|
const mnode_t *nodes, vec3_t p, vec3_t color, float modulate, vec3_t lightspot);
|
||||||
vec3_t pointcolor, vec3_t lightspot, float modulate);
|
|
||||||
|
|
||||||
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
#endif /* SRC_CLIENT_REFRESH_REF_SHARED_H_ */
|
||||||
|
|
|
@ -524,8 +524,6 @@ extern vec3_t lightspot;
|
||||||
void R_PrintAliasStats (void);
|
void R_PrintAliasStats (void);
|
||||||
void R_PrintTimes (void);
|
void R_PrintTimes (void);
|
||||||
void R_PrintDSpeeds (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);
|
void R_SetupFrame (void);
|
||||||
|
|
||||||
extern refdef_t r_newrefdef;
|
extern refdef_t r_newrefdef;
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "header/local.h"
|
#include "header/local.h"
|
||||||
|
|
||||||
vec3_t lightspot;
|
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
|
static void
|
||||||
R_AddDynamicLights (drawsurf_t* drawsurf)
|
R_AddDynamicLights(drawsurf_t* drawsurf)
|
||||||
{
|
{
|
||||||
msurface_t *surf;
|
msurface_t *surf;
|
||||||
int lnum;
|
int lnum;
|
||||||
|
|
|
@ -185,8 +185,6 @@ void Vk_ScreenShot_f (void);
|
||||||
void Vk_Strings_f(void);
|
void Vk_Strings_f(void);
|
||||||
void Vk_Mem_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_PushDlights(void);
|
||||||
|
|
||||||
void R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel);
|
void R_DrawAliasModel(entity_t *currententity, const model_t *currentmodel);
|
||||||
|
|
|
@ -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
|
static void
|
||||||
R_AddDynamicLights(msurface_t *surf)
|
R_AddDynamicLights(msurface_t *surf)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue