- Timestamp:
- 02/13/09 15:59:33 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env
r3309 r3310 106 106 ssaoSampleIntensity=0.8f 107 107 # ssao temporal coherence factor 108 tempCohFactor=1 50.0f108 tempCohFactor=100.0f 109 109 # ssao filter radius 110 110 ssaoFilterRadius=12.0f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3309 r3310 208 208 case DeferredRenderer::SAMPLING_QUADRATIC: 209 209 { 210 staticQuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f);210 QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 211 211 //static QuadraticDiscSampleGenerator2D g(NUM_SAMPLES, 1.0f); 212 212 g.Generate((float *)samples2); … … 741 741 sCgSsaoProgram->SetTexture(i ++, noiseTex2D); 742 742 743 sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0);743 sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : .0f); 744 744 745 745 if (/*mUseTemporalCoherence || */mRegenerateSamples) -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg
r3306 r3310 114 114 } 115 115 116 117 /** In between step that only filters in one direction 118 */ 119 pixel FilterSsaoHalfRes(fragment IN, 120 uniform sampler2D colorsTex, 121 uniform sampler2D ssaoTex, 122 uniform float3 bl, 123 uniform float3 br, 124 uniform float3 tl, 125 uniform float3 tr, 126 uniform float2 res 127 ) 128 { 129 pixel OUT; 130 131 const float depth = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)).w; 132 133 OUT.illum_col = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 134 // compute minimal convergence for savetly reasons, write it out 135 const float convergence = ComputeConvergenceHalfRes(ssaoTex, IN.texCoord, res * 0.5f); 136 OUT.illum_col.y = convergence; 137 138 const float2 xyStep = float2(1.0f / res.x, 0); 139 140 // filter reaches size 1 pixel when sample size reaches threshold 141 // afterwards we do not use the filter anymore 142 143 // filter up to a certain convergance value and leave out background (sky) by checking depth 144 if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 145 { 146 // the filtered ssao value 147 //OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence); 148 } 149 150 return OUT; 151 } 152 153 116 154 /** In between step that only filters in one direction 117 155 */ … … 137 175 // afterwards we do not use the filter anymore 138 176 139 float2 xyStep = float2(1.0f / res.x, 0);177 const float2 xyStep = float2(1.0f / res.x, 0); 140 178 141 179 // filter up to a certain convergance value and leave out background (sky) by checking depth … … 149 187 } 150 188 151 /** In between step that only filters in one direction152 */153 pixel FilterSsaoHalfRes(fragment IN,154 uniform sampler2D colorsTex,155 uniform sampler2D ssaoTex,156 uniform float3 bl,157 uniform float3 br,158 uniform float3 tl,159 uniform float3 tr,160 uniform float2 res161 )162 {163 pixel OUT;164 165 const float depth = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)).w;166 167 OUT.illum_col = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0));168 // compute minimal convergence for savetly reasons, write it out169 const float convergence = ComputeConvergenceHalfRes(ssaoTex, IN.texCoord, res * 0.5f);170 OUT.illum_col.y = convergence;171 172 const float2 xyStep = float2(1.0f / res.x, 0);173 174 // filter reaches size 1 pixel when sample size reaches threshold175 // afterwards we do not use the filter anymore176 177 // filter up to a certain convergance value and leave out background (sky) by checking depth178 if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD))179 {180 // the filtered ssao value181 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence);182 }183 184 return OUT;185 }186 189 187 190 /** Function combining image and indirect illumination buffer using a -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3309 r3310 48 48 weight of the pixel in the new frame. 49 49 */ 50 inline float 2temporalSmoothing(float4 worldPos,50 inline float3 temporalSmoothing(float4 worldPos, 51 51 float eyeSpaceDepth, 52 52 float2 texcoord0, … … 96 96 // the weight of the accumulated samples from the previous frames 97 97 float w; 98 float idx; 98 99 99 100 ////////////// … … 108 109 // pixel valid => retrieve the convergence weight 109 110 w = oldPixel.y; 111 idx = oldPixel.z; 110 112 } 111 113 else 112 114 { 113 w = 0.0f; 114 } 115 116 return float2(ssao, w); 115 w = .0f; 116 idx = .0f; 117 } 118 119 return float3(ssao, w, idx); 117 120 } 118 121 … … 141 144 float numSamples = .0f; 142 145 float validSamples = .0f; 146 143 147 144 148 for (int i = 0; i < NUM_PRECOMPUTED_SAMPLES; ++ i) … … 247 251 //-- (affects performance for some reason!) 248 252 249 if ( convergence < SSAO_CONVERGENCE_THRESHOLD)253 if (1)//convergence < SSAO_CONVERGENCE_THRESHOLD) 250 254 { 251 255 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 252 256 //offset = myreflect(samples[i], mynoise); 253 offset = myrotate(samples[i + idx], mynoise.x); 257 offset = myrotate(samples[i], mynoise.x); 258 //offset = myrotate(samples[i + idx], mynoise.x); 254 259 } 255 260 else 256 261 { 257 offset = samples[i + idx]; 262 //offset = samples[i + idx]; 263 offset = samples[i]; 258 264 } 259 265 … … 382 388 //-- compute temporal reprojection 383 389 384 float 2temporalVals = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos,390 float3 temporalVals = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 385 391 oldTex, oldModelViewProj, 386 392 colors, … … 394 400 float oldWeight = temporalVals.y; 395 401 396 float usedWeight = min(temporalCoherence, abs(oldWeight));397 int idx = (int)oldWeight % (int)temporalCoherence;402 int idx = (int)temporalVals.z; 403 //min(0, (int)oldWeight % max((int)temporalCoherence, 1)); 398 404 399 405 float3 ao; … … 402 408 if (eyeSpaceDepth < DEPTH_THRESHOLD) 403 409 { 404 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), usedWeight, sampleIntensity, isMovingObject, idx); 410 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, 411 scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, 412 sampleIntensity, isMovingObject, idx); 405 413 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 406 414 } … … 428 436 if (ao.y > completelyResetThres) 429 437 { 430 oldWeight = .0f; 438 oldWeight = .0f; 439 idx = .0f; 431 440 } 432 441 else if (ao.y > partlyResetThres) 433 442 { 434 443 oldWeight = min(oldWeight, 4.0f * newWeight); 435 //oldWeight = .0f;444 idx = oldWeight; 436 445 } 437 446 } 447 448 float usedWeight = min(temporalCoherence, oldWeight); 449 438 450 439 451 ////////// 440 452 //-- blend ao between old and new samples (and avoid division by zero) 441 453 442 OUT.illum_col.x = ao.x * newWeight + oldSsao * usedWeight; 443 OUT.illum_col.x /= (newWeight + usedWeight); 454 OUT.illum_col.x = ao.x * newWeight;// + oldSsao * usedWeight; 455 OUT.illum_col.x /= max(newWeight + usedWeight, 1); 456 457 //if (oldWeight >= 10000) oldWeight = 1000; 444 458 445 459 // the new weight for the next frame 446 460 //const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 447 const float combinedWeight = newWeight + oldWeight; 461 float combinedWeight = newWeight + oldWeight; 462 463 clamp(combinedWeight, 0, 1000); 448 464 449 465 OUT.illum_col.y = combinedWeight;
Note: See TracChangeset
for help on using the changeset viewer.