Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion sp/src/utils/vrad/leaf_ambient_lighting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,11 @@ struct ambientsample_t
// be discarded. This has the effect of converging on the best samples when enough are added.
void AddSampleToList( CUtlVector<ambientsample_t> &list, const Vector &samplePosition, Vector *pCube )
{
#ifdef MAPBASE
const int MAX_SAMPLES = g_iAmbientCubesPerLeaf;
#else
const int MAX_SAMPLES = 16;
#endif // MAPBASE

int index = list.AddToTail();
list[index].pos = samplePosition;
Expand Down Expand Up @@ -695,7 +699,7 @@ void ComputePerLeafAmbientLighting()
{
if ( !(dleafs[i].contents & CONTENTS_SOLID) )
{
Msg("Bad leaf ambient for leaf %d\n", i );
Warning("\nBad leaf ambient for leaf %d\n", i );
}

int refLeaf = NearestNeighborWithLight(i);
Expand Down
6 changes: 6 additions & 0 deletions sp/src/utils/vrad/lightmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1666,8 +1666,10 @@ void ExportDirectLightsToWorldLights()

#define CONSTANT_DOT (.7/2)

#ifndef MAPBASE
#define NSAMPLES_SUN_AREA_LIGHT 30 // number of samples to take for an
// non-point sun light
#endif // MAPBASE

// Helper function - gathers light from sun (emit_skylight)
void GatherSampleSkyLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, int facenum,
Expand All @@ -1693,7 +1695,11 @@ void GatherSampleSkyLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, i
int nsamples = 1;
if ( g_SunAngularExtent > 0.0f )
{
#ifdef MAPBASE
nsamples = g_iSunSamplesAreaLight;
#else
nsamples = NSAMPLES_SUN_AREA_LIGHT;
#endif //MAPBASE
if ( do_fast || force_fast )
nsamples /= 4;
}
Expand Down
47 changes: 47 additions & 0 deletions sp/src/utils/vrad/vrad.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ float coring = 1.0; // Light threshold to force to blackness(minimizes lightmap
qboolean texscale = true;
int dlight_map = 0; // Setting to 1 forces direct lighting into different lightmap than radiosity

#ifdef MAPBASE
int g_iSunSamplesAreaLight = 512; // original 30, this was way to little samples
int g_iAmbientCubesPerLeaf = 16;
#endif // MAPBASE

float luxeldensity = 1.0;
unsigned num_degenerate_faces;

Expand Down Expand Up @@ -2662,7 +2667,45 @@ int ParseCommandLine( int argc, char **argv, bool *onlydetail )
return 1;
}
}
#ifdef MAPBASE
else if (!Q_stricmp(argv[i], "-SunSamplesAreaLight"))
{
if (++i < argc && *argv[i])
{
int iTemp = atoi(argv[i]);
if (iTemp < 0)
{
Warning("Error: expected non-negative value after '-SunSamplesAreaLight'\n");
return -1;
}
g_iSunSamplesAreaLight = iTemp;
}
else
{
Warning("Error: expected a value after '-SunSamplesAreaLight'\n");
return -1;
}
}
else if (!Q_stricmp(argv[i], "-AmbientCubesPerLeaf"))
{
if (++i < argc && *argv[i])
{
int iTemp = atof(argv[i]);

if (iTemp < 0)
{
Warning("Error: expected a positive number after '-AmbientCubesPerLeaf'\n");
return -1;
}
g_iAmbientCubesPerLeaf = iTemp;
}
else
{
Warning("Error: expected a number after '-AmbientCubesPerLeaf'\n");
return -1;
}
}
#endif // MAPBASE
#if ALLOWDEBUGOPTIONS
else if (!Q_stricmp(argv[i],"-scale"))
{
Expand Down Expand Up @@ -2820,6 +2863,10 @@ void PrintUsage( int argc, char **argv )
" -chop : Smallest number of luxel widths for a bounce patch, used on edges\n"
" -maxchop : Coarsest allowed number of luxel widths for a patch, used in face interiors\n"
"\n"
#ifdef MAPBASE
" -SunSamplesAreaLight # : Set max number of samples from the light_enviroment, (default: 512).\n"
" -AmbientCubesPerLeaf # : Lets you scale how many ambient cubes your leaf has, (default: 16).\n"
#endif // MAPBASE
" -LargeDispSampleRadius: This can be used if there are splotches of bounced light\n"
" on terrain. The compile will take longer, but it will gather\n"
" light across a wider area.\n"
Expand Down
5 changes: 5 additions & 0 deletions sp/src/utils/vrad/vrad.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
extern float dispchop; // "-dispchop" tightest number of luxel widths for a patch, used on edges
extern float g_MaxDispPatchRadius;

#ifdef MAPBASE
extern int g_iSunSamplesAreaLight;
extern int g_iAmbientCubesPerLeaf;
#endif // MAPBASE

//-----------------------------------------------------------------------------
// forward declarations
//-----------------------------------------------------------------------------
Expand Down
Loading