mirror of
https://github.com/id-Software/DOOM-3-BFG.git
synced 2024-12-03 09:22:45 +00:00
Updated embedded shadow mapping using rotated Poisson disc
This commit is contained in:
parent
c17773306c
commit
3dcade4c15
1 changed files with 65 additions and 2 deletions
|
@ -4383,7 +4383,7 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
"\n"
|
||||
" // multiple taps\n"
|
||||
" \n"
|
||||
"#if 1\n"
|
||||
"#if 0\n"
|
||||
" float4 base = shadowTexcoord;\n"
|
||||
" \n"
|
||||
" base.xy += rpJitterTexScale.xy * -0.5;\n"
|
||||
|
@ -4406,7 +4406,70 @@ static const cgShaderDef_t cg_renderprogs[] =
|
|||
" \n"
|
||||
" shadow *= stepSize;\n"
|
||||
"#else\n"
|
||||
" float shadow = texture( samp5, shadowTexcoord.xywz );\n"
|
||||
" \n"
|
||||
" \n"
|
||||
" const float2 poissonDisk[12] = float2[](\n"
|
||||
" float2(0.6111618, 0.1050905),\n"
|
||||
" float2(0.1088336, 0.1127091),\n"
|
||||
" float2(0.3030421, -0.6292974),\n"
|
||||
" float2(0.4090526, 0.6716492),\n"
|
||||
" float2(-0.1608387, -0.3867823),\n"
|
||||
" float2(0.7685862, -0.6118501),\n"
|
||||
" float2(-0.1935026, -0.856501),\n"
|
||||
" float2(-0.4028573, 0.07754025),\n"
|
||||
" float2(-0.6411021, -0.4748057),\n"
|
||||
" float2(-0.1314865, 0.8404058),\n"
|
||||
" float2(-0.7005203, 0.4596822),\n"
|
||||
" float2(-0.9713828, -0.06329931) );\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"
|
||||
" \n"
|
||||
" int numSamples = 12; //int(rpScreenCorrectionFactor.w);\n"
|
||||
" float stepSize = 1.0 / numSamples;\n"
|
||||
" \n"
|
||||
" float4 jitterTC = ( fragment.position * rpScreenCorrectionFactor ) + rpJitterTexOffset;\n"
|
||||
" float4 random = tex2D( samp6, jitterTC.xy ) * PI;\n"
|
||||
" //float4 random = fragment.position;\n"
|
||||
" \n"
|
||||
" float2 rot;\n"
|
||||
" rot.x = cos( random.x );\n"
|
||||
" rot.y = sin( random.x );\n"
|
||||
" \n"
|
||||
" float shadowTexelSize = rpScreenCorrectionFactor.z * rpJitterTexScale;\n"
|
||||
" for( int i = 0; i < numSamples; i++ )\n"
|
||||
" {\n"
|
||||
" float2 jitter = poissonDisk[i];\n"
|
||||
" float2 jitterRotated;\n"
|
||||
" jitterRotated.x = jitter.x * rot.x - jitter.y * rot.y;\n"
|
||||
" jitterRotated.y = jitter.x * rot.y + jitter.y * rot.x;\n"
|
||||
" \n"
|
||||
" float4 shadowTexcoordJittered = float4( shadowTexcoord.xy + jitterRotated * shadowTexelSize, shadowTexcoord.z, shadowTexcoord.w );\n"
|
||||
" \n"
|
||||
" shadow += texture( samp5, shadowTexcoordJittered.xywz);\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" shadow *= stepSize;\n"
|
||||
"\n"
|
||||
" //float shadow = texture( samp5, shadowTexcoord.xywz );\n"
|
||||
"#endif\n"
|
||||
"\n"
|
||||
" result.color.xyz = ( diffuseColor + specularColor ) * lambert * lightColor * fragment.color.rgb * shadow;// + rimColor;\n"
|
||||
|
|
Loading…
Reference in a new issue