Skip to content

Commit 21d22b8

Browse files
committed
[VRAD] small improvements
1 parent 7976a21 commit 21d22b8

File tree

4 files changed

+63
-1
lines changed

4 files changed

+63
-1
lines changed

sp/src/utils/vrad/leaf_ambient_lighting.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,11 @@ struct ambientsample_t
313313
// be discarded. This has the effect of converging on the best samples when enough are added.
314314
void AddSampleToList( CUtlVector<ambientsample_t> &list, const Vector &samplePosition, Vector *pCube )
315315
{
316+
#ifdef MAPBASE
317+
const int MAX_SAMPLES = g_iAmbientCubesPerLeaf;
318+
#else
316319
const int MAX_SAMPLES = 16;
320+
#endif // MAPBASE
317321

318322
int index = list.AddToTail();
319323
list[index].pos = samplePosition;
@@ -695,7 +699,7 @@ void ComputePerLeafAmbientLighting()
695699
{
696700
if ( !(dleafs[i].contents & CONTENTS_SOLID) )
697701
{
698-
Msg("Bad leaf ambient for leaf %d\n", i );
702+
Warning("\nBad leaf ambient for leaf %d\n", i );
699703
}
700704

701705
int refLeaf = NearestNeighborWithLight(i);

sp/src/utils/vrad/lightmap.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,8 +1666,10 @@ void ExportDirectLightsToWorldLights()
16661666

16671667
#define CONSTANT_DOT (.7/2)
16681668

1669+
#ifndef MAPBASE
16691670
#define NSAMPLES_SUN_AREA_LIGHT 30 // number of samples to take for an
16701671
// non-point sun light
1672+
#endif // MAPBASE
16711673

16721674
// Helper function - gathers light from sun (emit_skylight)
16731675
void GatherSampleSkyLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, int facenum,
@@ -1693,7 +1695,11 @@ void GatherSampleSkyLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, i
16931695
int nsamples = 1;
16941696
if ( g_SunAngularExtent > 0.0f )
16951697
{
1698+
#ifdef MAPBASE
1699+
nsamples = g_iSunSamplesAreaLight;
1700+
#else
16961701
nsamples = NSAMPLES_SUN_AREA_LIGHT;
1702+
#endif //MAPBASE
16971703
if ( do_fast || force_fast )
16981704
nsamples /= 4;
16991705
}

sp/src/utils/vrad/vrad.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ float coring = 1.0; // Light threshold to force to blackness(minimizes lightmap
107107
qboolean texscale = true;
108108
int dlight_map = 0; // Setting to 1 forces direct lighting into different lightmap than radiosity
109109

110+
#ifdef MAPBASE
111+
int g_iSunSamplesAreaLight = 512; // original 30, this was way to little samples
112+
int g_iAmbientCubesPerLeaf = 16;
113+
#endif // MAPBASE
114+
110115
float luxeldensity = 1.0;
111116
unsigned num_degenerate_faces;
112117

@@ -2662,7 +2667,45 @@ int ParseCommandLine( int argc, char **argv, bool *onlydetail )
26622667
return 1;
26632668
}
26642669
}
2670+
#ifdef MAPBASE
2671+
else if (!Q_stricmp(argv[i], "-SunSamplesAreaLight"))
2672+
{
2673+
if (++i < argc && *argv[i])
2674+
{
2675+
int iTemp = atoi(argv[i]);
2676+
if (iTemp < 0)
2677+
{
2678+
Warning("Error: expected non-negative value after '-SunSamplesAreaLight'\n");
2679+
return -1;
2680+
}
2681+
g_iSunSamplesAreaLight = iTemp;
2682+
}
2683+
else
2684+
{
2685+
Warning("Error: expected a value after '-SunSamplesAreaLight'\n");
2686+
return -1;
2687+
}
2688+
}
2689+
else if (!Q_stricmp(argv[i], "-AmbientCubesPerLeaf"))
2690+
{
2691+
if (++i < argc && *argv[i])
2692+
{
2693+
int iTemp = atof(argv[i]);
26652694

2695+
if (iTemp < 0)
2696+
{
2697+
Warning("Error: expected a positive number after '-AmbientCubesPerLeaf'\n");
2698+
return -1;
2699+
}
2700+
g_iAmbientCubesPerLeaf = iTemp;
2701+
}
2702+
else
2703+
{
2704+
Warning("Error: expected a number after '-AmbientCubesPerLeaf'\n");
2705+
return -1;
2706+
}
2707+
}
2708+
#endif // MAPBASE
26662709
#if ALLOWDEBUGOPTIONS
26672710
else if (!Q_stricmp(argv[i],"-scale"))
26682711
{
@@ -2820,6 +2863,10 @@ void PrintUsage( int argc, char **argv )
28202863
" -chop : Smallest number of luxel widths for a bounce patch, used on edges\n"
28212864
" -maxchop : Coarsest allowed number of luxel widths for a patch, used in face interiors\n"
28222865
"\n"
2866+
#ifdef MAPBASE
2867+
" -SunSamplesAreaLight # : Set max number of samples from the light_enviroment, (default: 512).\n"
2868+
" -AmbientCubesPerLeaf # : Lets you scale how many ambient cubes your leaf has, (default: 16).\n"
2869+
#endif // MAPBASE
28232870
" -LargeDispSampleRadius: This can be used if there are splotches of bounced light\n"
28242871
" on terrain. The compile will take longer, but it will gather\n"
28252872
" light across a wider area.\n"

sp/src/utils/vrad/vrad.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@
5555
extern float dispchop; // "-dispchop" tightest number of luxel widths for a patch, used on edges
5656
extern float g_MaxDispPatchRadius;
5757

58+
#ifdef MAPBASE
59+
extern int g_iSunSamplesAreaLight;
60+
extern int g_iAmbientCubesPerLeaf;
61+
#endif // MAPBASE
62+
5863
//-----------------------------------------------------------------------------
5964
// forward declarations
6065
//-----------------------------------------------------------------------------

0 commit comments

Comments
 (0)