Skip to content

Commit c0d19f6

Browse files
committed
vrad: Make scaling for light_environment samples configurable + bump it 30 -> 1024
See ValveSoftware/source-sdk-2013#1116
1 parent 2d0807c commit c0d19f6

File tree

3 files changed

+81
-58
lines changed

3 files changed

+81
-58
lines changed

utils/vrad/lightmap.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,9 +1656,6 @@ void ExportDirectLightsToWorldLights()
16561656

16571657
#define CONSTANT_DOT (.7/2)
16581658

1659-
#define NSAMPLES_SUN_AREA_LIGHT 30 // number of samples to take for an
1660-
// non-point sun light
1661-
16621659
// Helper function - gathers light from sun (emit_skylight)
16631660
void GatherSampleSkyLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, int facenum,
16641661
FourVectors const& pos, FourVectors *pNormals, int normalCount, int iThread,
@@ -1683,7 +1680,8 @@ void GatherSampleSkyLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, i
16831680
int nsamples = 1;
16841681
if ( g_SunAngularExtent > 0.0f )
16851682
{
1686-
nsamples = NSAMPLES_SUN_AREA_LIGHT;
1683+
// dimhotepus: Configurable number of samples to take for an non-point sun light.
1684+
nsamples = g_sunSamplesAreaLight;
16871685
if ( do_fast || force_fast )
16881686
nsamples /= 4;
16891687
}
@@ -1696,7 +1694,7 @@ void GatherSampleSkyLightSSE( SSE_sampleLightOutput_t &out, directlight_t *dl, i
16961694
for ( int d = 0; d < nsamples; d++ )
16971695
{
16981696
// determine visibility of skylight
1699-
// serach back to see if we can hit a sky brush
1697+
// search back to see if we can hit a sky brush
17001698
Vector delta;
17011699
VectorScale( dl->light.normal, -MAX_TRACE_LENGTH, delta );
17021700
if ( d )

utils/vrad/vrad.cpp

Lines changed: 76 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ unsigned num_degenerate_faces;
117117
qboolean g_bLowPriority = false;
118118
qboolean g_bLogHashData = false;
119119
bool g_bNoDetailLighting = false;
120+
// dimhotepus: Original VRAD has 30 non-point sun light samples count which is not enough for large surfaces.
121+
int g_sunSamplesAreaLight = 1024;
120122
double g_flStartTime;
121123
bool g_bStaticPropLighting = false;
122124
bool g_bStaticPropPolys = false;
@@ -2614,6 +2616,26 @@ static int ParseCommandLine( int argc, char **argv, bool *onlydetail )
26142616
return -1;
26152617
}
26162618
}
2619+
// dimhotepus: Allow to configure non-point sun light samples count.
2620+
else if (!Q_stricmp(argv[i], "-sunSamplesAreaLight"))
2621+
{
2622+
if (++i < argc)
2623+
{
2624+
int sunSamplesAreaLight = atoi(argv[i]);
2625+
if (sunSamplesAreaLight < 0)
2626+
{
2627+
Error("Expected non-negative samples count value after '-sunSamplesAreaLight'\n");
2628+
return -1;
2629+
}
2630+
g_sunSamplesAreaLight = sunSamplesAreaLight;
2631+
Msg("--sun-samples-area-light: %d\n", g_sunSamplesAreaLight);
2632+
}
2633+
else
2634+
{
2635+
Error("Expected a samples count value after '-sunSamplesAreaLight'\n");
2636+
return -1;
2637+
}
2638+
}
26172639
else if ( !Q_stricmp( argv[i], "-maxdispsamplesize" ) )
26182640
{
26192641
if ( ++i < argc )
@@ -2857,67 +2879,68 @@ void PrintUsage( int argc, char **argv )
28572879
"\n"
28582880
"Common options:\n"
28592881
"\n"
2860-
" -v (or -verbose): Turn on verbose output (also shows more command\n"
2861-
" -bounce # : Set max number of bounces (default: 100).\n"
2862-
" -fast : Quick and dirty lighting.\n"
2863-
" -fastambient : Per-leaf ambient sampling is lower quality to save compute time.\n"
2864-
" -final : High quality processing. equivalent to -extrasky 16.\n"
2865-
" -extrasky n : trace N times as many rays for indirect light and sky ambient.\n"
2866-
" -low : Run as an idle-priority process.\n"
2867-
" -mpi : Use VMPI to distribute computations.\n"
2868-
" -rederror : Show errors in red.\n"
2882+
" -v (or -verbose) : Turn on verbose output (also shows more command\n"
2883+
" -bounce # : Set max number of bounces (default: 100).\n"
2884+
" -fast : Quick and dirty lighting.\n"
2885+
" -fastambient : Per-leaf ambient sampling is lower quality to save compute time.\n"
2886+
" -final : High quality processing. equivalent to -extrasky 16.\n"
2887+
" -extrasky n : trace N times as many rays for indirect light and sky ambient.\n"
2888+
" -low : Run as an idle-priority process.\n"
2889+
" -mpi : Use VMPI to distribute computations.\n"
2890+
" -rederror : Show errors in red.\n"
28692891
"\n"
2870-
" -vproject <directory> : Override the VPROJECT environment variable.\n"
2871-
" -game <directory> : Same as -vproject.\n"
2892+
" -vproject <directory> : Override the VPROJECT environment variable.\n"
2893+
" -game <directory> : Same as -vproject.\n"
28722894
"\n"
28732895
"Other options:\n"
2874-
" -novconfig : Don't bring up graphical UI on vproject errors.\n"
2875-
" -dump : Write debugging .txt files.\n"
2876-
" -dumpnormals : Write normals to debug files.\n"
2877-
" -dumptrace : Write ray-tracing environment to debug files.\n"
2878-
" -threads : Control the number of threads vbsp uses (defaults to the #\n"
2879-
" or processors on your machine).\n"
2880-
" -lights <file> : Load a lights file in addition to lights.rad and the\n"
2881-
" level lights file.\n"
2882-
" -noextra : Disable supersampling.\n"
2883-
" -debugextra : Places debugging data in lightmaps to visualize\n"
2884-
" supersampling.\n"
2885-
" -smooth # : Set the threshold for smoothing groups, in degrees\n"
2886-
" (default 45).\n"
2887-
" -dlightmap : Force direct lighting into different lightmap than\n"
2888-
" radiosity.\n"
2889-
" -stoponexit : Wait for a keypress on exit.\n"
2890-
" -mpi_pw <pw> : Use a password to choose a specific set of VMPI workers.\n"
2891-
" -nodetaillight : Don't light detail props.\n"
2892-
" -centersamples : Move sample centers.\n"
2893-
" -luxeldensity # : Rescale all luxels by the specified amount (default: 1.0).\n"
2894-
" The number specified must be less than 1.0 or it will be\n"
2895-
" ignored.\n"
2896-
" -loghash : Log the sample hash table to samplehash.txt.\n"
2897-
" -onlydetail : Only light detail props and per-leaf lighting.\n"
2898-
" -maxdispsamplesize #: Set max displacement sample size (default: 512).\n"
2899-
" -softsun <n> : Treat the sun as an area light source of size <n> degrees."
2900-
" Produces soft shadows.\n"
2901-
" Recommended values are between 0 and 5. Default is 0.\n"
2902-
" -FullMinidumps : Write large minidumps on crash.\n"
2903-
" -chop : Smallest number of luxel widths for a bounce patch, used on edges\n"
2904-
" -maxchop : Coarsest allowed number of luxel widths for a patch, used in face interiors\n"
2896+
" -novconfig : Don't bring up graphical UI on vproject errors.\n"
2897+
" -dump : Write debugging .txt files.\n"
2898+
" -dumpnormals : Write normals to debug files.\n"
2899+
" -dumptrace : Write ray-tracing environment to debug files.\n"
2900+
" -threads : Control the number of threads vbsp uses (defaults to the #\n"
2901+
" or processors on your machine).\n"
2902+
" -lights <file> : Load a lights file in addition to lights.rad and the\n"
2903+
" level lights file.\n"
2904+
" -noextra : Disable supersampling.\n"
2905+
" -debugextra : Places debugging data in lightmaps to visualize\n"
2906+
" supersampling.\n"
2907+
" -smooth # : Set the threshold for smoothing groups, in degrees\n"
2908+
" (default 45).\n"
2909+
" -dlightmap : Force direct lighting into different lightmap than\n"
2910+
" radiosity.\n"
2911+
" -stoponexit : Wait for a keypress on exit.\n"
2912+
" -mpi_pw <pw> : Use a password to choose a specific set of VMPI workers.\n"
2913+
" -nodetaillight : Don't light detail props.\n"
2914+
" -centersamples : Move sample centers.\n"
2915+
" -luxeldensity # : Rescale all luxels by the specified amount (default: 1.0).\n"
2916+
" The number specified must be less than 1.0 or it will be\n"
2917+
" ignored.\n"
2918+
" -loghash : Log the sample hash table to samplehash.txt.\n"
2919+
" -onlydetail : Only light detail props and per-leaf lighting.\n"
2920+
" -maxdispsamplesize # : Set max displacement sample size (default: 512).\n"
2921+
" -softsun <n> : Treat the sun as an area light source of size <n> degrees."
2922+
" Produces soft shadows.\n"
2923+
" Recommended values are between 0 and 5 (default: 0).\n"
2924+
" -sunSamplesAreaLight # : Set max number of samples from the light_enviroment (default: 1024).\n"
2925+
" -FullMinidumps : Write large minidumps on crash.\n"
2926+
" -chop : Smallest number of luxel widths for a bounce patch, used on edges\n"
2927+
" -maxchop : Coarsest allowed number of luxel widths for a patch, used in face interiors\n"
29052928
"\n"
2906-
" -LargeDispSampleRadius: This can be used if there are splotches of bounced light\n"
2907-
" on terrain. The compile will take longer, but it will gather\n"
2908-
" light across a wider area.\n"
2909-
" -StaticPropLighting : generate backed static prop vertex lighting\n"
2910-
" -StaticPropPolys : Perform shadow tests of static props at polygon precision\n"
2911-
" -OnlyStaticProps : Only perform direct static prop lighting (vrad debug option)\n"
2912-
" -StaticPropNormals : when lighting static props, just show their normal vector\n"
2913-
" -textureshadows : Allows texture alpha channels to block light - rays intersecting alpha surfaces will sample the texture\n"
2914-
" -noskyboxrecurse : Turn off recursion into 3d skybox (skybox shadows on world)\n"
2915-
" -nossprops : Globally disable self-shadowing on static props\n"
2929+
" -LargeDispSampleRadius : This can be used if there are splotches of bounced light\n"
2930+
" on terrain. The compile will take longer, but it will gather\n"
2931+
" light across a wider area.\n"
2932+
" -StaticPropLighting : generate backed static prop vertex lighting\n"
2933+
" -StaticPropPolys : Perform shadow tests of static props at polygon precision\n"
2934+
" -OnlyStaticProps : Only perform direct static prop lighting (vrad debug option)\n"
2935+
" -StaticPropNormals : when lighting static props, just show their normal vector\n"
2936+
" -textureshadows : Allows texture alpha channels to block light - rays intersecting alpha surfaces will sample the texture\n"
2937+
" -noskyboxrecurse : Turn off recursion into 3d skybox (skybox shadows on world)\n"
2938+
" -nossprops : Globally disable self-shadowing on static props\n"
29162939
"\n"
29172940
#if 1 // Disabled for the initial SDK release with VMPI so we can get feedback from selected users.
29182941
);
29192942
#else
2920-
" -mpi_ListParams : Show a list of VMPI parameters.\n"
2943+
" -mpi_ListParams : Show a list of VMPI parameters.\n"
29212944
"\n"
29222945
);
29232946

utils/vrad/vrad.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646

4747
extern float dispchop; // "-dispchop" tightest number of luxel widths for a patch, used on edges
4848
extern float g_MaxDispPatchRadius;
49+
// dimhotepus: Make non-point sun light samples count configurable.
50+
extern int g_sunSamplesAreaLight;
4951

5052
//-----------------------------------------------------------------------------
5153
// forward declarations

0 commit comments

Comments
 (0)