Changeset 3284 for GTP/trunk/App
- Timestamp:
- 01/18/09 02:25:26 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj
r3262 r3284 284 284 </File> 285 285 <File 286 RelativePath=".\src\VisibilitySolutionLoader.cpp" 287 > 288 </File> 289 <File 290 RelativePath=".\src\VisibilitySolutionLoader.h" 291 > 292 </File> 293 <File 286 294 RelativePath=".\src\WalkThroughRecorder.cpp" 287 295 > … … 579 587 </File> 580 588 <File 581 RelativePath=".\src\VisibilitySolutionLoader.h"582 >583 </File>584 <File585 589 RelativePath=".\src\Visualization.h" 586 590 > … … 683 687 </File> 684 688 <File 689 RelativePath=".\src\Pvs.cpp" 690 > 691 </File> 692 <File 685 693 RelativePath=".\src\RenderQueue.cpp" 686 694 > … … 778 786 <File 779 787 RelativePath=".\src\ViewCellsTree.cpp" 780 >781 </File>782 <File783 RelativePath=".\src\VisibilitySolutionLoader.cpp"784 788 > 785 789 </File> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3282 r3284 9 9 #filename=vienna_full_hp 10 10 #bvhname=vienna_full_hp 11 filename=tryvienna212 bvhname=tryvienna211 #filename=tryvienna2 12 #bvhname=tryvienna2 13 13 #filename=mypompeii 14 14 #bvhname=mypompeii 15 15 #filename=pompeii/pompeii_full 16 16 #filename=pompeii/pompeii_part 17 #filename=city18 #bvhname=city17 filename=city 18 bvhname=city 19 19 useLODs=1 20 20 # shadow map size … … 32 32 # if using pvs, this specifies the name of the visibility solutin 33 33 #visibilitySolution=vienna_full-8x3-pgv 34 #visibilitySolution=vienna_full-8x3-spgvu 35 #visibilitySolution=vienna_full-8x3-refu 34 36 #visibilitySolution=mypompeii-1x1-pgv 35 37 #visibilitySolution=mypompeii-2x1-obvh-pgv -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp
r3282 r3284 40 40 if (delData) 41 41 { 42 //DEL_ARRAY_PTR(mVertices);42 DEL_ARRAY_PTR(mVertices); 43 43 DEL_ARRAY_PTR(mNormals); 44 44 DEL_ARRAY_PTR(mTexCoords); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.cpp
r3283 r3284 7 7 { 8 8 9 bool Pvs::sStoreTimeStamps = false; 9 10 bool operator<(const PvsEntry &a, const PvsEntry &b) 11 { 12 //return a.mTimeStamp < b.mTimeStamp; 13 return true; 14 } 10 15 11 16 … … 22 27 23 28 29 void Pvs::Sort() 30 { 31 } 32 33 24 34 25 35 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h
r3283 r3284 11 11 class Bvh; 12 12 13 struct PvsEntry 14 { 15 PvsEntry(SceneEntity *ent, float t): 16 mEntity(ent) 17 //, mTimeStamp(t) 18 {} 19 20 friend bool operator<(const PvsEntry &a, const PvsEntry &b); 21 22 23 /////////////// 24 25 SceneEntity *mEntity; 26 //float mTimeStamp; 27 }; 28 29 30 31 32 typedef std::vector<PvsEntry> PvsEntryContainer; 33 13 34 14 35 /** Class representing the Potentially Visible Set (PVS) from a view cell. … … 16 37 class Pvs 17 38 { 18 19 39 public: 20 40 … … 22 42 23 43 bool Empty() const; 24 25 void AddEntry(Bvh *bvh, BvhNode *node); 44 /** Convencience method adding all scene entities associated with a bvh node. 45 */ 46 void AddEntry(Bvh *bvh, BvhNode *node, float timeStamp = -1); 26 47 27 48 int GetSize() const; 28 49 29 inline SceneEntity *GetEntry(int i) const; 50 inline SceneEntity *GetEntity(int i) const; 51 52 inline PvsEntry GetEntry(int i) const; 30 53 31 inline void AddEntry(SceneEntity *ent, float timeStamp = 0.0f); 54 inline void AddEntry(const PvsEntry &entry); 55 /* Sort entries by timestamp 56 */ 57 void Sort(); 32 58 33 59 … … 35 61 36 62 /// vector of PVS entries 37 SceneEntityContainer mEntries; 38 std::vector<float> mTimeStamps; 39 40 static bool sStoreTimeStamps; 63 PvsEntryContainer mEntries; 41 64 }; 42 65 43 66 44 inline SceneEntity *Pvs::GetEntry(int i) const 67 inline SceneEntity *Pvs::GetEntity(int i) const 68 { 69 return mEntries[i].mEntity; 70 } 71 72 73 inline PvsEntry Pvs::GetEntry(int i) const 45 74 { 46 75 return mEntries[i]; … … 48 77 49 78 50 inline void Pvs::AddEntry( SceneEntity *ent, float timeStamp)79 inline void Pvs::AddEntry(const PvsEntry &entry) 51 80 { 52 mEntries.push_back(ent); 53 54 if (sStoreTimeStamps) 55 { 56 mTimeStamps.push_back(timeStamp); 57 } 81 mEntries.push_back(entry); 58 82 } 59 83 … … 65 89 66 90 67 inline void Pvs::AddEntry(Bvh *bvh, BvhNode *node )91 inline void Pvs::AddEntry(Bvh *bvh, BvhNode *node, float timeStamp) 68 92 { 69 93 int geometrySize; … … 73 97 for (int i = 0; i < geometrySize; ++ i) 74 98 { 75 AddEntry( entities[i]);99 AddEntry(PvsEntry(entities[i], timeStamp)); 76 100 } 77 101 } 102 78 103 79 104 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/PvsCollectionRenderer.h
r3258 r3284 40 40 void SetViewCell(ViewCell *vc) { mViewCell = vc; } 41 41 42 virtual int GetType() const { return CULL_COLLECTOR; } 42 //virtual int GetType() const { return CULL_COLLECTOR; } 43 virtual int GetType() const { return -1; } 43 44 44 45 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h
r3258 r3284 54 54 STOP_AND_WAIT, 55 55 CHC, CHCPLUSPLUS, 56 CULL_COLLECTOR,56 //CULL_COLLECTOR, 57 57 NUM_TRAVERSAL_TYPES}; 58 58 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp
r3282 r3284 149 149 if (number != mViewCells.size()) 150 150 { 151 cerr << "Warning: Number of view cells (" << number << ", " << (int)mViewCells.size() << ") does not match when loading PVSs!" << endl; 151 cerr << "Warning: Number of view cells (" << number << ", " 152 << (int)mViewCells.size() << ") does not match when loading PVSs!" << endl; 152 153 return false; 153 154 } … … 176 177 177 178 outstream << n->GetFirstEntity() << " " << n->GetLastEntity() << " " << n->GetBox() << " " << box << endl; 178 179 } 180 } 181 182 outstream.close(); 183 184 179 } 180 } 181 185 182 for (int i = 0; i < number; ++ i) 186 183 { … … 196 193 197 194 BvhNode *node = nodes[objectId]; 198 mViewCells[i]->mPvs.AddEntry(bvh, node); 199 } 200 } 195 if (i == 100) 196 outstream << "t " << time << " "; 197 mViewCells[i]->mPvs.AddEntry(bvh, node, time); 198 } 199 } 200 201 outstream.close(); 201 202 202 203 return true; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3282 r3284 154 154 static int globalVisibleId = 0; 155 155 156 PerfTimer applicationTimer; 157 158 float shotRays = .0f; 156 159 157 160 … … 927 930 tr = new CHCPlusPlusTraverser(); 928 931 break; 929 case RenderTraverser::CULL_COLLECTOR:930 tr = new PvsCollectionRenderer();931 break;932 //case RenderTraverser::CULL_COLLECTOR: 933 // tr = new PvsCollectionRenderer(); 934 // break; 932 935 default: 933 936 tr = new FrustumCullingTraverser(); … … 1229 1232 if (1 && usePvs) 1230 1233 { 1231 if (!viewCellsTree) LoadVisibilitySolution(); 1234 if (!viewCellsTree) 1235 { 1236 applicationTimer.Start(); 1237 LoadVisibilitySolution(); 1238 } 1232 1239 1233 1240 if (viewCellsTree) LoadPvs(); … … 1313 1320 else 1314 1321 { 1315 if (traverser->GetType() == RenderTraverser::CULL_COLLECTOR) 1316 ((PvsCollectionRenderer *)traverser)->SetViewCell(usePvs ? viewCell : NULL); 1317 1318 //for (size_t i = 0; i < staticObjects.size(); ++ i) 1319 // staticObjects[i]->Render(&renderState); 1320 1322 //if (traverser->GetType() == RenderTraverser::CULL_COLLECTOR) 1323 // ((PvsCollectionRenderer *)traverser)->SetViewCell(usePvs ? viewCell : NULL); 1324 1321 1325 // actually render the scene geometry using the specified algorithm 1322 1326 traverser->RenderScene(); … … 2372 2376 , "CHC" 2373 2377 , "CHC ++" 2374 , "Collector"2378 // , "Collector" 2375 2379 }; 2376 2380 2381 #if 0 2377 2382 if (!showAlgorithmTime) 2378 2383 { … … 2388 2393 myfont.DrawString(msg[7], 1.3f, 690.0f, 760.0f);//, top_color, bottom_color); 2389 2394 } 2390 2391 2392 //sprintf(msg[8], "algorithm time: %6.1f ms", rTime); 2393 //myfont.DrawString(msg[8], 720.0f, 730.0f); 2395 #else 2396 int mrays = (int)shotRays / 1000000; 2397 sprintf(msg[7], "%s: %04d M rays", alg_str[renderMode], mrays); 2398 myfont.DrawString(msg[7], 1.3f, 690.0f, 760.0f);//, top_color, bottom_color); 2399 #endif 2394 2400 } 2395 2401 … … 2428 2434 RenderShadowMap(newFar); 2429 2435 } 2436 2430 2437 // initialize deferred rendering 2431 2438 InitDeferredRendering(); … … 2651 2658 viewCell = viewCellsTree->GetViewCell(camera->GetPosition()); 2652 2659 2653 int numTriangles = 0; 2660 // assume 60 FPS and 1M rays per second 2661 const float scale = 1e6f / 60.0f; 2662 2663 //const float elapsedAlgorithmTime = applicationTimer.Elapsedms(false); 2664 //int numTriangles = 0; 2654 2665 2655 2666 SceneEntity::SetCurrentVisibleId(globalVisibleId); … … 2657 2668 for (int i = 0; i < viewCell->mPvs.GetSize(); ++ i) 2658 2669 { 2659 SceneEntity *ent = viewCell->mPvs.GetEntry(i); 2660 ent->SetVisibleId(globalVisibleId); 2661 //ent->Render(&renderState); 2662 2663 numTriangles += ent->CountNumTriangles(); 2664 } 2665 2670 PvsEntry entry = viewCell->mPvs.GetEntry(i); 2671 2672 if (1)//(entry.mTimeStamp < 0.0f) || (entry.mTimeStamp <= shotRays)) 2673 { 2674 entry.mEntity->SetVisibleId(globalVisibleId); 2675 //numTriangles += entry.mEntity->CountNumTriangles(); 2676 } 2677 } 2678 2679 shotRays += scale; 2666 2680 ++ globalVisibleId; 2667 2681 } … … 2701 2715 void LoadPompeiiFloor() 2702 2716 { 2703 AxisAlignedBox3 pompeiiBox = SceneEntity::ComputeBoundingBox(staticObjects); 2717 AxisAlignedBox3 pompeiiBox = 2718 SceneEntity::ComputeBoundingBox(staticObjects); 2704 2719 2705 2720 // todo: dispose texture … … 2722 2737 depthPass->SetLightingEnabled(false); 2723 2738 2724 ShaderProgram *defaultFragmentTexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("defaultFragmentTexMrt"); 2725 ShaderProgram *defaultVertexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("defaultVertexMrt"); 2739 ShaderProgram *defaultFragmentTexProgramMrt = 2740 ShaderManager::GetSingleton()->GetShaderProgram("defaultFragmentTexMrt"); 2741 ShaderProgram *defaultVertexProgramMrt = 2742 ShaderManager::GetSingleton()->GetShaderProgram("defaultVertexMrt"); 2726 2743 2727 2744 deferred->SetFragmentProgram(defaultFragmentTexProgramMrt); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg
r3230 r3284 89 89 for (int i = 0; i < NUM_PCF_TABS; ++ i) 90 90 { 91 const float2 offset = samples[i];91 float2 offset; 92 92 const float w = weights[i]; 93 93 … … 96 96 //-- add random noise: reflect around random normal vector (warning: slow!) 97 97 98 float2 mynoise = tex2D(noiseTexture, IN.texCoord).xy; 99 const float2 offsetTransformed = myreflect(offset, mynoise); 98 float2 mynoise = tex2D(noiseTexture, IN.texCoord * 4.0f).xy; 99 //offset = myreflect(samples[i], mynoise); 100 offset = myrotate(samples[i], mynoise.x); 100 101 #else 101 const float2 offsetTransformed = offset;102 offset = samples[i]; 102 103 #endif 103 104 // weight with projected coordinate to reach similar kernel size for near and far 104 float2 texcoord = lightSpacePos + offset Transformed* scale;105 float2 texcoord = lightSpacePos + offset * scale; 105 106 106 107 float shadowDepth = tex2D(shadowMap, texcoord).x; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3271 r3284 249 249 { 250 250 float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 251 //offset Transformed = myreflect(offset, mynoise);251 //offset = myreflect(samples[i], mynoise); 252 252 offset = myrotate(samples[i], mynoise.x); 253 253 }
Note: See TracChangeset
for help on using the changeset viewer.