Changeset 3133 for GTP/trunk/App/Demos
- Timestamp:
- 11/17/08 19:43:12 (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/DeferredRenderer.cpp
r3132 r3133 94 94 { 95 95 float g = 1.0f / sqrtf(2.0f * M_PI * rho * rho); 96 g *= expf( -(x *x + y*y) / (2.0f * rho * rho));96 g *= expf( -(x * x + y * y) / (2.0f * rho * rho)); 97 97 98 98 return g; … … 139 139 140 140 idx += 2; 141 } 142 } 143 } 144 145 146 static void ComputeSampleOffsets2(float *sampleOffsets, int w, int h, float width, int samples) 147 { 148 const float xoffs = width / (float)w; 149 const float yoffs = width / (float)h; 150 151 const int numSamples = (int)sqrt((float)samples); 152 153 for (int x = 0; x < numSamples; ++ x) 154 { 155 for (int y = 0; y < numSamples; ++ y) 156 { 157 int idx = (y * numSamples + x) * 2; 158 sampleOffsets[idx + 0] = ((float)x - 0.5f * numSamples) * xoffs; 159 sampleOffsets[idx + 1] = ((float)y - 0.5f * numSamples) * yoffs; 141 160 } 142 161 } … … 445 464 /////////// 446 465 447 466 #if 0 448 467 PoissonDiscSampleGenerator2 poisson(NUM_SSAO_FILTERSAMPLES, 1.0f); 449 468 poisson.Generate((float *)ssaoFilterOffsets); 450 469 451 //const float filterWidth = 10.0f; 452 //const float filterWidth = 6.0f; 453 const float filterWidth = 20.0f; 454 455 //const float xoffs = filterWidth / mDownSampleFbo->GetWidth(); 456 //const float yoffs = filterWidth / mDownSampleFbo->GetHeight(); 470 const float filterWidth = 10.0f; 457 471 const float xoffs = (float)filterWidth / mWidth; 458 472 const float yoffs = (float)filterWidth / mHeight; … … 463 477 float y = ssaoFilterOffsets[2 * i + 1]; 464 478 465 ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f);466 //ssaoFilterWeights[i] = 1.0f;479 //ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 480 ssaoFilterWeights[i] = 1.0f; 467 481 468 482 ssaoFilterOffsets[2 * i + 0] *= xoffs; 469 483 ssaoFilterOffsets[2 * i + 1] *= yoffs; 470 484 } 471 485 #else 486 //ComputeSampleOffsets(ssaoFilterOffsets, 1024, 768, sqrt(NUM_SSAO_FILTERSAMPLES), NUM_SSAO_FILTERSAMPLES); 487 ComputeSampleOffsets2(ssaoFilterOffsets, 1024, 768, 5, NUM_SSAO_FILTERSAMPLES); 488 489 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 490 ssaoFilterWeights[i] = 1.0f; 491 492 #endif 493 494 /////// 495 //-- pcf tabs for shadowing 472 496 473 497 float filterWeights[NUM_PCF_TABS]; … … 501 525 FirstPass(fbo, light); 502 526 503 504 527 if (mShadingMethod != 0) 505 528 { 506 // downsample fbo buffers for colors 507 DownSample(fbo, colorBufferIdx, mDownSampleFbo, 0); 508 // normals 509 DownSample(fbo, 1, mDownSampleFbo, 1); 510 // offsets 511 DownSample(fbo, 2, mDownSampleFbo, 2); 512 } 513 529 // downsample fbo buffers 530 DownSample(fbo, colorBufferIdx, mDownSampleFbo, 0); // colors 531 DownSample(fbo, 1, mDownSampleFbo, 1); // normals 532 DownSample(fbo, 2, mDownSampleFbo, 2); // offsets 533 } 534 535 // antialiasing of the color buffer 514 536 AntiAliasing(fbo, light); 515 537 … … 518 540 case SSAO: 519 541 ComputeSsao(fbo, tempCohFactor); 520 //SmoothSsao(fbo);542 SmoothSsao(fbo); 521 543 CombineSsao(fbo); 522 544 break; … … 562 584 GLuint colorsTex, normalsTex, attribsTex; 563 585 564 if ( 1)586 if (0) 565 587 { 566 588 colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); … … 794 816 GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 795 817 GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 796 //GLuint ssaoTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture();797 GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetTexture();818 GLuint ssaoTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 819 //GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetTexture(); 798 820 799 821 FlipFbos(fbo); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3128 r3133 58 58 #define NUM_DOWNSAMPLES 9 59 59 60 #define NUM_SSAO_FILTERSAMPLES 5060 #define NUM_SSAO_FILTERSAMPLES 49 61 61 //#define NUM_SSAO_FILTERSAMPLES 40 62 62 //#define NUM_SSAO_FILTERSAMPLES 100 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3132 r3133 78 78 float depthFactor; 79 79 float normalFactor; 80 float converganceFactor; 80 81 81 82 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) … … 89 90 depthFactor = max(step(5e-1f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 90 91 normalFactor = max(step(0.6f, dot(sampleNorm, norm)), 1e-3f); 91 92 w = filterWeights[i] * normalFactor * depthFactor; 92 converganceFactor = max(step(8.5f, aoSample.y), 1e-3f); 93 94 //w = filterWeights[i] * normalFactor * depthFactor * converganceFactor; 95 w = filterWeights[i];// * normalFactor * converganceFactor; 93 96 //w = filterWeights[i] * depthFactor; 94 97 … … 107 110 uniform sampler2D ssaoTex, 108 111 uniform sampler2D normalsTex, 112 uniform sampler2D offsetTex, 109 113 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 110 114 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES] … … 119 123 if (col.w < 1e10f) 120 124 { 121 const float xoffs = 4.0f / 1024.0f; 122 const float yoffs = 4.0f / 768.0f; 123 /* 125 const float xoffs = 20.0f / 1024.0f; 126 const float yoffs = 20.0f / 768.0f; 127 128 /*float3 b2 = tex2Dlod(offsetTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).xyz; 129 float3 b3 = tex2Dlod(offsetTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).xyz; 130 float3 b4 = tex2Dlod(offsetTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).xyz; 131 float3 b5 = tex2Dlod(offsetTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).xyz; 132 133 float border = step(0.001f, b2 134 124 135 //float3 id = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 125 float3 x2 = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).xyz; 136 */ 137 138 /*float3 x2 = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).xyz; 126 139 float3 x3 = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).xyz; 127 140 float3 x4 = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).xyz; … … 129 142 130 143 //ao.x = (ao.x + x2 + x3 + x4 + x5) * 0.2f; 144 if (ao.y < 1.5f) 131 145 ao.x = (x2 + x3 + x4 + x5) * 0.25f; 132 146 … … 134 148 const static float scaleFactor = 1.0f; 135 149 //const static float scaleFactor = 10.0f; 136 const static float adaptFactor = 50 .0f;150 const static float adaptFactor = 50000.0f; 137 151 138 152 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); … … 140 154 //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, adaptFactor * scaleFactor * ao.z / (adaptFactor + ao.y), 0); 141 155 //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, adaptFactor * scaleFactor / (adaptFactor + ao.y), 0); 142 } 143 156 157 if (ao.y < 10.5f) ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1, 0); 158 //ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1, 0); 159 } 160 161 //float dummy = clamp(1.0f - ao.y * 1e-2f, 0, 1); 162 //float dummy2 = ao.y < 1.5f ? 1.0f : .0f; 144 163 OUT.illum_col.xyz = col.xyz * ao.x; 145 //OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w); 146 //OUT.illum_col.xyz = float3(1.0f - ao.x, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1); 164 165 // if (ao.y < 1.5f) OUT.illum_col.xyz = float3(10000, 10000, 0); 166 // else if (ao.y < 3.5f) OUT.illum_col.xyz = float3(10000, 0, 10000); 167 // else 168 // if (ao.y < 10.5f) OUT.illum_col.xyz = float3(0, 10000, 0); 169 //OUT.illum_col = float4(dummy3, dummy3, dummy3, col.w); 170 OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w); 171 172 //OUT.illum_col.xyz = float3(1.0f - ao.x, dummy2, 0);//dummy2); 173 //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1); 147 174 OUT.illum_col.w = col.w; 148 175 149 176 return OUT; 150 177 } 178 151 179 152 180 float DiscontinuityFilter2(float2 texCoord, … … 181 209 //depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f); 182 210 depthFactor = max(step(5e-1f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 183 normalFactor = max(step(0.6f, dot(sampleNorm, norm)), 1e-3f);211 //normalFactor = max(step(0.6f, dot(sampleNorm, norm)), 1e-3f); 184 212 185 213 //w = filterWeights[i] * normalFactor * depthFactor; 186 w = normalFactor * depthFactor; 214 //w = normalFactor * depthFactor; 215 w = depthFactor; 187 216 188 217 average += aoSample.y * w; … … 208 237 //const static float scaleFactor = 20.0f; 209 238 const static float scaleFactor = 10.0f; 210 ao.y = DiscontinuityFilter2(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor * ao.z, 1);239 //ao.y = DiscontinuityFilter2(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 0.5f, 1); 211 240 //ao.y = DiscontinuityFilter2(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor, 1); 212 241 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3132 r3133 143 143 { 144 144 // compute position from old frame for dynamic objects + translational portion 145 const float3 translatedPos = diffVec + worldPos.xyz - oldEyePos;145 const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz; 146 146 147 147
Note: See TracChangeset
for help on using the changeset viewer.