Changeset 3225 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Timestamp:
- 12/19/08 01:56:47 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3224 r3225 131 131 StatsWriter *statsWriter = NULL; 132 132 133 bool makeSnapShot = false; 134 133 135 134 136 /// the technique used for rendering … … 1038 1040 //-- update animations 1039 1041 1040 Matrix4x4 rotMatrix = RotationZMatrix(M_PI * 1e-3f); 1042 //const float rotAngle = M_PI * 1e-3f; 1043 const float rotAngle = 1.0f * M_PI / 180.0f; 1044 1045 Matrix4x4 rotMatrix = RotationZMatrix(rotAngle); 1041 1046 dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 1042 1047 1043 1048 motionPath->Move(0.01f); 1044 1045 1049 1046 1050 … … 1263 1267 } 1264 1268 1269 static int snapShotIdx = 0; 1270 1265 1271 deferredShader->SetSunVisiblePixels(sunVisiblePixels); 1266 1272 deferredShader->SetShadingMethod(shadingMethod); … … 1271 1277 deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 1272 1278 deferredShader->SetSortSamples(sortSamples); 1273 deferredShader->SetSaveFrame(recordedFramesSuffix, (recordFrames && replayPath) ? currentReplayFrame : -1); 1279 1280 if (recordFrames && replayPath) 1281 deferredShader->SetSaveFrame(recordedFramesSuffix, currentReplayFrame); 1282 else if (makeSnapShot) 1283 deferredShader->SetSaveFrame("snap", snapShotIdx ++); 1284 else 1285 deferredShader->SetSaveFrame("", -1); 1286 1287 if (makeSnapShot) makeSnapShot = false; 1274 1288 1275 1289 ShadowMap *sm = showShadowMap ? shadowMap : NULL; … … 1503 1517 // move light source instead of camera tilt 1504 1518 moveLight = !moveLight; 1519 break; 1520 case '#': 1521 // make a snapshot of the current frame 1522 makeSnapShot = true; 1505 1523 break; 1506 1524 default: … … 2379 2397 cout << "\nloading model " << filename << endl; 2380 2398 if (resourceManager->Load(filename, entities)) 2399 { 2381 2400 cout << "model " << filename << " successfully loaded" << endl; 2401 } 2382 2402 else 2383 2403 { 2384 2404 cerr << "loading model " << filename << " failed" << endl; 2405 2385 2406 CleanUp(); 2386 2407 exit(0); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3221 r3225 6 6 //-- ssao + gi parameters 7 7 8 #define NUM_SAMPLES 88 //#define NUM_SAMPLES 8 9 9 //#define NUM_SAMPLES 16 10 //#define NUM_SAMPLES 2410 #define NUM_SAMPLES 24 11 11 //#define NUM_SAMPLES 48 12 12 … … 58 58 #define DYNAMIC_OBJECTS_THRESHOLD 1e-8f 59 59 60 #define USE_GTX61 60 62 61 #endif // __SHADERENV_H -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3216 r3225 138 138 const float minConvergence = min(m1, m2); 139 139 140 const float convergence = minConvergence;140 //const float convergence = minConvergence; 141 141 //const float convergence = 0; 142 //const float convergence = ao.y;142 const float convergence = ao.y; 143 143 144 144 // filter reaches size 1 pixel when sample size reaches threshold … … 159 159 } 160 160 161 // just apply ssao if we are not in the sky 161 162 if (col.w < 1e10f) 162 163 OUT.illum_col.xyz = col.xyz * max(1e-1f, 1.0f - ao.x); … … 164 165 OUT.illum_col.xyz = col.xyz; 165 166 167 168 //OUT.illum_col.xyz = float3(abs(ao.y * 1e2f), abs(ao.z * 1e2f), abs(ao.w * 1e2f)); 169 170 //if (convergence < (1.0f + NUM_SAMPLES * 10)) 171 // OUT.illum_col.xyz = float3(1 - convergence / (NUM_SAMPLES * 10), convergence / (NUM_SAMPLES * 10), 0); 172 173 //OUT.illum_col.xyz = float3(ao.z * 1e4f, ao.z * 1e4f, ao.z * 1e4f); 174 166 175 //OUT.illum_col.xyz = float3(ao.x, ao.x, step(thres, convergence)); 167 //OUT.illum_col.xyz = float3(0, convergence, 0);168 176 //OUT.illum_col.xyz = float3(abs(center.x - IN.texCoord.x) * 16.0f, abs(center.y - IN.texCoord.y) * 12.0f, 0); 169 170 //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1);171 177 //OUT.illum_col.xyz = float3(0, 1.0f - step(0.5f + NUM_SAMPLES, convergence), 1); 178 172 179 OUT.illum_col.w = col.w; 173 180 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3221 r3225 119 119 const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 120 120 121 const float xOffs = 1.0f / 1024.0f; 122 const float yOffs = 1.0f / 768.0f; 123 const float eps = 1e-6f; 124 125 // the weight of the old value 121 //const float xOffs = 1.0f / 1024.0f; const float yOffs = 1.0f / 768.0f; const float eps = 1e-6f; 122 123 // the weight of the accumulated samples from the previous frames 126 124 float w; 127 125 … … 130 128 131 129 if (1 132 && (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= 1.0f - xOffs + eps) 133 && (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= 1.0f - yOffs + eps) 130 // && (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= 1.0f - xOffs + eps) 131 // && (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= 1.0f - yOffs + eps) 132 && (oldTexCoords.x > 0) && (oldTexCoords.x < 1.0f) 133 && (oldTexCoords.y > 0) && (oldTexCoords.y < 1.0f) 134 134 && (depthDif <= MIN_DEPTH_DIFF) 135 135 ) … … 215 215 //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 216 216 217 #if 1218 // if surface normal perpenticular to view dir, approx. half of the samples will not count219 // => compensate for this (on the other hand, projected sampling area could be larger!)220 221 const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f);222 total_ao += cosAngle * aoContrib * viewCorrection;223 #else224 217 total_ao += cosAngle * aoContrib; 225 #endif 218 226 219 // check if the samples have been valid in the last frame 227 220 validSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x; … … 231 224 232 225 total_ao /= numSamples; 226 227 #if 1 228 // if surface normal perpenticular to view dir, approx. half of the samples will not count 229 // => compensate for this (on the other hand, projected sampling area could be larger!) 230 const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f); 231 total_ao += cosAngle * aoContrib * viewCorrection; 232 233 #endif 233 234 234 235 return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); … … 302 303 //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 303 304 304 #if 1305 // if surface normal perpenticular to view dir, approx. half of the samples will not count306 // => compensate for this (on the other hand, projected sampling area could be larger!)307 308 const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f);309 total_ao += cosAngle * aoContrib * viewCorrection;310 #else311 305 total_ao += cosAngle * aoContrib; 312 #endif313 306 314 307 ++ numSamples; … … 325 318 validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid); 326 319 327 #ifdef QWQ//USE_GTX320 #ifdef USE_GTX 328 321 // we can bail out early and use a minimal #samples) 329 322 // if some conditions are met as long as the hardware supports it … … 337 330 } 338 331 #endif 339 340 } 341 342 // scale ao contribution 332 } 333 334 // "normalize" ao contribution 343 335 total_ao /= numSamples; 336 337 #if 1 338 // if surface normal perpenticular to view dir, approx. half of the samples will not count 339 // => compensate for this (on the other hand, projected sampling area could be larger!) 340 const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f); 341 total_ao *= viewCorrection; 342 #endif 344 343 345 344 return float3(total_ao, validSamples, numSamples); … … 434 433 const float newWeight = ao.z; 435 434 435 // completely reset the ao in this pixel 436 436 const float completelyResetThres = 4.0f; 437 // don't fully reset the ao in this pixel, but give low weight to old solution 437 438 const float partlyResetThres = 1.0f; 438 439 … … 440 441 { 441 442 if (ao.y > completelyResetThres) 443 { 442 444 oldWeight = .0f; 445 } 443 446 else if (ao.y > partlyResetThres) 444 oldWeight = min(oldWeight, 4.0f * newWeight); 447 { 448 //oldWeight = min(oldWeight, 4.0f * newWeight); 449 oldWeight = .0f; 450 } 445 451 } 446 452 … … 448 454 const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 449 455 456 450 457 ////////// 451 458 //-- blend ao between old and new samples (and avoid division by zero) 459 452 460 OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, newWeight + oldWeight); 453 461 462 OUT.illum_col.y = combinedWeight; 463 // can be used to check if this pixel belongs to a moving object 454 464 OUT.illum_col.z = SqrLen(diffVec); 455 OUT.illum_col.y = combinedWeight;456 465 OUT.illum_col.w = eyeSpaceDepth; 457 466 467 //OUT.illum_col.yzw = diffVec; 468 458 469 return OUT; 459 470 }
Note: See TracChangeset
for help on using the changeset viewer.