Changeset 3316 for GTP/trunk/App
- Timestamp:
- 02/17/09 19:21:52 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3313 r3316 91 91 /** Helper method that computes the view vectors in the corners of the current view frustum. 92 92 */ 93 static void ComputeViewVectors(PerspectiveCamera *cam, Vector3 &bl, Vector3 &br, Vector3 &tl, Vector3 &tr) 93 static void ComputeViewVectors(PerspectiveCamera *cam, 94 Vector3 &bl, 95 Vector3 &br, 96 Vector3 &tl, 97 Vector3 &tr) 94 98 { 95 99 Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; … … 304 308 mUseAntiAliasing(false), 305 309 mUseDepthOfField(false), 306 mSsaoUseFullResolution(ssaoUseFullResolution) 310 mSsaoUseFullResolution(ssaoUseFullResolution), 311 mMaxConvergence(2000.0f) 307 312 { 308 313 /////////// … … 460 465 461 466 string combineSsaoParams[] = 462 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res"};467 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 463 468 464 469 //sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13); 465 sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 7);470 sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 8); 466 471 467 472 … … 469 474 470 475 string filterSsaoParams[] = 471 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res" };472 473 sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 7);476 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 477 478 sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 8); 474 479 475 480 … … 980 985 981 986 sCgFilterSsaoProgram->SetValue2f(i ++, (float)mWidth, (float)mHeight); 987 sCgFilterSsaoProgram->SetValue1f(i ++, (float)mMaxConvergence); 982 988 983 989 DrawQuad(sCgFilterSsaoProgram); … … 1006 1012 1007 1013 sCgCombineSsaoProgram->SetValue2f(i ++, mWidth, mHeight); 1014 sCgCombineSsaoProgram->SetValue1f(i ++, (float)mMaxConvergence); 1008 1015 1009 1016 DrawQuad(sCgCombineSsaoProgram); … … 1506 1513 1507 1514 1515 void DeferredRenderer::SetMaxConvergence(float c) 1516 { 1517 mMaxConvergence = c; 1518 } 1519 1520 1508 1521 } // namespace -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h
r3305 r3316 95 95 void SetTemporalCoherenceFactorForSsao(float factor); 96 96 97 /** Sets the maxinal convergence factor for ssao filter 98 */ 99 void SetMaxConvergence(float c); 100 97 101 98 102 // hack: store the color buffer idx for the currently used flip flop-MRT here … … 222 226 223 227 bool mSsaoUseFullResolution; 228 229 float mMaxConvergence; 224 230 }; 225 231 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3315 r3316 286 286 float viewCellsScaleFactor = 1.0f; 287 287 288 float maxConvergence = 2000.0f; 289 290 288 291 289 292 ////////////// … … 377 380 inline float KeyShift() { return keyForwardMotion * elapsedTime * 1e-3f; } 378 381 379 void CreateAnimation( );382 void CreateAnimation(const Vector3 &pos); 380 383 381 384 SceneQuery *GetOrCreateSceneQuery(); … … 390 393 391 394 void LoadOrUpdatePVSs(const Vector3 &pos); 395 396 void CreateNewInstance(SceneEntity *parent, const Vector3 &pos); 397 398 399 ///////////// 392 400 393 401 string envFileName = "default.env"; … … 626 634 627 635 #if 1 628 const Vector3 sceneCenter(470.398f, 240.364f, 181.7f); 636 637 #if 0 638 VertexArray positions; 639 positions.push_back(Vector3(478.398f, 268.0f, 181.3)); 640 positions.push_back(Vector3(470.461, 268.543, 181.7)); 641 positions.push_back(Vector3(499.648, 264.358, 181.7)); 642 positions.push_back(Vector3(487.913, 285.162, 181.7)); 643 644 #else 645 646 VertexArray positions; 647 //positions.push_back(Vector3(6.07307, 8.20723, 6.7)); 648 positions.push_back(Vector3(6.07307, 8.20723, 6.62)); 649 positions.push_back(Vector3(-17.1935, 11.1687, 8.8781)); 650 //positions.push_back(Vector3(499.648, 264.358, 181.7)); 651 //positions.push_back(Vector3(487.913, 285.162, 181.7)); 652 653 #endif 654 629 655 //const Vector3 sceneCenter(470.398f, 240.364f, 180.3); 630 Matrix4x4 transl = TranslationMatrix( sceneCenter);656 Matrix4x4 transl = TranslationMatrix(positions[0]); 631 657 632 658 LoadModel("hbuddha.dem", dynamicObjects); … … 635 661 buddha->GetTransform()->SetMatrix(transl); 636 662 637 for (int i = 0; i < 10; ++ i) 638 { 639 SceneEntity *ent = new SceneEntity(*buddha); 640 resourceManager->AddSceneEntity(ent); 641 642 Vector3 offs = Vector3::ZERO(); 643 644 offs.x = RandomValue(.0f, 50.0f); 645 offs.y = RandomValue(.0f, 50.0f); 646 647 Vector3 newPos = sceneCenter + offs; 648 649 transl = TranslationMatrix(newPos); 650 Transform3 *transform = resourceManager->CreateTransform(transl); 651 652 ent->SetTransform(transform); 653 dynamicObjects.push_back(ent); 654 } 663 664 for (size_t i = 1; i < positions.size(); ++ i) 665 { 666 CreateNewInstance(buddha, positions[i]); 667 } 668 655 669 #endif 656 670 … … 706 720 preetham = new SkyPreetham(turbitity, skyDome); 707 721 708 CreateAnimation( );722 CreateAnimation(positions[0]); 709 723 710 724 … … 1151 1165 1152 1166 //const float rotAngle = M_PI * 1e-3f; 1153 const float rotAngle = 0.3f * M_PI / 180.0f;1154 //const float rotAngle = 1.0f * M_PI / 180.0f;1167 //const float rotAngle = 0.3f * M_PI / 180.0f; 1168 const float rotAngle = 0.6f * M_PI / 180.0f; 1155 1169 1156 1170 Matrix4x4 rotMatrix = RotationZMatrix(rotAngle); 1171 // hack: second buddha 1157 1172 dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 1158 1173 1159 const float moveSpeed = 5e-3f; 1174 //const float moveSpeed = 5e-3f; 1175 const float moveSpeed = 1e-1f; 1160 1176 motionPath->Move(moveSpeed); 1161 1177 } … … 1412 1428 deferredShader->SetUseToneMapping(useHDR); 1413 1429 deferredShader->SetUseAntiAliasing(useAntiAliasing); 1430 deferredShader->SetMaxConvergence(maxConvergence); 1414 1431 1415 1432 … … 1582 1599 traverser->SetUseOptimization(useOptimization); 1583 1600 break;*/ 1601 case 'o': 1602 case 'O': 1603 if (maxConvergence > 100.0f) 1604 maxConvergence = 1.0f; 1605 else 1606 maxConvergence = 5000.0f; 1607 1608 cout << "max convergence: " << maxConvergence << endl; 1609 1610 break; 1584 1611 case 'l': 1585 1612 case 'L': … … 2595 2622 2596 2623 2597 void CreateAnimation() 2598 { 2599 const float radius = 5.0f; 2600 //const Vector3 center(480.398f, 268.364f, 181.3); 2601 const Vector3 center(480.398f, 269.364f, 181.3); 2624 void CreateAnimation(const Vector3 &pos) 2625 { 2626 //const float b = 5.0f; const float a = 1.5f; 2627 const float a = 5.0f; const float b = 1.5f; 2602 2628 2603 2629 VertexArray vertices; 2604 2630 2605 /*for (int i = 0; i < 360; ++ i) 2606 { 2607 float angle = (float)i * M_PI / 180.0f; 2608 2609 Vector3 offs = Vector3(cos(angle) * radius, sin(angle) * radius, 0); 2631 for (int i = 0; i < 360; ++ i) 2632 { 2633 const float angle = (float)i * M_PI / 180.0f; 2634 2635 Vector3 offs = Vector3(cos(angle) * a, sin(angle) * b, 0); 2636 vertices.push_back(pos + offs); 2637 } 2638 2639 /*for (int i = 0; i < 5; ++ i) 2640 { 2641 Vector3 offs = Vector3(i, 0, 0); 2642 vertices.push_back(center + offs); 2643 } 2644 2645 for (int i = 0; i < 5; ++ i) 2646 { 2647 Vector3 offs = Vector3(4 - i, 0, 0); 2610 2648 vertices.push_back(center + offs); 2611 2649 }*/ 2612 2650 2613 for (int i = 0; i < 5; ++ i)2614 {2615 Vector3 offs = Vector3(i, 0, 0);2616 vertices.push_back(center + offs);2617 }2618 2619 2620 for (int i = 0; i < 5; ++ i)2621 {2622 Vector3 offs = Vector3(4 -i, 0, 0);2623 vertices.push_back(center + offs);2624 }2625 2626 2651 motionPath = new MotionPath(vertices); 2627 2652 } 2653 2628 2654 2629 2655 /** This function returns the number of visible pixels of a … … 2805 2831 if (viewCellsTree) UpdatePvs(pos); 2806 2832 } 2833 2834 2835 void CreateNewInstance(SceneEntity *parent, const Vector3 &pos) 2836 { 2837 SceneEntity *ent = new SceneEntity(*parent); 2838 resourceManager->AddSceneEntity(ent); 2839 2840 Matrix4x4 transl = TranslationMatrix(pos); 2841 Transform3 *transform = resourceManager->CreateTransform(transl); 2842 2843 ent->SetTransform(transform); 2844 dynamicObjects.push_back(ent); 2845 //Debug << "positions: " << newPos << endl; 2846 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg
r3314 r3316 58 58 float3 br, 59 59 float3 tl, 60 float3 tr) 60 float3 tr, 61 float maxConvergence) 61 62 { 62 63 float2 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); … … 72 73 float spatialFactor = 1.0f / max(len, 1e-3f); 73 74 74 float convergenceFactor = aoSample.y + 1.0f; 75 float convergenceFactor = min(aoSample.y + 1.0f, maxConvergence); 76 convergenceFactor *= convergenceFactor; 75 77 76 78 // combine the weights 77 //float w = convergenceFactor * convergenceFactor * spatialFactor;78 79 float w = convergenceFactor * spatialFactor; 79 80 //float w = spatialFactor; … … 96 97 float3 tr, 97 98 float2 xyStep, 98 float convergence) 99 float convergence, 100 float maxConvergence 101 ) 99 102 { 100 103 float2 result = float2(0.0f, 0.0f); … … 109 112 { 110 113 float4 sampleTexCoord = float4(texCoord + i * xyStep * scale, .0f, .0f); 111 result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr );114 result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence); 112 115 } 113 116 … … 148 151 { 149 152 // the filtered ssao value 150 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence );153 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 151 154 } 152 155 … … 163 166 uniform float3 tl, 164 167 uniform float3 tr, 165 uniform float2 res 168 uniform float2 res, 169 uniform float maxConvergence 166 170 ) 167 171 { … … 183 187 { 184 188 // the filtered ssao value 185 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence );189 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 186 190 } 187 191 … … 200 204 uniform float3 tl, 201 205 uniform float3 tr, 202 uniform float2 res 206 uniform float2 res, 207 uniform float maxConvergence 203 208 ) 204 209 { … … 221 226 { 222 227 // the filtered ssao value 223 ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence );228 ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 224 229 } 225 230 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3314 r3316 48 48 weight of the pixel in the new frame. 49 49 */ 50 inline float2 temporalSmoothing(float4 worldPos,50 inline float2 Reproject(float4 worldPos, 51 51 float eyeSpaceDepth, 52 52 float2 texcoord0, … … 107 107 { 108 108 // pixel valid => retrieve the convergence weight 109 w = oldPixel.y; 109 float w1 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 110 float w2 = tex2Dlod(oldTex, float4(oldTexCoords - float2(0.5f / 1024.0f, 0), .0f, .0f)).y; 111 float w3 = tex2Dlod(oldTex, float4(oldTexCoords + float2(0, 0.5f / 768.0f), .0f, .0f)).y; 112 float w4 = tex2Dlod(oldTex, float4(oldTexCoords - float2(0, 0.5f / 768.0f), .0f, .0f)).y; 113 114 w = min(min(w1, w2), min(w3, w4)); 115 //w = oldPixel.y; 110 116 } 111 117 else … … 385 391 //-- compute temporal reprojection 386 392 387 float2 temporalVals = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos,388 389 390 391 392 393 394 393 float2 temporalVals = Reproject(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 394 oldTex, oldModelViewProj, 395 colors, 396 projPos.xyz, 397 invw, 398 oldbl, oldbr, oldtl, oldtr, 399 diffVec 400 ); 395 401 396 402 const float oldSsao = temporalVals.x;
Note: See TracChangeset
for help on using the changeset viewer.