Changeset 3123 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 11/12/08 17:56:47 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3119 r3123 12 12 # triangles per bvh leaf (influences hierarchy depth vs. occlusion power) 13 13 trianglesPerVirtualLeaf=300 14 15 maxDepthForTestingChildren=3 14 16 15 17 ################ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp
r3075 r3123 158 158 159 159 if (!numEntities) 160 { 161 // no box=> just initialize 160 { // no box=> just initialize 162 161 box.Initialize(); 163 162 } … … 202 201 mGeometry[mStaticGeometrySize + i] = dynamicEntities[i]; 203 202 } 203 } 204 205 206 Bvh::Bvh(const SceneEntityContainer &staticEntities, 207 const SceneEntityContainer &dynamicEntities, 208 int maxDepthForTestingChildren) 209 { 210 Init(); 211 212 mGeometrySize = staticEntities.size() + dynamicEntities.size(); 213 mGeometry = new SceneEntity*[mGeometrySize]; 214 215 mStaticGeometrySize = staticEntities.size(); 216 mDynamicGeometrySize = dynamicEntities.size(); 217 218 for (size_t i = 0; i < mStaticGeometrySize; ++ i) 219 { 220 mGeometry[i] = staticEntities[i]; 221 } 222 223 for (size_t i = 0; i < mDynamicGeometrySize; ++ i) 224 { 225 mGeometry[mStaticGeometrySize + i] = dynamicEntities[i]; 226 } 227 228 mMaxDepthForTestingChildren = maxDepthForTestingChildren; 204 229 } 205 230 … … 232 257 // nodes are tested using the subnodes from 3 levels below 233 258 mMaxDepthForTestingChildren = 3; 259 mMaxDepthForTestingChildren = 0; 234 260 //mMaxDepthForTestingChildren = 4; 235 261 … … 567 593 return numNodes; 568 594 } 595 596 #if TODO 597 void Bvh::RenderBoundsImmediate(const BvhNodeContainer &nodes, RenderState *state) 598 { 599 ///////// 600 //-- Render the tight bounds in immediate mode 601 BvhNodeContainer::const_iterator nit, nit_end = nodes.end(); 602 603 for (nit = nodes.begin(); nit != nit_end; ++ nit) 604 { 605 BvhNode *node = *nit; 606 607 for (int size_t i = 0; i < node->mNumTestNodes; ++ i) 608 { 609 BvhNode *testNode = node->mTestNodesIdx 610 RenderBoundingBoxImmediate((*nit)->GetBox()); 611 } 612 } 613 } 614 #endif 569 615 570 616 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h
r3102 r3123 665 665 const Bvh(const SceneEntityContainer &staticEntities, 666 666 const SceneEntityContainer &dynamicEntities); 667 /** Protected constructor taking scene geometry into account 668 Sets the static and dynamic objects for the hierarchy. 669 */ 670 const Bvh(const SceneEntityContainer &staticEntities, 671 const SceneEntityContainer &dynamicEntities, 672 int maxDepthForTestingChildren); 667 673 /** Called by the constructor. Initializes important members. 668 674 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp
r3074 r3123 64 64 Bvh *BvhLoader::Load(const string &filename, 65 65 const SceneEntityContainer &staticEntities, 66 const SceneEntityContainer &dynamicEntities) 66 const SceneEntityContainer &dynamicEntities, 67 int maxDepthForTestingChildren) 67 68 { 68 69 queue<BvhNode *> tQueue; … … 73 74 cout << "loading bvh" << endl; 74 75 75 Bvh *bvh = new Bvh(staticEntities, dynamicEntities );76 Bvh *bvh = new Bvh(staticEntities, dynamicEntities, maxDepthForTestingChildren); 76 77 77 78 BvhNode *root = LoadNextNode(stream, NULL); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.h
r3072 r3123 23 23 Bvh *Load(const std::string &filename, 24 24 const SceneEntityContainer &staticEntities, 25 const SceneEntityContainer &dynamicEntities); 25 const SceneEntityContainer &dynamicEntities, 26 int maxDepthForTestingChildren); 26 27 27 28 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3122 r3123 409 409 410 410 ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 411 //ssaoFilterWeights[i] = 1.0f; 411 412 412 413 ssaoFilterOffsets[2 * i + 0] *= xoffs; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
r3077 r3123 137 137 138 138 if (!scaleToRange) 139 { 139 { 140 140 // use tone mapping 141 141 vtxParams->SetValue1f(8, 1.0f); … … 143 143 else 144 144 { 145 // no tone mapping => scale to range 145 // no tone mapping => scale to range 146 146 vtxParams->SetValue1f(8, 8e-5f); 147 147 } … … 275 275 // diffuse color: sun color 276 276 pair<float, float> sun_theta; 277 277 278 Vector3 zenithColor; 278 279 vector<Vector3> ABCDE; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3120 r3123 107 107 MotionPath *motionPath = NULL; 108 108 109 int maxDepthForTestingChildren = 3; 110 109 111 110 112 /// the technique used for rendering … … 358 360 env.GetIntParam(string("maxBatchSize"), maxBatchSize); 359 361 env.GetIntParam(string("trianglesPerVirtualLeaf"), trianglesPerVirtualLeaf); 362 env.GetIntParam(string("winWidth"), winWidth); 363 env.GetIntParam(string("winHeight"), winHeight); 364 env.GetIntParam(string("shadowSize"), shadowSize); 365 env.GetIntParam(string("maxDepthForTestingChildren"), maxDepthForTestingChildren); 360 366 361 367 env.GetFloatParam(string("keyForwardMotion"), keyForwardMotion); 362 368 env.GetFloatParam(string("keyRotation"), keyRotation); 363 364 env.GetIntParam(string("winWidth"), winWidth);365 env.GetIntParam(string("winHeight"), winHeight);366 369 env.GetFloatParam(string("tempCohFactor"), ssaoTempCohFactor); 370 371 372 367 373 env.GetVectorParam(string("camPosition"), camPos); 368 374 env.GetVectorParam(string("camDirection"), camDir); 369 375 env.GetVectorParam(string("lightDirection"), lightDir); 370 env.GetIntParam(string("shadowSize"), shadowSize);371 376 372 377 env.GetBoolParam(string("useFullScreen"), useFullScreen); … … 467 472 468 473 //LoadModel("fisch.dem", dynamicObjects); 469 LoadModel("hbuddha.dem", dynamicObjects);474 /*LoadModel("hbuddha.dem", dynamicObjects); 470 475 buddha = dynamicObjects.back(); 471 476 … … 492 497 ent->SetTransform(transform); 493 498 dynamicObjects.push_back(ent); 494 } 499 }*/ 495 500 496 501 … … 501 506 502 507 BvhLoader bvhLoader; 503 bvh = bvhLoader.Load(bvh_filename, sceneEntities, dynamicObjects );508 bvh = bvhLoader.Load(bvh_filename, sceneEntities, dynamicObjects, maxDepthForTestingChildren); 504 509 505 510 if (!bvh) … … 908 913 void MainLoop() 909 914 { 915 #if 0 910 916 GPUProgramParameters *vtxParams = 911 917 buddha->GetShape(0)->GetMaterial()->GetTechnique(1)->GetVertexProgramParameters(); … … 931 937 Matrix4x4 rotMatrix = RotationZMatrix(M_PI * 1e-3f); 932 938 dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 933 939 #endif 934 940 935 941 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h
r3122 r3123 12 12 //#define SAMPLE_INTENSITY 0.1f 13 13 //#define SAMPLE_INTENSITY 0.07f 14 #define SAMPLE_INTENSITY 0.0 3f14 #define SAMPLE_INTENSITY 0.015f 15 15 16 16 #define SAMPLE_RADIUS 8e-1f … … 58 58 #define NUM_DOWNSAMPLES 9 59 59 60 #define NUM_SSAO_FILTERSAMPLES 2060 #define NUM_SSAO_FILTERSAMPLES 50 61 61 //#define NUM_SSAO_FILTERSAMPLES 40 62 62 //#define NUM_SSAO_FILTERSAMPLES 100 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg
r3122 r3123 57 57 58 58 59 float BilateralFilter(float2 texCoord,60 float4 ao,61 uniform sampler2D ssaoTex,62 uniform sampler2D normalsTex,63 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES],64 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES],65 float scale)59 float DiscontinuityFilter(float2 texCoord, 60 float4 ao, 61 uniform sampler2D ssaoTex, 62 uniform sampler2D normalsTex, 63 uniform float2 filterOffs[NUM_SSAO_FILTERSAMPLES], 64 uniform float filterWeights[NUM_SSAO_FILTERSAMPLES], 65 float scale) 66 66 { 67 67 float average = .0f; … … 76 76 float4 offs; 77 77 float depthFactor; 78 float normalFactor; 78 79 79 80 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) … … 83 84 84 85 sampleNorm = normalize(tex2Dlod(normalsTex, offs).xyz); 85 depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f);86 //sampleNorm = tex2Dlod(normalsTex, offs).xyz;87 86 88 w = filterWeights[i] * max(dot(sampleNorm, norm), 1e-3f) * depthFactor; 87 //depthFactor = clamp(1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w), 1e-3f, 1.0f); 88 89 depthFactor = max(step(5e-2f, 1.0f - abs(1.0f - eyeSpaceDepth / aoSample.w)), 1e-3f); 90 normalFactor = max(step(0.5f, dot(sampleNorm, norm)), 1e-3f); 91 92 w = filterWeights[i] * normalFactor * depthFactor; 93 //w = filterWeights[i] * depthFactor; 89 94 90 95 average += aoSample.x * w; … … 111 116 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 112 117 113 if ((ao.y < 60.0f) && (col.w < 1e10f)) 118 //if ((ao.y < 60.0f) && (col.w < 1e10f)) 119 if (col.w < 1e10f) 114 120 { 115 const static float scaleFactor = 20.0f; 121 //const static float scaleFactor = 10.0f; 122 const static float scaleFactor = 50.0f; 116 123 117 124 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); 118 125 //ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y)); 119 ao.x = BilateralFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y));126 ao.x = DiscontinuityFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, scaleFactor / (scaleFactor + ao.y)); 120 127 //ao.x = BilateralFilter(IN.texCoord, ao, ssaoTex, normalsTex, filterOffs, filterWeights, 1.0f); 121 128 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3122 r3123 6 6 7 7 #define USE_EYESPACE_DEPTH 1 8 //#extension GL_EXT_gpu_shader4 : enable9 10 8 11 9 … … 110 108 const float projectedEyeSpaceDepth = invlen * length(translatedPos); 111 109 112 float depthDif = (abs(eyeSpaceDepth - sampleEyeSpaceDepth) > 3.0f) ?110 float depthDif = (abs(eyeSpaceDepth - sampleEyeSpaceDepth) > 1.0f) ? 113 111 0 : abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 114 112 … … 183 181 184 182 float notValid = 0.5f; 185 //float overallDepth = 0; 183 float overallDepth = 0; 184 186 185 const float squaredLen = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z; 187 186 … … 209 208 #endif 210 209 211 //const float clampedOldWeight = clamp(oldPixel.y, .0f, temporalCoherence);212 const float oldWeight = oldPixel.y;210 const float oldWeight = clamp(oldPixel.y, .0f, temporalCoherence); 211 //const float oldWeight = oldPixel.y; 213 212 214 213 float newWeight; … … 225 224 // increase the weight for convergence 226 225 newWeight = oldWeight + 1.0f; 227 //if (notValid > 1.0f) newWeight = 2.0f; 226 //if (notValid > 1.0f) newWeight = 10.0f; 227 //if (notValid > 1.0f) newWeight = max(15.0f - notValid * 2.0f, 1.0f); 228 228 } 229 229 else … … 234 234 //if (oldPixel.y >= 2000) 235 235 // newWeight = min(temporalCoherence + 1, max(oldPixel.y - 70, 50)); 236 if (newWeight >= 2000) newWeight = 1000;236 //if (newWeight >= 2000) newWeight = 1000; 237 237 238 238 return float3(oldPixel.x, newWeight, eyeSpaceDepth); … … 397 397 } 398 398 399 const float clampedWeight = clamp(newWeight, 1, temporalCoherence); 400 401 OUT.illum_col.x = (ao.x + oldSsao * (clampedWeight - 1.0f)) / clampedWeight; 399 OUT.illum_col.x = (ao.x + oldSsao * (newWeight - 1.0f)) / newWeight; 402 400 OUT.illum_col.y = newWeight; 403 401 OUT.illum_col.z = invw;
Note: See TracChangeset
for help on using the changeset viewer.