Fixed r_shadowMapJitterScale for Poisson disc algorithm

This commit is contained in:
Robert Beckebans 2014-05-16 22:32:56 +02:00
parent 3dcade4c15
commit 54c31bff8f
3 changed files with 5 additions and 43 deletions

View file

@ -232,7 +232,6 @@ void main( PS_IN fragment, out PS_OUT result )
shadow *= stepSize; shadow *= stepSize;
#else #else
const float2 poissonDisk[12] = float2[]( const float2 poissonDisk[12] = float2[](
float2(0.6111618, 0.1050905), float2(0.6111618, 0.1050905),
float2(0.1088336, 0.1127091), float2(0.1088336, 0.1127091),
@ -247,27 +246,9 @@ void main( PS_IN fragment, out PS_OUT result )
float2(-0.7005203, 0.4596822), float2(-0.7005203, 0.4596822),
float2(-0.9713828, -0.06329931) ); float2(-0.9713828, -0.06329931) );
// const float2 poissonDisk[16] = float2[](
// float2( -0.94201624, -0.39906216 ),
// float2( 0.94558609, -0.76890725 ),
// float2( -0.094184101, -0.92938870 ),
// float2( 0.34495938, 0.29387760 ),
// float2( -0.91588581, 0.45771432 ),
// float2( -0.81544232, -0.87912464 ),
// float2( -0.38277543, 0.27676845 ),
// float2( 0.97484398, 0.75648379 ),
// float2( 0.44323325, -0.97511554 ),
// float2( 0.53742981, -0.47373420 ),
// float2( -0.26496911, -0.41893023 ),
// float2( 0.79197514, 0.19090188 ),
// float2( -0.24188840, 0.99706507 ),
// float2( -0.81409955, 0.91437590 ),
// float2( 0.19984126, 0.78641367 ),
// float2( 0.14383161, -0.14100790 )
// );
float shadow = 0.0; float shadow = 0.0;
// RB: casting a float to int and using it as index can really kill the performance ...
int numSamples = 12; //int(rpScreenCorrectionFactor.w); int numSamples = 12; //int(rpScreenCorrectionFactor.w);
float stepSize = 1.0 / numSamples; float stepSize = 1.0 / numSamples;
@ -280,7 +261,7 @@ void main( PS_IN fragment, out PS_OUT result )
rot.y = sin( random.x ); rot.y = sin( random.x );
float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale; float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale;
for( int i = 0; i < numSamples; i++ ) for( int i = 0; i < 12; i++ )
{ {
float2 jitter = poissonDisk[i]; float2 jitter = poissonDisk[i];
float2 jitterRotated; float2 jitterRotated;

View file

@ -4407,7 +4407,6 @@ static const cgShaderDef_t cg_renderprogs[] =
" shadow *= stepSize;\n" " shadow *= stepSize;\n"
"#else\n" "#else\n"
" \n" " \n"
" \n"
" const float2 poissonDisk[12] = float2[](\n" " const float2 poissonDisk[12] = float2[](\n"
" float2(0.6111618, 0.1050905),\n" " float2(0.6111618, 0.1050905),\n"
" float2(0.1088336, 0.1127091),\n" " float2(0.1088336, 0.1127091),\n"
@ -4422,27 +4421,9 @@ static const cgShaderDef_t cg_renderprogs[] =
" float2(-0.7005203, 0.4596822),\n" " float2(-0.7005203, 0.4596822),\n"
" float2(-0.9713828, -0.06329931) );\n" " float2(-0.9713828, -0.06329931) );\n"
" \n" " \n"
" // const float2 poissonDisk[16] = float2[](\n"
" // float2( -0.94201624, -0.39906216 ),\n"
" // float2( 0.94558609, -0.76890725 ),\n"
" // float2( -0.094184101, -0.92938870 ),\n"
" // float2( 0.34495938, 0.29387760 ),\n"
" // float2( -0.91588581, 0.45771432 ),\n"
" // float2( -0.81544232, -0.87912464 ),\n"
" // float2( -0.38277543, 0.27676845 ),\n"
" // float2( 0.97484398, 0.75648379 ),\n"
" // float2( 0.44323325, -0.97511554 ),\n"
" // float2( 0.53742981, -0.47373420 ),\n"
" // float2( -0.26496911, -0.41893023 ),\n"
" // float2( 0.79197514, 0.19090188 ),\n"
" // float2( -0.24188840, 0.99706507 ),\n"
" // float2( -0.81409955, 0.91437590 ),\n"
" // float2( 0.19984126, 0.78641367 ),\n"
" // float2( 0.14383161, -0.14100790 ) \n"
" // );\n"
" \n"
" float shadow = 0.0;\n" " float shadow = 0.0;\n"
" \n" " \n"
" // RB: casting a float to int and using it as index can really kill the performance ...\n"
" int numSamples = 12; //int(rpScreenCorrectionFactor.w);\n" " int numSamples = 12; //int(rpScreenCorrectionFactor.w);\n"
" float stepSize = 1.0 / numSamples;\n" " float stepSize = 1.0 / numSamples;\n"
" \n" " \n"
@ -4455,7 +4436,7 @@ static const cgShaderDef_t cg_renderprogs[] =
" rot.y = sin( random.x );\n" " rot.y = sin( random.x );\n"
" \n" " \n"
" float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale;\n" " float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale;\n"
" for( int i = 0; i < numSamples; i++ )\n" " for( int i = 0; i < 12; i++ )\n"
" {\n" " {\n"
" float2 jitter = poissonDisk[i];\n" " float2 jitter = poissonDisk[i];\n"
" float2 jitterRotated;\n" " float2 jitterRotated;\n"

View file

@ -222,7 +222,7 @@ idCVar r_useShadowMapping( "r_useShadowMapping", "1", CVAR_RENDERER | CVAR_ARCHI
idCVar r_shadowMapFrustumFOV( "r_shadowMapFrustumFOV", "92", CVAR_RENDERER | CVAR_FLOAT, "oversize FOV for point light side matching" ); idCVar r_shadowMapFrustumFOV( "r_shadowMapFrustumFOV", "92", CVAR_RENDERER | CVAR_FLOAT, "oversize FOV for point light side matching" );
idCVar r_shadowMapSingleSide( "r_shadowMapSingleSide", "-1", CVAR_RENDERER | CVAR_INTEGER, "only draw a single side (0-5) of point lights" ); idCVar r_shadowMapSingleSide( "r_shadowMapSingleSide", "-1", CVAR_RENDERER | CVAR_INTEGER, "only draw a single side (0-5) of point lights" );
idCVar r_shadowMapImageSize( "r_shadowMapImageSize", "1024", CVAR_RENDERER | CVAR_INTEGER, "", 128, 2048 ); idCVar r_shadowMapImageSize( "r_shadowMapImageSize", "1024", CVAR_RENDERER | CVAR_INTEGER, "", 128, 2048 );
idCVar r_shadowMapJitterScale( "r_shadowMapJitterScale", "0.006", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter offset" ); idCVar r_shadowMapJitterScale( "r_shadowMapJitterScale", "3", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter offset" );
idCVar r_shadowMapBiasScale( "r_shadowMapBiasScale", "0.0001", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter bias" ); idCVar r_shadowMapBiasScale( "r_shadowMapBiasScale", "0.0001", CVAR_RENDERER | CVAR_FLOAT, "scale factor for jitter bias" );
idCVar r_shadowMapRandomizeJitter( "r_shadowMapRandomizeJitter", "1", CVAR_RENDERER | CVAR_BOOL, "randomly offset jitter texture each draw" ); idCVar r_shadowMapRandomizeJitter( "r_shadowMapRandomizeJitter", "1", CVAR_RENDERER | CVAR_BOOL, "randomly offset jitter texture each draw" );
idCVar r_shadowMapSamples( "r_shadowMapSamples", "1", CVAR_RENDERER | CVAR_INTEGER, "0, 1, 4, or 16" ); idCVar r_shadowMapSamples( "r_shadowMapSamples", "1", CVAR_RENDERER | CVAR_INTEGER, "0, 1, 4, or 16" );