From 21d22b8411c63d2cacc7c6b08b745f8bb57eade1 Mon Sep 17 00:00:00 2001 From: Carlos suarez <110506367+Unusuario2@users.noreply.github.com> Date: Mon, 9 Jun 2025 00:49:41 +0200 Subject: [PATCH] [VRAD] small improvements --- sp/src/utils/vrad/leaf_ambient_lighting.cpp | 6 ++- sp/src/utils/vrad/lightmap.cpp | 6 +++ sp/src/utils/vrad/vrad.cpp | 47 +++++++++++++++++++++ sp/src/utils/vrad/vrad.h | 5 +++ 4 files changed, 63 insertions(+), 1 deletion(-) diff --git a/sp/src/utils/vrad/leaf_ambient_lighting.cpp b/sp/src/utils/vrad/leaf_ambient_lighting.cpp index 3836592e08d..b30bd06f8a3 100644 --- a/sp/src/utils/vrad/leaf_ambient_lighting.cpp +++ b/sp/src/utils/vrad/leaf_ambient_lighting.cpp @@ -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 &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; @@ -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); diff --git a/sp/src/utils/vrad/lightmap.cpp b/sp/src/utils/vrad/lightmap.cpp index bfa4bd03bc4..f9ef1062e20 100644 --- a/sp/src/utils/vrad/lightmap.cpp +++ b/sp/src/utils/vrad/lightmap.cpp @@ -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, @@ -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; } diff --git a/sp/src/utils/vrad/vrad.cpp b/sp/src/utils/vrad/vrad.cpp index a7cba1c07ea..ad7be4678af 100644 --- a/sp/src/utils/vrad/vrad.cpp +++ b/sp/src/utils/vrad/vrad.cpp @@ -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; @@ -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")) { @@ -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" diff --git a/sp/src/utils/vrad/vrad.h b/sp/src/utils/vrad/vrad.h index 95fcd151907..48e0093c36b 100644 --- a/sp/src/utils/vrad/vrad.h +++ b/sp/src/utils/vrad/vrad.h @@ -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 //-----------------------------------------------------------------------------