- Timestamp:
- 10/21/08 16:04:27 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.cpp
r3050 r3054 34 34 // if lighting is used 35 35 mLightingEnabled = true; 36 /// if depth write should be enabled 37 mDepthWriteEnabled = true; 36 38 37 m DepthWriteEnabled = true;39 mRenderQueueBucket = NULL; 38 40 } 39 41 … … 58 60 } 59 61 60 62 /* 61 63 Technique::Technique(const Technique &tech) 62 64 { … … 80 82 mLightingEnabled = tech.mLightingEnabled; 81 83 mDepthWriteEnabled = tech.mDepthWriteEnabled; 82 } 84 }*/ 83 85 84 86 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Material.h
r3050 r3054 14 14 class GPUProgramParameters; 15 15 class ShaderProgram; 16 struct RenderQueueBucket; 16 17 17 18 … … 48 49 { 49 50 friend class ResourceManager; 51 friend class RenderQueue; 50 52 51 53 public: … … 55 57 Technique(); 56 58 57 Technique(const Technique &tech);59 //Technique(const Technique &tech); 58 60 /** Sets ambient and diffuse color to color 59 61 */ … … 134 136 /// if depth write is enabled 135 137 bool mDepthWriteEnabled; 138 /// pointer to the renderqueue bucket this entity belongs to 139 RenderQueueBucket *mRenderQueueBucket; 136 140 }; 137 141 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r3053 r3054 6 6 #include "Camera.h" 7 7 #include "Shape.h" 8 8 #include "RenderState.h" 9 9 10 10 using namespace std; … … 51 51 bool RenderQueue::FitsInBucket(Shape *shape, size_t idx) const 52 52 { 53 Technique *tech = shape->GetMaterial()->Get DefaultTechnique();53 Technique *tech = shape->GetMaterial()->GetTechnique(mState->GetRenderTechnique()); 54 54 55 55 // test if entity belongs to this bucket 56 // note: rather slows down the application for some reason!! 57 if (tech->IsAlphaTestEnabled() != mBuckets[idx]->mAlphaTestEnabled) { cout << "a"; return false; } 58 if (tech->IsCullFaceEnabled() != mBuckets[idx]->mCullFaceEnabled) { cout << "b"; return false; } 59 if (tech->IsColorWriteEnabled() != mBuckets[idx]->mColorWriteEnabled) { cout << "c"; return false; } 60 if (tech->IsLightingEnabled() != mBuckets[idx]->mLightingEnabled) { cout << "d"; return false; } 61 if (tech->IsDepthWriteEnabled() != mBuckets[idx]->mDepthWriteEnabled) { cout << "e"; return false; } 56 if (tech->IsAlphaTestEnabled() != mBuckets[idx]->mAlphaTestEnabled) { return false; } 57 if (tech->IsCullFaceEnabled() != mBuckets[idx]->mCullFaceEnabled) { return false; } 58 if (tech->IsColorWriteEnabled() != mBuckets[idx]->mColorWriteEnabled) { return false; } 59 if (tech->IsLightingEnabled() != mBuckets[idx]->mLightingEnabled) { return false; } 60 if (tech->IsDepthWriteEnabled() != mBuckets[idx]->mDepthWriteEnabled) { return false; } 61 62 //if (tech->IsColorWriteEnabled()) cout << "x"; 62 63 63 64 const bool hasTexture = (tech->GetTexture() != NULL); 64 65 65 if (hasTexture != mBuckets[idx]->mHasTexture) { cout << "f";return false; }66 if (hasTexture != mBuckets[idx]->mHasTexture) { return false; } 66 67 67 68 if (hasTexture) 68 69 { 69 if (tech->GetTexture()->GetWidth() != mBuckets[idx]->mTexWidth) { cout << "g"; return false; } 70 if (tech->GetTexture()->GetHeight() != mBuckets[idx]->mTexHeight) { cout << "h"; return false; } 71 if (tech->GetTexture()->GetFormat() != mBuckets[idx]->mTexFormat) { cout << "i"; return false; } 72 } 73 74 if (!tech->GetFragmentProgram() && mBuckets[idx]->mHasFragmentProgram) { cout << "j"; return false; } 75 if (!tech->GetVertexProgram() && mBuckets[idx]->mHasVertexProgram) { cout << "h"; return false; } 76 70 if (tech->GetTexture()->GetWidth() != mBuckets[idx]->mTexWidth) { return false; } 71 if (tech->GetTexture()->GetHeight() != mBuckets[idx]->mTexHeight) {return false; } 72 if (tech->GetTexture()->GetFormat() != mBuckets[idx]->mTexFormat) { return false; } 73 } 74 75 //if (!tech->GetFragmentProgram() && mBuckets[idx]->mHasFragmentProgram) { return false; } 76 //if (!tech->GetVertexProgram() && mBuckets[idx]->mHasVertexProgram) { return false; } 77 if (tech->GetFragmentProgram() != mBuckets[idx]->mFragmentProgram) { return false; } 78 if (tech->GetVertexProgram() != mBuckets[idx]->mVertexProgram) { return false; } 77 79 78 80 return true; … … 95 97 void RenderQueue::Enqueue(Shape *shape) 96 98 { 97 RenderQueueBucket *bucket; 99 Technique *tech = shape->GetMaterial()->GetTechnique(mState->GetRenderTechnique()); 100 RenderQueueBucket *bucket = tech->mRenderQueueBucket; 101 98 102 ++ mNumEntries; 99 103 100 if (shape->mRenderQueueBucket) 101 { 102 bucket = shape->mRenderQueueBucket; 103 } 104 else 104 if (!bucket) 105 105 { 106 106 bool bucketFound = false; … … 119 119 RenderQueueBucket *bucket = new RenderQueueBucket(); 120 120 bucket->mMinDistance = -1; 121 122 Technique *tech = shape->GetMaterial()->GetDefaultTechnique();123 121 124 122 bucket->mAlphaTestEnabled = tech->IsAlphaTestEnabled(); … … 150 148 } 151 149 152 bucket->mHasVertexProgram = tech->GetVertexProgram() != NULL; 153 bucket->mHasFragmentProgram = tech->GetFragmentProgram() != NULL; 150 // bucket->mHasVertexProgram = (tech->GetVertexProgram() != NULL); 151 // bucket->mHasFragmentProgram = (tech->GetFragmentProgram() != NULL); 152 bucket->mVertexProgram = tech->GetVertexProgram(); 153 bucket->mFragmentProgram = tech->GetFragmentProgram(); 154 154 155 155 mBuckets.push_back(bucket); 156 157 cout << "num buckets: " << (int)mBuckets.size() << endl; 156 //cout << "increased #buckets to " << (int)mBuckets.size() << endl; 158 157 } 159 158 160 159 bucket = mBuckets[i]; 161 shape->mRenderQueueBucket = bucket;160 tech->mRenderQueueBucket = bucket; 162 161 } 163 162 … … 226 225 Shape *shape = *sit; 227 226 228 Technique *tech = shape->GetMaterial()->Get DefaultTechnique();227 Technique *tech = shape->GetMaterial()->GetTechnique(mState->GetRenderTechnique()); 229 228 int tsize = tech->GetTexture() ? tech->GetTexture()->GetByteSize() : 0; 230 229 … … 239 238 void RenderQueue::Sort() 240 239 { 241 // sort buckets itself 240 // sort buckets itself by distance 242 241 sort(mBuckets.begin(), mBuckets.end(), CompDist); 243 242 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
r3051 r3054 33 33 bool mCullFaceEnabled; 34 34 35 bool mHasVertexProgram; 36 bool mHasFragmentProgram; 35 //bool mHasVertexProgram; 36 //bool mHasFragmentProgram; 37 ShaderProgram *mVertexProgram; 38 ShaderProgram *mFragmentProgram; 37 39 38 40 /// minimal distance to the camera … … 65 67 */ 66 68 void Enqueue(SceneEntity *entity); 69 /** Enqueues a single shape. 70 */ 71 void Enqueue(Shape *shape); 67 72 /** Sets the current render state 68 73 */ … … 77 82 */ 78 83 void Apply(); 79 84 /** Clears the render queue 85 */ 86 void Clear(); 80 87 81 88 protected: … … 83 90 void Sort(); 84 91 85 void Enqueue(Shape *shape);86 87 92 inline bool FitsInBucket(Shape *shape, size_t idx) const; 88 /** Clears the render queue89 */90 void Clear();91 93 /** Renders the contents of the render queue. 92 94 */ … … 104 106 //SceneEntityContainer mEntities; 105 107 int mMinSizeForSorting; 106 107 108 /// each bucket contains objects with similar materials that don't cause a hard state change 108 109 std::vector<RenderQueueBucket *> mBuckets; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h
r3052 r3054 51 51 void DisableFragmentProfile(); 52 52 void DisableVertexProfile(); 53 /** Returns pointer to shape container. 54 */ 55 const ShapeContainer * const GetShapes() const { return &mShapes; } 56 /** Returns pointer to scene entity container. 57 */ 58 const SceneEntityContainer * const GetSceneEntities() const { return &mSceneEntities; } 53 59 54 60 /** Returns the resource manager as a singleton. … … 97 103 ShapeContainer mShapes; 98 104 LODContainer mLODs; 99 100 105 /// the scene entities 101 106 SceneEntityContainer mSceneEntities; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp
r2957 r3054 13 13 mGeometry(geometry), 14 14 mMaterial(mat), 15 mParent(parent), 16 mRenderQueueBucket(NULL) 15 mParent(parent) 17 16 { 18 17 mCenter = GetBoundingBox().Center(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.h
r3034 r3054 68 68 Material *mMaterial; 69 69 SceneEntity *mParent; 70 71 /// pointer to the renderqueue bucket this entity belongs to72 RenderQueueBucket *mRenderQueueBucket;73 70 }; 74 71 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp
r3048 r3054 143 143 else 144 144 { 145 // no tone mapping => scale 145 // no tone mapping => scale to range 146 146 vtxParams->SetValue1f(8, 8e-5f); 147 147 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3052 r3054 162 162 int horizontalMotionBegin = 0; 163 163 164 165 164 bool leftKeyPressed = false; 166 165 bool rightKeyPressed = false; … … 170 169 bool ascendKeyPressed = false; 171 170 171 bool altKeyPressed = false; 172 172 173 bool showHelp = false; 173 174 bool showStatistics = false; … … 193 194 bool showShadowMap = false; 194 195 bool renderLightView = false; 195 196 bool altKeyPressed = false;197 198 196 bool useHDR = true; 199 197 198 PerfTimer frameTimer, algTimer; 199 200 PerformanceGraph *perfGraph = NULL; 201 200 202 static float ssaoTempCohFactor = 255.0; 201 202 203 PerfTimer frameTimer, algTimer;204 205 203 static int sCurrentMrtSet = 0; 206 204 207 PerformanceGraph *perfGraph = NULL; 208 205 206 #define CAMERA_PASS 0 207 #define LIGHT_PASS 1 209 208 210 209 //DeferredRenderer::SAMPLING_METHOD samplingMethod = DeferredRenderer::SAMPLING_POISSON; … … 267 266 void RenderShadowMap(float newfar); 268 267 268 269 269 static Matrix4x4 viewProjMat = IdentityMatrix(); 270 270 static Matrix4x4 oldViewProjMat = IdentityMatrix(); … … 356 356 357 357 //cout << "model path: " << model_path << endl; 358 359 358 cout << "**** end parameters ****" << endl << endl; 360 359 } … … 454 453 Matrix4x4 transl = TranslationMatrix(cubeCenter); 455 454 456 SceneEntityContainer dummy;457 458 455 string skyDomeStr(model_path + "sky.dem"); 459 456 … … 479 476 visualization = new Visualization(bvh, camera, NULL, &state); 480 477 478 for (int i = 0; i < 3; ++ i) 479 { 480 state.SetRenderTechnique((RenderState::RenderTechnique)i); 481 482 // fill all shapes into the render queue once so we can establish the buckets 483 ShapeContainer::const_iterator sit, sit_end = (*loader->GetShapes()).end(); 484 485 for (sit = (*loader->GetShapes()).begin(); sit != sit_end; ++ sit) 486 { 487 renderQueue->Enqueue(*sit); 488 } 489 490 //renderQueue->Apply(); 491 // just clear queue again 492 renderQueue->Clear(); 493 } 494 481 495 state.SetRenderTechnique(RenderState::FORWARD); 482 496 … … 978 992 // change CHC++ set of state variables (must be done for each change of camera because 979 993 // otherwise the temporal coherency is broken 980 BvhNode::SetCurrentState( 1);994 BvhNode::SetCurrentState(LIGHT_PASS); 981 995 shadowMap->RenderShadowView(shadowTraverser, viewProjMat); 982 BvhNode::SetCurrentState( 0);996 BvhNode::SetCurrentState(CAMERA_PASS); 983 997 } 984 998 else … … 1013 1027 { 1014 1028 FrameBufferObject::Release(); 1015 1016 //loader->DisableVertexProfile();1017 //loader->DisableFragmentProfile();1018 1029 1019 1030 if (!ssaoShader) ssaoShader = … … 1960 1971 // this must be done for each change of camera because 1961 1972 // otherwise the temporal coherency is broken 1962 BvhNode::SetCurrentState(1); 1963 1973 BvhNode::SetCurrentState(LIGHT_PASS); 1964 1974 // hack: temporarily change camera far plane 1965 1975 camera->SetFar(newfar); 1966 1967 1976 // the scene is rendered withouth any shading 1968 1977 shadowMap->ComputeShadowMap(shadowTraverser, viewProjMat); … … 1977 1986 1978 1987 // change back state 1979 BvhNode::SetCurrentState( 0);1980 } 1988 BvhNode::SetCurrentState(CAMERA_PASS); 1989 }
Note: See TracChangeset
for help on using the changeset viewer.