integrate final gather with -bounce -bouncedebug switches
This commit is contained in:
parent
23ab0a8ef1
commit
9faae0ec97
|
|
@ -165,7 +165,7 @@ struct ltface_ctx
|
||||||
extern struct ltface_ctx *ltface_ctxs;
|
extern struct ltface_ctx *ltface_ctxs;
|
||||||
|
|
||||||
/* bounce lights */
|
/* bounce lights */
|
||||||
|
#if 0
|
||||||
typedef struct {
|
typedef struct {
|
||||||
vec3_t pos;
|
vec3_t pos;
|
||||||
vec3_t color;
|
vec3_t color;
|
||||||
|
|
@ -176,6 +176,7 @@ typedef struct {
|
||||||
|
|
||||||
extern const bouncelight_t *bouncelights;
|
extern const bouncelight_t *bouncelights;
|
||||||
extern int numbouncelights;
|
extern int numbouncelights;
|
||||||
|
#endif
|
||||||
extern byte thepalette[768];
|
extern byte thepalette[768];
|
||||||
|
|
||||||
/* tracelist is a null terminated array of BSP models to use for LOS tests */
|
/* tracelist is a null terminated array of BSP models to use for LOS tests */
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,10 @@ LightThread(void *arg)
|
||||||
LightFace(bsp->dfaces + facenum, NULL, face_modelinfo, ctx);
|
LightFace(bsp->dfaces + facenum, NULL, face_modelinfo, ctx);
|
||||||
LightFace(bsp->dfaces + facenum, faces_sup + facenum, face_modelinfo, ctx);
|
LightFace(bsp->dfaces + facenum, faces_sup + facenum, face_modelinfo, ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!bounce) {
|
||||||
|
LightFaceShutdown(ctx);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
@ -753,11 +757,13 @@ LightWorld(bspdata_t *bspdata, qboolean forcedscale)
|
||||||
logprint("==LightThread==\n");
|
logprint("==LightThread==\n");
|
||||||
RunThreadsOn(0, bsp->numfaces, LightThread, bsp);
|
RunThreadsOn(0, bsp->numfaces, LightThread, bsp);
|
||||||
|
|
||||||
logprint("==LightThreadIndirect==\n");
|
if (bounce) {
|
||||||
RunThreadsOn(0, bsp->numfaces, LightThreadIndirect, bsp);
|
logprint("==LightThreadIndirect==\n");
|
||||||
|
RunThreadsOn(0, bsp->numfaces, LightThreadIndirect, bsp);
|
||||||
logprint("==LightThreadSaveAndFree==\n");
|
|
||||||
RunThreadsOn(0, bsp->numfaces, LightThreadSaveAndFree, bsp);
|
logprint("==LightThreadSaveAndFree==\n");
|
||||||
|
RunThreadsOn(0, bsp->numfaces, LightThreadSaveAndFree, bsp);
|
||||||
|
}
|
||||||
|
|
||||||
logprint("Lighting Completed.\n\n");
|
logprint("Lighting Completed.\n\n");
|
||||||
bsp->lightdatasize = file_p - filebase;
|
bsp->lightdatasize = file_p - filebase;
|
||||||
|
|
@ -825,6 +831,7 @@ LoadExtendedTexinfoFlags(const char *sourcefilename, const bsp2_t *bsp)
|
||||||
|
|
||||||
// radiosity
|
// radiosity
|
||||||
|
|
||||||
|
#if 0
|
||||||
map<string, vec3_struct_t> texturecolors;
|
map<string, vec3_struct_t> texturecolors;
|
||||||
std::vector<bouncelight_t> radlights;
|
std::vector<bouncelight_t> radlights;
|
||||||
|
|
||||||
|
|
@ -1141,6 +1148,7 @@ void MakeBounceLights (const bsp2_t *bsp)
|
||||||
numbouncelights = radlights.size();
|
numbouncelights = radlights.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
// end radiosity
|
// end radiosity
|
||||||
|
|
||||||
//obj
|
//obj
|
||||||
|
|
@ -1496,12 +1504,7 @@ main(int argc, const char **argv)
|
||||||
SetupDirt();
|
SetupDirt();
|
||||||
|
|
||||||
MakeTnodes(bsp);
|
MakeTnodes(bsp);
|
||||||
|
|
||||||
if (bounce) {
|
|
||||||
MakeTextureColors(bsp);
|
|
||||||
MakeBounceLights(bsp);
|
|
||||||
}
|
|
||||||
|
|
||||||
LightWorld(&bspdata, !!lmscaleoverride);
|
LightWorld(&bspdata, !!lmscaleoverride);
|
||||||
|
|
||||||
/*invalidate any bspx lighting info early*/
|
/*invalidate any bspx lighting info early*/
|
||||||
|
|
|
||||||
|
|
@ -1543,6 +1543,7 @@ LightFace_PhongDebug(const lightsurf_t *lightsurf, lightmap_t *lightmaps)
|
||||||
Lightmap_Save(lightmaps, lightsurf, lightmap, 0);
|
Lightmap_Save(lightmaps, lightsurf, lightmap, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
// returns color in [0,255]
|
// returns color in [0,255]
|
||||||
static inline void
|
static inline void
|
||||||
BounceLight_ColorAtDist(const bouncelight_t *vpl, vec_t dist, vec3_t color)
|
BounceLight_ColorAtDist(const bouncelight_t *vpl, vec_t dist, vec3_t color)
|
||||||
|
|
@ -1650,7 +1651,7 @@ LightFace_Bounce(const bsp2_t *bsp, const bsp2_dface_t *face, const lightsurf_t
|
||||||
|
|
||||||
Lightmap_Save(lightmaps, lightsurf, lightmap, 0);
|
Lightmap_Save(lightmaps, lightsurf, lightmap, 0);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Dirtmapping borrowed from q3map2, originally by RaP7oR */
|
/* Dirtmapping borrowed from q3map2, originally by RaP7oR */
|
||||||
|
|
||||||
|
|
@ -1704,9 +1705,9 @@ void SetupDirt( void ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static const lightmap_t *
|
static const lightmap_t *
|
||||||
Lightmap_ForStyle_ReadOnly(const struct ltface_ctx *ctx, const int style)
|
Lightmap_ForStyle_ReadOnly(const struct ltface_ctx *ctx, const int style, bool sampledirect)
|
||||||
{
|
{
|
||||||
const lightmap_t *lightmap = ctx->lightmaps;
|
const lightmap_t *lightmap = sampledirect ? ctx->lightmaps : ctx->lightmaps_bounce1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAXLIGHTMAPS; i++, lightmap++) {
|
for (i = 0; i < MAXLIGHTMAPS; i++, lightmap++) {
|
||||||
|
|
@ -2061,8 +2062,7 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
|
||||||
* minlight levels, then cast all negative lights. Finally, we
|
* minlight levels, then cast all negative lights. Finally, we
|
||||||
* clamp any values that may have gone negative.
|
* clamp any values that may have gone negative.
|
||||||
*/
|
*/
|
||||||
#if 1
|
if (!dirtDebug && !phongDebug) {
|
||||||
if (!dirtDebug && !phongDebug && !bouncedebug) {
|
|
||||||
/* positive lights */
|
/* positive lights */
|
||||||
for (lighte = lights; (entity = *lighte); lighte++)
|
for (lighte = lights; (entity = *lighte); lighte++)
|
||||||
{
|
{
|
||||||
|
|
@ -2093,12 +2093,7 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
|
||||||
if (sun->sunlight.light < 0)
|
if (sun->sunlight.light < 0)
|
||||||
LightFace_Sky (sun, lightsurf, lightmaps);
|
LightFace_Sky (sun, lightsurf, lightmaps);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dirtDebug && !phongDebug) {
|
|
||||||
/* add indirect lighting */
|
|
||||||
LightFace_Bounce(bsp, face, lightsurf, lightmaps);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* replace lightmaps with AO for debugging */
|
/* replace lightmaps with AO for debugging */
|
||||||
if (dirtDebug)
|
if (dirtDebug)
|
||||||
LightFace_DirtDebug(lightsurf, lightmaps);
|
LightFace_DirtDebug(lightsurf, lightmaps);
|
||||||
|
|
@ -2155,7 +2150,10 @@ LightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo,
|
||||||
VectorAdd(lightsurf->texturecolor, texcolor, lightsurf->texturecolor);
|
VectorAdd(lightsurf->texturecolor, texcolor, lightsurf->texturecolor);
|
||||||
}
|
}
|
||||||
VectorScale(lightsurf->texturecolor, 1.0f/lightsurf->numpoints, lightsurf->texturecolor);
|
VectorScale(lightsurf->texturecolor, 1.0f/lightsurf->numpoints, lightsurf->texturecolor);
|
||||||
#endif
|
|
||||||
|
if (!bounce) {
|
||||||
|
WriteLightmaps(face, facesup, lightsurf, lightmaps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -2230,7 +2228,7 @@ LightAtPoint(const bsp2_t *bsp, const vec3_t point, const bsp2_dface_t *face, ve
|
||||||
|
|
||||||
//printf("sample point is %f from impatc point. \n", dist);
|
//printf("sample point is %f from impatc point. \n", dist);
|
||||||
|
|
||||||
const lightmap_t *lm = Lightmap_ForStyle_ReadOnly(ctx, 0);
|
const lightmap_t *lm = Lightmap_ForStyle_ReadOnly(ctx, 0, true);
|
||||||
if (lm == NULL) {
|
if (lm == NULL) {
|
||||||
//printf("LightAtPoint: style 0 not filled\n");
|
//printf("LightAtPoint: style 0 not filled\n");
|
||||||
VectorCopy(vec3_origin, light);
|
VectorCopy(vec3_origin, light);
|
||||||
|
|
@ -2435,6 +2433,7 @@ LightFaceIndirect(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *mod
|
||||||
|
|
||||||
VectorSet(lightsurf->indirectlight, 512, 512, 512);
|
VectorSet(lightsurf->indirectlight, 512, 512, 512);
|
||||||
|
|
||||||
|
// write indirect lighting into lightmaps_bounce1 style 0
|
||||||
#if 1
|
#if 1
|
||||||
lightmap_t *lightmaps = ctx->lightmaps_bounce1;
|
lightmap_t *lightmaps = ctx->lightmaps_bounce1;
|
||||||
lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, 0, lightsurf);
|
lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, 0, lightsurf);
|
||||||
|
|
@ -2457,29 +2456,36 @@ LightFaceIndirect(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *mod
|
||||||
void
|
void
|
||||||
FinishLightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, struct ltface_ctx *ctx)
|
FinishLightFace(bsp2_dface_t *face, facesup_t *facesup, const modelinfo_t *modelinfo, struct ltface_ctx *ctx)
|
||||||
{
|
{
|
||||||
lightmap_t *lightmaps = ctx->lightmaps_bounce1;
|
lightmap_t *lightmaps = ctx->lightmaps;
|
||||||
lightsurf_t *lightsurf = &ctx->lightsurf;
|
lightsurf_t *lightsurf = &ctx->lightsurf;
|
||||||
|
|
||||||
/* use a style 0 light map */
|
// add the indirect lighting style 0 to the main lightmap style 0
|
||||||
lightmap_t *lightmap = Lightmap_ForStyle(lightmaps, 0, lightsurf);
|
{
|
||||||
|
lightmap_t *main_lightmap = Lightmap_ForStyle(lightmaps, 0, lightsurf);
|
||||||
// add direct light for style 0
|
const lightmap_t *lightmap_indirect = Lightmap_ForStyle_ReadOnly(ctx, 0, false);
|
||||||
#if 0
|
|
||||||
const lightmap_t *lightmap_direct = Lightmap_ForStyle_ReadOnly(ctx, 0);
|
|
||||||
if (lightmap_direct && lightmap_direct->samples) {
|
|
||||||
for (int x = 0; x < lightsurf->width; x++) {
|
for (int x = 0; x < lightsurf->width; x++) {
|
||||||
for (int y = 0; y < lightsurf->height; y++) {
|
for (int y = 0; y < lightsurf->height; y++) {
|
||||||
const int i = SampIdx(lightsurf, x, y);
|
const int i = SampIdx(lightsurf, x, y);
|
||||||
const lightsample_t *sample_direct = &lightmap_direct->samples[i];
|
|
||||||
lightsample_t *sample = &lightmap->samples[i];
|
|
||||||
|
|
||||||
VectorAdd(sample_direct->color, sample->color, sample->color);
|
lightsample_t *sample_main = &main_lightmap->samples[i];
|
||||||
|
|
||||||
|
if (lightmap_indirect && lightmap_indirect->samples) {
|
||||||
|
const lightsample_t *sample_indirect = &lightmap_indirect->samples[i];
|
||||||
|
if (bouncedebug) {
|
||||||
|
VectorCopy(sample_indirect->color, sample_main->color);
|
||||||
|
} else {
|
||||||
|
VectorAdd(sample_indirect->color, sample_main->color, sample_main->color);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (bouncedebug) {
|
||||||
|
VectorSet(sample_main->color, 0, 0, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Lightmap_Save(lightmaps, lightsurf, main_lightmap, 0);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
Lightmap_Save(lightmaps, lightsurf, lightmap, 0);
|
|
||||||
|
|
||||||
/* Perform post-processing if requested */
|
/* Perform post-processing if requested */
|
||||||
if (softsamples > 0) {
|
if (softsamples > 0) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue