- Timestamp:
- 02/18/09 18:34:49 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp
r3305 r3319 107 107 108 108 109 if ( !normals.empty())109 if (0)//!normals.empty()) 110 110 { 111 111 faceNormals.push_back(normals[nIndices[idx1]]); … … 358 358 str.write(reinterpret_cast<char *>(geom->mTexcoords), sizeof(float) * texCoordCount * 2); 359 359 360 360 /* 361 ////////////// 362 //-- hack: a default material 361 363 /////// 362 364 //-- texture 363 /* 365 364 366 #ifdef USE_TEXTURE 365 367 int texId = 0; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env
r3313 r3319 101 101 ssaoUseFullResolution=1 102 102 # ssao kernel radius 103 ssaoKernelRadius=2.5f 103 #ssaoKernelRadius=2.5f 104 ssaoKernelRadius=1.28f 104 105 # ssao sample intensity 105 106 #ssaoSampleIntensity=0.2f -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3316 r3319 309 309 mUseDepthOfField(false), 310 310 mSsaoUseFullResolution(ssaoUseFullResolution), 311 mMaxConvergence(2000.0f) 311 mMaxConvergence(2000.0f), 312 mSpatialWeight(.0f) 312 313 { 313 314 /////////// … … 465 466 466 467 string combineSsaoParams[] = 467 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 468 //{"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 469 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence", "spatialWeight"}; 468 470 469 471 //sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13); 470 sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 8);472 sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 9); 471 473 472 474 … … 474 476 475 477 string filterSsaoParams[] = 476 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence" };477 478 sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 8);478 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence", "spatialWeight"}; 479 480 sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 9); 479 481 480 482 … … 985 987 986 988 sCgFilterSsaoProgram->SetValue2f(i ++, (float)mWidth, (float)mHeight); 987 sCgFilterSsaoProgram->SetValue1f(i ++, (float)mMaxConvergence); 989 sCgFilterSsaoProgram->SetValue1f(i ++, mMaxConvergence); 990 sCgFilterSsaoProgram->SetValue1f(i ++, mSpatialWeight); 988 991 989 992 DrawQuad(sCgFilterSsaoProgram); … … 1012 1015 1013 1016 sCgCombineSsaoProgram->SetValue2f(i ++, mWidth, mHeight); 1014 sCgCombineSsaoProgram->SetValue1f(i ++, (float)mMaxConvergence); 1017 sCgCombineSsaoProgram->SetValue1f(i ++, mMaxConvergence); 1018 sCgCombineSsaoProgram->SetValue1f(i ++, mSpatialWeight); 1015 1019 1016 1020 DrawQuad(sCgCombineSsaoProgram); … … 1519 1523 1520 1524 1525 void DeferredRenderer::SetSpatialWeight(float w) 1526 { 1527 mSpatialWeight = w; 1528 } 1529 1530 1521 1531 } // namespace -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r3316 r3319 99 99 void SetMaxConvergence(float c); 100 100 101 void SetSpatialWeight(float w); 101 102 102 103 // hack: store the color buffer idx for the currently used flip flop-MRT here … … 228 229 229 230 float mMaxConvergence; 231 float mSpatialWeight; 230 232 }; 231 233 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3318 r3319 287 287 288 288 float maxConvergence = 2000.0f; 289 289 float spatialWeight = 0.0001f; 290 290 291 291 … … 635 635 #if 1 636 636 637 #if 1637 #if 0 638 638 // vienna positions 639 639 VertexArray positions; … … 1431 1431 deferredShader->SetUseAntiAliasing(useAntiAliasing); 1432 1432 deferredShader->SetMaxConvergence(maxConvergence); 1433 deferredShader->SetSpatialWeight(spatialWeight); 1433 1434 1434 1435 … … 1602 1603 break;*/ 1603 1604 case 'o': 1605 spatialWeight /= 2.0f; 1606 cout << "spatialWeight: " << spatialWeight << endl; 1607 break; 1608 case 'O': 1609 spatialWeight *= 2.0f; 1610 cout << "spatialWeight: " << spatialWeight << endl; 1611 break; 1612 /*case 'o': 1604 1613 case 'O': 1605 1614 if (maxConvergence > 100.0f) … … 1609 1618 1610 1619 cout << "max convergence: " << maxConvergence << endl; 1611 1620 */ 1612 1621 break; 1613 1622 case 'l': -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3318 r3319 8 8 //#define NUM_SAMPLES 8 9 9 //#define NUM_SAMPLES 16 10 #define NUM_SAMPLES 2411 //#define NUM_SAMPLES 4810 //#define NUM_SAMPLES 24 11 #define NUM_SAMPLES 48 12 12 13 13 //#define MIN_SAMPLES 48 … … 61 61 #define NUM_DOF_TABS 16 62 62 63 //#define USE_GTX63 #define USE_GTX 64 64 65 65 #define SSAO_FILTER_RADIUS 5 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg
r3318 r3319 59 59 float3 tl, 60 60 float3 tr, 61 float maxConvergence) 61 float maxConvergence, 62 float spatialWeight) 62 63 { 63 64 float2 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); … … 71 72 //float len = min(SqrLen(centerPos - samplePos), 1e2f); 72 73 float len = distance(centerPos, samplePos); 73 float spatialFactor = 1.0f / max(len, 1e-3f); 74 //float spatialFactor = 1.0f / max(len, 1e-3f); 75 float spatialFactor = 1.0f / max(spatialWeight + len, 1e-3f); 74 76 75 77 float convergenceFactor = min(aoSample.y + 1.0f, maxConvergence); 76 convergenceFactor *= convergenceFactor;78 //convergenceFactor *= convergenceFactor; 77 79 78 80 // combine the weights 81 //float w = convergenceFactor * exp(1.0f + spatialFactor); 79 82 float w = convergenceFactor * spatialFactor; 80 83 //float w = spatialFactor; … … 98 101 float2 xyStep, 99 102 float convergence, 100 float maxConvergence 103 float maxConvergence, 104 float spatialWeight 101 105 ) 102 106 { … … 105 109 const float3 centerPos = ReconstructSamplePos(colorsTex, texCoord, bl, br, tl, tr); 106 110 107 const float scale = saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD);111 const float scale = 1.0f;//saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 108 112 //const int radius = SSAO_FILTER_RADIUS * saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 109 113 … … 112 116 { 113 117 float4 sampleTexCoord = float4(texCoord + i * xyStep * scale, .0f, .0f); 114 result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence );118 result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence, spatialWeight); 115 119 } 116 120 … … 151 155 { 152 156 // the filtered ssao value 153 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence );157 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 154 158 } 155 159 … … 167 171 uniform float3 tr, 168 172 uniform float2 res, 169 uniform float maxConvergence 173 uniform float maxConvergence, 174 uniform float spatialWeight 170 175 ) 171 176 { … … 187 192 { 188 193 // the filtered ssao value 189 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence );194 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 190 195 } 191 196 … … 205 210 uniform float3 tr, 206 211 uniform float2 res, 207 uniform float maxConvergence 212 uniform float maxConvergence, 213 uniform float spatialWeight 208 214 ) 209 215 { … … 226 232 { 227 233 // the filtered ssao value 228 ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 229 } 234 ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 235 } 236 237 //const float minAO = 2e-2f; 238 const float minAO = 1e-3f; 230 239 231 240 // just apply ssao if we are not in the sky 232 241 if (depth < DEPTH_THRESHOLD) 233 242 { 234 //OUT.illum_col.xyz = col.xyz * max(1e-3f, 1.0f - ao.x);235 OUT.illum_col.xyz = max(1e-3f, 1.0f - ao.x);243 OUT.illum_col.xyz = col.xyz * max(minAO, 1.0f - ao.x); 244 //OUT.illum_col.xyz = max(minAO, 1.0f - ao.x); 236 245 } 237 246 else -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3318 r3319 50 50 51 51 float4 texelCenterConv; 52 const float2 offs(1.0f / res.x, 1.0f / res.y);52 const float2 invRes = float2(1.0f / res.x, 1.0f / res.y); 53 53 54 54 // get position exactly between texel centers 55 float2 center = (floor(texCoord * res) + float2(.5f)) * offs;55 float2 center = (floor(texCoord * res) + float2(.5f)) * texelCenterConv; 56 56 //center.x = (floor(texCoord.x * res.x - .5f) + 1.0f) / res.x; 57 57 //center.y = (floor(texCoord.y * res.y - .5f) + 1.0f) / res.y; … … 68 68 const float convergence = min(m1, m2);*/ 69 69 70 const float convergence = tex2Dlod(tex, float4(center, 0, 0)).y; 70 //const float convergence = tex2Dlod(tex, float4(center, 0, 0)).y; 71 const float convergence = tex2Dlod(tex, float4(texCoord, 0, 0)).y; 71 72 72 73 return convergence; … … 143 144 w = min(min(w1, w2), min(w3, w4));*/ 144 145 145 w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f));146 //w = oldPixel.y;146 //w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f)); 147 w = oldPixel.y; 147 148 } 148 149 else … … 306 307 float3 dirSample = samplePos - centerPosition; 307 308 308 //const float sqrLen = max(SqrLen(dirSample), 1e-2f); 309 //const float minDist = 9e-1f; 310 const float minDist = 1e-2f; 311 312 //const float sqrLen = max(SqrLen(dirSample), minDist); 309 313 //const float lengthToSample = sqrt(sqrLen); 310 const float lengthToSample = max(length(dirSample), 1e-2f);314 const float lengthToSample = max(length(dirSample), minDist); 311 315 312 316 dirSample /= lengthToSample; // normalize … … 326 330 // only mark sample as invalid if in the last / current frame 327 331 // they possibly have any influence on the ao 332 328 333 const float changeFactor = sampleColor.y; 329 334 const float pixelValid = sampleColor.x; 330 335 336 // hack: 331 337 // we check if the sample could have been near enough to the current pixel 338 // or if the angle is small enough 332 339 // to have any influence in the current or last frame 333 #if 0340 #if 1 334 341 const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 335 validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid * step(-0.1f, cosAngle)); 342 if (pixelValid < 2.0f) 343 validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-0.1f, cosAngle)); 344 else 345 validSamples = max(validSamples, pixelValid); 336 346 #else 337 347 validSamples = max(validSamples, pixelValid); … … 345 355 //break; 346 356 // if the pixel belongs to a static object and all the samples stay valid in the current frame 347 if (!isMovingObject && (validSamples < 1.0f) ) break;357 if (!isMovingObject && (validSamples < 1.0f) && (convergence > NUM_SAMPLES)) break; 348 358 // if the pixel belongs to a dynamic object but the #accumulated samples for this pixel is sufficiently high 349 359 // (=> there was no discontinuity recently) 350 else if (isMovingObject && (convergence > NUM_SAMPLES * 5)) break; 360 //else if (isMovingObject && (convergence > SSAO_CONVERGENCE_THRESHOLD)) break; 361 //else if (isMovingObject && (convergence > NUM_SAMPLES * 5)) break; 351 362 } 352 363 #endif
Note: See TracChangeset
for help on using the changeset viewer.