Changeset 3110 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 11/07/08 16:40:53 (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
r3103 r3110 585 585 </File> 586 586 <File 587 RelativePath=".\src\EntityMerger.cpp"588 >589 </File>590 <File591 RelativePath=".\src\EntityMerger.h"592 >593 </File>594 <File595 587 RelativePath=".\src\FrameBufferObject.cpp" 596 588 > -
GTP/trunk/App/Demos/Vis/FriendlyCulling/VboFormatConverter/VboFormatConverter.cpp
r3107 r3110 132 132 133 133 void VboFormatConverter::LoadShape(const VertexArray &faceVertices, 134 const VertexArray &faceNormals,135 const vector<Texcoord> &faceTexcoords)134 const VertexArray &faceNormals, 135 const vector<Texcoord> &faceTexcoords) 136 136 { 137 137 int numElements = (int)faceVertices.size(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3107 r3110 72 72 73 73 74 int DeferredRenderer::colorBufferIdx = 0;74 int DeferredRenderer::colorBufferIdx = 3; 75 75 76 76 … … 91 91 static float GaussianDistribution(float x, float y, float rho) 92 92 { 93 93 float g = 1.0f / sqrtf(2.0f * M_PI * rho * rho); 94 94 g *= expf( -(x*x + y*y) / (2.0f * rho * rho)); 95 95 … … 338 338 {"colors", "normals", "oldTex", "noiseTex", "temporalCoherence", 339 339 "samples", "bl", "br", "tl", "tr", "modelViewProj", "oldModelViewProj", 340 "oldEyePos", "oldbl", "oldbr", "oldtl", "oldtr" };341 sCgSsaoProgram->AddParameters(ssaoParams, 0, 1 7);340 "oldEyePos", "oldbl", "oldbr", "oldtl", "oldtr", "attribsTex", "inverseModelTrafo"}; 341 sCgSsaoProgram->AddParameters(ssaoParams, 0, 19); 342 342 343 343 string giParams[] = … … 559 559 sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 560 560 561 GLuint attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 562 sCgSsaoProgram->SetTexture(i ++, attribsTex); 563 564 sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix()); 565 561 566 DrawQuad(sCgSsaoProgram); 562 567 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp
r3071 r3110 80 80 for (; sit != sit_end; ++ sit) 81 81 { 82 Enqueue(*sit, entity ->GetTransform());83 } 84 } 85 86 87 void RenderQueue::Enqueue(Shape *shape, Transform3 *trafo)82 Enqueue(*sit, entity); 83 } 84 } 85 86 87 void RenderQueue::Enqueue(Shape *shape, SceneEntity *containingEnt) 88 88 { 89 89 Technique *tech = shape->GetMaterial()->GetTechnique(mState->GetRenderTechnique()); … … 159 159 } 160 160 161 bucket->mShapes.push_back(ShapePair(shape, trafo));161 bucket->mShapes.push_back(ShapePair(shape, containingEnt)); 162 162 } 163 163 … … 193 193 194 194 Shape *shape = s.first; 195 Transform3 *t = s.second;196 197 t->Load(mState);195 SceneEntity *ent = s.second; 196 197 if (ent) ent->Prepare(mState); 198 198 shape->Render(mState); 199 t->Unload(mState);199 if (ent) ent->GetTransform()->Unload(mState); 200 200 } 201 201 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
r3071 r3110 11 11 class Camera; 12 12 13 typedef std::pair<Shape *, Transform3*> ShapePair;13 typedef std::pair<Shape *, SceneEntity *> ShapePair; 14 14 typedef std::vector<ShapePair> ShapePairArray; 15 15 … … 19 19 { 20 20 inline bool IsEmpty() const { return mShapes.empty();} 21 21 22 22 23 //////// … … 41 42 ShaderProgram *mVertexProgram; 42 43 ShaderProgram *mFragmentProgram; 43 44 /// the shapes that belong to a bucket 45 ShapePairArray mShapes; 44 46 /// minimal distance to the camera 45 47 //float mMinDistance; 46 47 /// the shapes that belong to a bucket48 ShapePairArray mShapes;49 48 }; 50 49 … … 69 68 70 69 ~RenderQueue(); 71 /** Enqueues a n entity.70 /** Enqueues all the shapes of an entity. 72 71 */ 73 72 void Enqueue(SceneEntity *entity); 74 /** Enqueues a single shape. 73 /** Enqueues a single shape. We also have to pass the entity which contains the shape. 75 74 */ 76 void Enqueue(Shape *shape, Transform3 *trafo);75 void Enqueue(Shape *shape, SceneEntity *containingEnt); 77 76 /** Sets the current render state 78 77 */ -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp
r3109 r3110 6 6 #include "Transform3.h" 7 7 #include "Camera.h" 8 8 #include "glInterface.h" 9 9 10 10 … … 97 97 } 98 98 99 mTransform->Load(state);99 Prepare(state); 100 100 101 101 for (; sit != sit_end; ++ sit) … … 149 149 { 150 150 if (mTransform->IsIdentity()) return mBox; 151 152 151 Matrix4x4 mat = mTransform->GetMatrix(); 153 152 … … 164 163 Vector3 SceneEntity::GetWorldCenter() const 165 164 { 166 if (mTransform->IsIdentity()) 167 return mCenter; 165 if (mTransform->IsIdentity()) return mCenter; 168 166 169 167 return mTransform->GetMatrix() * mCenter; … … 171 169 172 170 171 void SceneEntity::Prepare(RenderState *state) 172 { 173 int id[] = {(mId / (255 * 255)) % 255, (mId / 255) % 255, mId % 255, 0}; 174 175 GLfloat fogColor[4] = {(float)id[0] / 255.0f, (float)id[1] / 255.0f, (float)id[2] / 255.0f, .0f}; 176 glFogfv(GL_FOG_COLOR, fogColor); 177 178 mTransform->Load(state); 173 179 } 180 181 182 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h
r3109 r3110 92 92 */ 93 93 Vector3 GetWorldCenter() const; 94 /** Prepare this scene entity for rendering, i.e., sets the state and the transform. 95 This is used with the render queue. When a shape belonging to this scene entity 96 is rendered, this function is called in beforehand. 97 */ 98 void Prepare(RenderState *state); 99 100 101 ///////////// 102 //-- static functions 103 94 104 /** If false, the highest (most detailed) LOD level is used for all entities. 95 105 */ 96 106 static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; } 97 107 /** See set 108 */ 98 109 static bool GetUseLODs() { return sUseLODs; } 99 110 100 111 112 int mId; 101 113 102 114 protected: … … 109 121 int GetCurrentLODLevel(); 110 122 123 124 ///////////////////// 111 125 112 126 /// the bounding box … … 127 141 Vector3 mCenter; 128 142 129 int mId;130 131 143 static bool sUseLODs; 132 144 static int sCurrentId; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3107 r3110 523 523 CreateAnimation(); 524 524 525 for (int i = 0; i < sceneEntities.size(); ++ i) 526 sceneEntities[i]->mId = 0; 527 for (int i = 0; i < dynamicObjects.size(); ++ i) 528 dynamicObjects[i]->mId = 0; 529 530 buddha->mId = 50; 531 525 532 526 533 ////////// … … 878 885 // draw to 3 color buffers 879 886 // a color, normal, and positions buffer 880 if (sCurrentMrtSet == 0) 881 { 882 DeferredRenderer::colorBufferIdx = 0; 883 glDrawBuffers(2, mrt); 884 } 885 else 886 { 887 DeferredRenderer::colorBufferIdx = 3; 888 glDrawBuffers(2, mrt2); 889 } 887 DeferredRenderer::colorBufferIdx = 3 - DeferredRenderer::colorBufferIdx; 888 if (sCurrentMrtSet == 0) glDrawBuffers(3, mrt); 889 else glDrawBuffers(3, mrt2); 890 890 891 891 sCurrentMrtSet = 1 - sCurrentMrtSet; … … 897 897 void MainLoop() 898 898 { 899 Vector3 oldPos = motionPath->GetCurrentPosition(); 900 899 901 //motionPath->Move(0.3f); 900 902 motionPath->Move(0.01f); 901 903 904 nMatrix mat = 902 905 Vector3 planepos = motionPath->GetCurrentPosition(); 903 906 … … 2039 2042 2040 2043 2041 /** To ach each material once in order to preload the render queue2044 /** Touch each material once in order to preload the render queue 2042 2045 bucket id of each material 2043 2046 */ … … 2054 2057 { 2055 2058 static Transform3 dummy(IdentityMatrix()); 2056 renderQueue->Enqueue(*sit, &dummy);2059 renderQueue->Enqueue(*sit, NULL); 2057 2060 } 2058 2061 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg
r3092 r3110 38 38 float4 col: COLOR0; 39 39 float3 norm: COLOR1; 40 float3 pos: COLOR2;40 float3 id: COLOR2; 41 41 }; 42 42 … … 83 83 // compute eye linear depth 84 84 pix.col.w = length(IN.eyePos.xyz); 85 // hack: squeeze some information about ambient into the texture 86 //pix.col.w = glstate.material.emission.x; 85 // the scene entity id 86 pix.id = glstate.fog.color.xyz; 87 //pix.id = float3(1,1,1); 87 88 88 89 return pix; … … 101 102 // eye space depth 102 103 pix.col.w = length(IN.eyePos.xyz); 103 // hack: squeeze some information about the ambient term into the target104 //pix.col.w = glstate.material.emission.x;105 104 // the scene entity id 105 pix.id = glstate.fog.color.xyz; 106 106 107 return pix; 107 108 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg
r3041 r3110 37 37 float4 col: COLOR0; 38 38 float3 norm: COLOR1; 39 float3 pos: COLOR2;39 float3 id: COLOR2; 40 40 }; 41 41 … … 83 83 0.055648f, -0.204043f, 1.057311f); 84 84 85 float3 hcol = mul(conv_Mat, XYZ); 86 OUT.color = float4(hcol, 1.0f); 85 //float3 hcol = mul(conv_Mat, XYZ); 86 //OUT.color = float4(hcol, 1.0f); 87 OUT.color = float4(mul(conv_Mat, XYZ), 1.0f); 87 88 88 89 OUT.color.rgb *= multiplier; … … 91 92 92 93 OUT.normal = IN.normal; 93 94 94 95 return OUT; 95 96 } … … 103 104 pix.col.w = 1e20f; 104 105 pix.norm = IN.normal; 105 106 // the scene entity id 107 pix.id = glstate.fog.color.xyz; 108 106 109 return pix; 107 110 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg
r3109 r3110 150 150 float4x4 trafo; 151 151 152 if (id > 20) trafo = oldModelViewProj; 153 else trafo = inverseModelTrafo * oldModelViewProj; 152 if (id < 10) 153 trafo = oldModelViewProj; 154 else 155 trafo = inverseModelTrafo * oldModelViewProj; 154 156 155 157 // compute translational portion … … 350 352 uniform float3 oldtl, 351 353 uniform float3 oldtr, 352 uniform sampler2D attribs ,354 uniform sampler2D attribsTex, 353 355 uniform float4x4 inverseModelTrafo 354 356 ) … … 383 385 //-- compute temporally smoothing 384 386 385 float id = tex2Dlod(attribs, float4(IN.texCoord, 0, 0)).x;387 float3 id = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 386 388 387 389 OUT.illum_col = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, ao, IN.texCoord, oldEyePos, 388 390 oldTex, oldModelViewProj, temporalCoherence, 389 colors, w, bl, br, tl, tr, projPos, inverseModelTrafo, id ,391 colors, w, bl, br, tl, tr, projPos, inverseModelTrafo, id.z, 390 392 noiseTex, samples, scaleFactor, oldbl, oldbr, oldtl, oldtr); 391 393 394 //OUT.illum_col.xyz = id; 392 395 //OUT.illum_col.xyz = normal * 0.5f + 0.5f; 393 396 return OUT; … … 405 408 406 409 for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 407 { 410 { 408 411 average += filterWeights[i] * tex2Dlod(ssaoTex, float4(texCoord + filterOffs[i] * scale, 0, 0)).x; 409 412 w += filterWeights[i]; … … 428 431 float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 429 432 430 if ((ao.y < 10.0f) && (col.w < 1e10f))431 ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y));//ao.z);432 433 OUT.illum_col = col * ao.x;433 //if ((ao.y < 10.0f) && (col.w < 1e10f)) 434 // ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights, 1.0f / (1.0f + ao.y));//ao.z); 435 436 //OUT.illum_col = col * ao.x; 434 437 //OUT.illum_col = float4(ao.y, ao.y, ao.y, col.w); 435 //OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w); 438 //OUT.illum_col = float4(ao.x, ao.y, ao.z, col.w); 439 OUT.illum_col = float4(ao.x, ao.x, ao.x, col.w); 436 440 //OUT.illum_col.xyz = float3(1.0f - ao.x, 1.0f - ao.y * 1e-2f, 1); 437 441 //OUT.illum_col.xyz = float3(1.0f - ao.x, ao.y, 0);
Note: See TracChangeset
for help on using the changeset viewer.