Skip to content

Commit 54c31bf

Browse files
Fixed r_shadowMapJitterScale for Poisson disc algorithm
1 parent 3dcade4 commit 54c31bf

File tree

3 files changed

+5
-43
lines changed

3 files changed

+5
-43
lines changed

base/renderprogs/interactionSM.pixel

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,6 @@ void main( PS_IN fragment, out PS_OUT result )
232232
shadow *= stepSize;
233233
#else
234234

235-
236235
const float2 poissonDisk[12] = float2[](
237236
float2(0.6111618, 0.1050905),
238237
float2(0.1088336, 0.1127091),
@@ -247,27 +246,9 @@ void main( PS_IN fragment, out PS_OUT result )
247246
float2(-0.7005203, 0.4596822),
248247
float2(-0.9713828, -0.06329931) );
249248

250-
// const float2 poissonDisk[16] = float2[](
251-
// float2( -0.94201624, -0.39906216 ),
252-
// float2( 0.94558609, -0.76890725 ),
253-
// float2( -0.094184101, -0.92938870 ),
254-
// float2( 0.34495938, 0.29387760 ),
255-
// float2( -0.91588581, 0.45771432 ),
256-
// float2( -0.81544232, -0.87912464 ),
257-
// float2( -0.38277543, 0.27676845 ),
258-
// float2( 0.97484398, 0.75648379 ),
259-
// float2( 0.44323325, -0.97511554 ),
260-
// float2( 0.53742981, -0.47373420 ),
261-
// float2( -0.26496911, -0.41893023 ),
262-
// float2( 0.79197514, 0.19090188 ),
263-
// float2( -0.24188840, 0.99706507 ),
264-
// float2( -0.81409955, 0.91437590 ),
265-
// float2( 0.19984126, 0.78641367 ),
266-
// float2( 0.14383161, -0.14100790 )
267-
// );
268-
269249
float shadow = 0.0;
270250

251+
// RB: casting a float to int and using it as index can really kill the performance ...
271252
int numSamples = 12; //int(rpScreenCorrectionFactor.w);
272253
float stepSize = 1.0 / numSamples;
273254

@@ -280,7 +261,7 @@ void main( PS_IN fragment, out PS_OUT result )
280261
rot.y = sin( random.x );
281262

282263
float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale;
283-
for( int i = 0; i < numSamples; i++ )
264+
for( int i = 0; i < 12; i++ )
284265
{
285266
float2 jitter = poissonDisk[i];
286267
float2 jitterRotated;

neo/renderer/RenderProgs_embedded.h

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4407,7 +4407,6 @@ static const cgShaderDef_t cg_renderprogs[] =
44074407
" shadow *= stepSize;\n"
44084408
"#else\n"
44094409
" \n"
4410-
" \n"
44114410
" const float2 poissonDisk[12] = float2[](\n"
44124411
" float2(0.6111618, 0.1050905),\n"
44134412
" float2(0.1088336, 0.1127091),\n"
@@ -4422,27 +4421,9 @@ static const cgShaderDef_t cg_renderprogs[] =
44224421
" float2(-0.7005203, 0.4596822),\n"
44234422
" float2(-0.9713828, -0.06329931) );\n"
44244423
" \n"
4425-
" // const float2 poissonDisk[16] = float2[](\n"
4426-
" // float2( -0.94201624, -0.39906216 ),\n"
4427-
" // float2( 0.94558609, -0.76890725 ),\n"
4428-
" // float2( -0.094184101, -0.92938870 ),\n"
4429-
" // float2( 0.34495938, 0.29387760 ),\n"
4430-
" // float2( -0.91588581, 0.45771432 ),\n"
4431-
" // float2( -0.81544232, -0.87912464 ),\n"
4432-
" // float2( -0.38277543, 0.27676845 ),\n"
4433-
" // float2( 0.97484398, 0.75648379 ),\n"
4434-
" // float2( 0.44323325, -0.97511554 ),\n"
4435-
" // float2( 0.53742981, -0.47373420 ),\n"
4436-
" // float2( -0.26496911, -0.41893023 ),\n"
4437-
" // float2( 0.79197514, 0.19090188 ),\n"
4438-
" // float2( -0.24188840, 0.99706507 ),\n"
4439-
" // float2( -0.81409955, 0.91437590 ),\n"
4440-
" // float2( 0.19984126, 0.78641367 ),\n"
4441-
" // float2( 0.14383161, -0.14100790 ) \n"
4442-
" // );\n"
4443-
" \n"
44444424
" float shadow = 0.0;\n"
44454425
" \n"
4426+
" // RB: casting a float to int and using it as index can really kill the performance ...\n"
44464427
" int numSamples = 12; //int(rpScreenCorrectionFactor.w);\n"
44474428
" float stepSize = 1.0 / numSamples;\n"
44484429
" \n"
@@ -4455,7 +4436,7 @@ static const cgShaderDef_t cg_renderprogs[] =
44554436
" rot.y = sin( random.x );\n"
44564437
" \n"
44574438
" float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale;\n"
4458-
" for( int i = 0; i < numSamples; i++ )\n"
4439+
" for( int i = 0; i < 12; i++ )\n"
44594440
" {\n"
44604441
" float2 jitter = poissonDisk[i];\n"
44614442
" float2 jitterRotated;\n"

neo/renderer/RenderSystem_init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ idCVar r_useShadowMapping( "r_useShadowMapping", "1", CVAR_RENDERER | CVAR_ARCHI
222222
idCVar r_shadowMapFrustumFOV( "r_shadowMapFrustumFOV", "92", CVAR_RENDERER | CVAR_FLOAT, "oversize FOV for point light side matching" );
223223
idCVar r_shadowMapSingleSide( "r_shadowMapSingleSide", "-1", CVAR_RENDERER | CVAR_INTEGER, "only draw a single side (0-5) of point lights" );
224224
idCVar r_shadowMapImageSize( "r_shadowMapImageSize", "1024", CVAR_RENDERER | CVAR_INTEGER, "", 128, 2048 );
225-
idCVar r_shadowMapJitterScale( "r_shadowMapJitterScale", "0.006", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter offset" );
225+
idCVar r_shadowMapJitterScale( "r_shadowMapJitterScale", "3", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter offset" );
226226
idCVar r_shadowMapBiasScale( "r_shadowMapBiasScale", "0.0001", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter bias" );
227227
idCVar r_shadowMapRandomizeJitter( "r_shadowMapRandomizeJitter", "1", CVAR_RENDERER | CVAR_BOOL, "randomly offset jitter texture each draw" );
228228
idCVar r_shadowMapSamples( "r_shadowMapSamples", "1", CVAR_RENDERER | CVAR_INTEGER, "0, 1, 4, or 16" );

0 commit comments

Comments
 (0)