Changeset 3311 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 02/13/09 18:37:42 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env
r3310 r3311 106 106 ssaoSampleIntensity=0.8f 107 107 # ssao temporal coherence factor 108 tempCohFactor=10 0.0f108 tempCohFactor=1024.0f 109 109 # ssao filter radius 110 110 ssaoFilterRadius=12.0f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3310 r3311 71 71 static GLuint noiseTex2D = 0; 72 72 static GLuint noiseTex1D = 0; 73 73 static GLuint sampleTex2D = 0; 74 74 75 75 … … 92 92 /** Helper method that computes the view vectors in the corners of the current view frustum. 93 93 */ 94 static void ComputeViewVectors(PerspectiveCamera *cam, Vector3 &bl, Vector3 &br, Vector3 &tl, Vector3 &tr) 94 static void ComputeViewVectors(PerspectiveCamera *cam, 95 Vector3 &bl, 96 Vector3 &br, 97 Vector3 &tl, 98 Vector3 &tr) 95 99 { 96 100 Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; … … 258 262 259 263 cout << "created noise texture" << endl; 264 265 PrintGLerror("noisetexture"); 266 } 267 268 269 static void CreateSampleTex(Sample2 *samples, int numSamples) 270 { 271 glEnable(GL_TEXTURE_2D); 272 glGenTextures(1, &sampleTex2D); 273 glBindTexture(GL_TEXTURE_2D, sampleTex2D); 274 275 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 276 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 277 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 278 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 279 280 int w = numSamples; 281 int h = 1; 282 283 float *tempBuffer = new float[numSamples * 3]; 284 285 for (int i = 0; i < numSamples; ++ i) 286 { 287 tempBuffer[i * 3 + 0] = samples[i].x; 288 tempBuffer[i * 3 + 1] = samples[i].y; 289 tempBuffer[i * 3 + 2] = 0; 290 291 } 292 293 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, w, h, 0, GL_RGB, GL_FLOAT, (float *)tempBuffer); 294 295 glBindTexture(GL_TEXTURE_2D, 0); 296 glDisable(GL_TEXTURE_2D); 297 298 cout << "created sample texture" << endl; 299 300 delete [] tempBuffer; 260 301 261 302 PrintGLerror("noisetexture"); … … 428 469 429 470 string ssaoParams[] = 430 471 {"colors", "normals", "oldTex", "noiseTex", "temporalCoherence", 431 472 "samples", "bl", "br", "tl", "tr", 432 473 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr", 433 474 "oldtl", "oldtr", "attribsTex", "kernelRadius", "sampleIntensity"}; 475 434 476 sCgSsaoProgram->AddParameters(ssaoParams, 0, 20); 435 477 … … 751 793 // needs longer to converge 752 794 GenerateSamples(mSamplingMethod); 753 795 CreateSampleTex(samples2, NUM_PRECOMPUTED_SAMPLES); 754 796 //if (mSortSamples) { SortSamples(); } 755 797 //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 756 sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_PRECOMPUTED_SAMPLES); 798 //sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_PRECOMPUTED_SAMPLES); 799 sCgSsaoProgram->SetTexture(i, sampleTex2D); 757 800 } 758 801 … … 772 815 de.y = mOldEyePos.y - mEyePos.y; 773 816 de.z = mOldEyePos.z - mEyePos.z; 817 774 818 775 819 sCgSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp
r3247 r3311 51 51 int tries = 0; 52 52 53 //cout << "minDist before= " << minDist << endl;53 cout << "minDist before= " << minDist << endl; 54 54 Sample2 *s = (Sample2 *)samples; 55 55 … … 109 109 } 110 110 111 //cout << "minDist after= " << (float)minDist / mNumSamples<< " #tries: " << tries << endl;111 cout << "minDist after= " << (float)minDist / mNumSamples<< " #tries: " << tries << endl; 112 112 } 113 113 … … 172 172 173 173 QuadraticDiscSampleGenerator2D::QuadraticDiscSampleGenerator2D(int numSamples, float radius): 174 //PoissonDiscSampleGenerator2D(numSamples, radius)175 RandomSampleGenerator2D(numSamples, radius)174 PoissonDiscSampleGenerator2D(numSamples, radius) 175 //RandomSampleGenerator2D(numSamples, radius) 176 176 {} 177 177 … … 194 194 #else 195 195 196 //PoissonDiscSampleGenerator2D::Generate(samples);197 RandomSampleGenerator2D::Generate(samples);196 PoissonDiscSampleGenerator2D::Generate(samples); 197 //RandomSampleGenerator2D::Generate(samples); 198 198 199 199 Sample2 *s = (Sample2 *)samples; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.h
r3247 r3311 78 78 with the distance 79 79 */ 80 //class QuadraticDiscSampleGenerator2D: public PoissonDiscSampleGenerator2D81 class QuadraticDiscSampleGenerator2D: public RandomSampleGenerator2D80 class QuadraticDiscSampleGenerator2D: public PoissonDiscSampleGenerator2D 81 //class QuadraticDiscSampleGenerator2D: public RandomSampleGenerator2D 82 82 { 83 83 public: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3306 r3311 1211 1211 if ((!shadowMap || !shadowTraverser) && (showShadowMap || renderLightView)) 1212 1212 { 1213 if (!shadowMap) 1214 shadowMap = new ShadowMap(light, shadowSize, bvh->GetBox(), camera); 1215 1216 if (!shadowTraverser) 1217 shadowTraverser = CreateTraverser(shadowMap->GetShadowCamera()); 1218 1213 if (!shadowMap) shadowMap = new ShadowMap(light, shadowSize, bvh->GetBox(), camera); 1214 if (!shadowTraverser) shadowTraverser = CreateTraverser(shadowMap->GetShadowCamera()); 1219 1215 } 1220 1216 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3309 r3311 5 5 //////////// 6 6 //-- ssao + gi parameters 7 #define NUM_PRECOMPUTED_SAMPLES 2007 #define NUM_PRECOMPUTED_SAMPLES 1024 8 8 //#define NUM_SAMPLES 8 9 9 //#define NUM_SAMPLES 16 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg
r3310 r3311 145 145 { 146 146 // the filtered ssao value 147 //OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence);147 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence); 148 148 } 149 149 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3309 r3311 263 263 264 264 // check if the pixel belonged to a dyanmic object in the last frame 265 const bool oldDynamic =(squaredLen > DYNAMIC_OBJECTS_THRESHOLD);266 const bool newDynamic =(oldPixel.z > DYNAMIC_OBJECTS_THRESHOLD);265 const bool newDynamic = false;//(squaredLen > DYNAMIC_OBJECTS_THRESHOLD); 266 const bool oldDynamic = false;//(oldPixel.z > DYNAMIC_OBJECTS_THRESHOLD); 267 267 268 268 // actually 0 means pixel is valid -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3310 r3311 224 224 sampler2D colors, 225 225 sampler2D noiseTex, 226 float2 samples[NUM_PRECOMPUTED_SAMPLES],226 sampler2D samples, 227 227 float3 normal, 228 228 float3 centerPosition, … … 236 236 float sampleIntensity, 237 237 bool isMovingObject, 238 int idx238 float idx 239 239 ) 240 240 { … … 251 251 //-- (affects performance for some reason!) 252 252 253 if (1)//convergence < SSAO_CONVERGENCE_THRESHOLD) 253 const float2 ssaoOffset = tex2Dlod(samples, float4((0.5f + i + idx) / NUM_PRECOMPUTED_SAMPLES, 0.5f, .0f, .0f)).xy; 254 255 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 254 256 { 255 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy;257 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord.x * 4.0f + idx * 0.01f, IN.texCoord.y * 4.0f, 0, 0)).xy; 256 258 //offset = myreflect(samples[i], mynoise); 257 offset = myrotate(samples[i], mynoise.x); 258 //offset = myrotate(samples[i + idx], mynoise.x); 259 //offset = myrotate(samples[i], mynoise.x); 260 261 offset = myrotate(ssaoOffset, mynoise.x); 259 262 } 260 263 else 261 264 { 262 //offset = samples[i + idx];263 offset = samples[i];265 offset = ssaoOffset; 266 //offset = samples[i]; 264 267 } 265 268 … … 312 315 // if the pixel belongs to a static object and all the samples stay valid in the current frame 313 316 if (!isMovingObject && (validSamples < 1.0f)) break; 314 // if the pixel belongs to a dynamic object but the #accumulated samples for this pixel is sufficiently high315 // (=> there was no discontinuity recently)317 // if the pixel belongs to a dynamic object but the #accumulated samples 318 // for this pixel is sufficiently high (=> there was no discontinuity recently) 316 319 else if (isMovingObject && (convergence > NUM_SAMPLES * 5)) break; 317 320 } … … 341 344 uniform sampler2D normals, 342 345 uniform sampler2D noiseTex, 343 uniform float2 samples[NUM_PRECOMPUTED_SAMPLES],346 uniform sampler2D samples, 344 347 uniform sampler2D oldTex, 345 348 uniform float4x4 modelViewProj, … … 400 403 float oldWeight = temporalVals.y; 401 404 402 int idx = (int)temporalVals.z; 403 //min(0, (int)oldWeight % max((int)temporalCoherence, 1)); 405 float idx = (int)temporalVals.z; 406 407 if (idx >= NUM_PRECOMPUTED_SAMPLES) idx = 0; 404 408 405 409 float3 ao; … … 425 429 // the weight equals the number of sampled shot in this pass 426 430 const float newWeight = ao.z; 431 432 idx += newWeight; 427 433 428 434 // completely reset the ao in this pixel … … 442 448 { 443 449 oldWeight = min(oldWeight, 4.0f * newWeight); 444 idx = oldWeight;445 450 } 446 451 } 447 448 float usedWeight = min(temporalCoherence, oldWeight);449 452 450 453 … … 452 455 //-- blend ao between old and new samples (and avoid division by zero) 453 456 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; 457 OUT.illum_col.x = ao.x * newWeight + oldSsao * oldWeight; 458 OUT.illum_col.x /= (newWeight + oldWeight); 458 459 459 460 // the new weight for the next frame 460 //const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 461 float combinedWeight = newWeight + oldWeight; 462 463 clamp(combinedWeight, 0, 1000); 464 461 const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 462 465 463 OUT.illum_col.y = combinedWeight; 466 464 // can be used to check if this pixel belongs to a moving object 467 OUT.illum_col.z = SqrLen(diffVec); 465 //OUT.illum_col.z = SqrLen(diffVec); 466 OUT.illum_col.z = idx; 468 467 OUT.illum_col.w = eyeSpaceDepth; 469 468
Note: See TracChangeset
for help on using the changeset viewer.