Changeset 3110 for GTP


Ignore:
Timestamp:
11/07/08 16:40:53 (16 years ago)
Author:
mattausch
Message:

worked on id for dynamic objects

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r3103 r3110  
    585585                                </File> 
    586586                                <File 
    587                                         RelativePath=".\src\EntityMerger.cpp" 
    588                                         > 
    589                                 </File> 
    590                                 <File 
    591                                         RelativePath=".\src\EntityMerger.h" 
    592                                         > 
    593                                 </File> 
    594                                 <File 
    595587                                        RelativePath=".\src\FrameBufferObject.cpp" 
    596588                                        > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VboFormatConverter/VboFormatConverter.cpp

    r3107 r3110  
    132132 
    133133void VboFormatConverter::LoadShape(const VertexArray &faceVertices, 
    134                                                         const VertexArray &faceNormals, 
    135                                                         const vector<Texcoord> &faceTexcoords) 
     134                                                                  const VertexArray &faceNormals, 
     135                                                                  const vector<Texcoord> &faceTexcoords) 
    136136{ 
    137137        int numElements = (int)faceVertices.size(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3107 r3110  
    7272 
    7373 
    74 int DeferredRenderer::colorBufferIdx = 0; 
     74int DeferredRenderer::colorBufferIdx = 3; 
    7575 
    7676 
     
    9191static float GaussianDistribution(float x, float y, float rho) 
    9292{ 
    93     float g = 1.0f / sqrtf(2.0f * M_PI * rho * rho); 
     93        float g = 1.0f / sqrtf(2.0f * M_PI * rho * rho); 
    9494    g *= expf( -(x*x + y*y) / (2.0f * rho * rho)); 
    9595 
     
    338338                {"colors", "normals", "oldTex", "noiseTex", "temporalCoherence",  
    339339                 "samples", "bl", "br", "tl", "tr", "modelViewProj", "oldModelViewProj", 
    340                  "oldEyePos", "oldbl", "oldbr", "oldtl", "oldtr"}; 
    341         sCgSsaoProgram->AddParameters(ssaoParams, 0, 17); 
     340                 "oldEyePos", "oldbl", "oldbr", "oldtl", "oldtr", "attribsTex", "inverseModelTrafo"}; 
     341        sCgSsaoProgram->AddParameters(ssaoParams, 0, 19); 
    342342         
    343343        string giParams[] =  
     
    559559                sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 
    560560 
     561        GLuint attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 
     562        sCgSsaoProgram->SetTexture(i ++, attribsTex); 
     563 
     564        sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix()); 
     565 
    561566        DrawQuad(sCgSsaoProgram); 
    562567 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.cpp

    r3071 r3110  
    8080        for (; sit != sit_end; ++ sit) 
    8181        { 
    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 
     87void RenderQueue::Enqueue(Shape *shape, SceneEntity *containingEnt) 
    8888{ 
    8989        Technique *tech = shape->GetMaterial()->GetTechnique(mState->GetRenderTechnique()); 
     
    159159        } 
    160160 
    161         bucket->mShapes.push_back(ShapePair(shape, trafo)); 
     161        bucket->mShapes.push_back(ShapePair(shape, containingEnt)); 
    162162} 
    163163 
     
    193193 
    194194                        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); 
    198198                        shape->Render(mState); 
    199                         t->Unload(mState); 
     199                        if (ent) ent->GetTransform()->Unload(mState); 
    200200                } 
    201201        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h

    r3071 r3110  
    1111class Camera; 
    1212 
    13 typedef std::pair<Shape *, Transform3 *> ShapePair; 
     13typedef std::pair<Shape *, SceneEntity *> ShapePair; 
    1414typedef std::vector<ShapePair> ShapePairArray; 
    1515 
     
    1919{ 
    2020        inline bool IsEmpty() const { return mShapes.empty();} 
     21 
    2122 
    2223        //////// 
     
    4142        ShaderProgram *mVertexProgram; 
    4243        ShaderProgram *mFragmentProgram; 
    43  
     44        /// the shapes that belong to a bucket 
     45        ShapePairArray mShapes; 
    4446        /// minimal distance to the camera 
    4547        //float mMinDistance; 
    46  
    47         /// the shapes that belong to a bucket 
    48         ShapePairArray mShapes; 
    4948}; 
    5049 
     
    6968 
    7069        ~RenderQueue(); 
    71         /** Enqueues an entity. 
     70        /** Enqueues all the shapes of an entity. 
    7271        */ 
    7372        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. 
    7574        */ 
    76         void Enqueue(Shape *shape, Transform3 *trafo); 
     75        void Enqueue(Shape *shape, SceneEntity *containingEnt); 
    7776        /** Sets the current render state 
    7877        */ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp

    r3109 r3110  
    66#include "Transform3.h" 
    77#include "Camera.h" 
    8  
     8#include "glInterface.h" 
    99 
    1010 
     
    9797        } 
    9898 
    99         mTransform->Load(state); 
     99        Prepare(state); 
    100100 
    101101        for (; sit != sit_end; ++ sit) 
     
    149149{ 
    150150        if (mTransform->IsIdentity()) return mBox; 
    151  
    152151        Matrix4x4 mat = mTransform->GetMatrix(); 
    153152 
     
    164163Vector3 SceneEntity::GetWorldCenter() const 
    165164{ 
    166         if (mTransform->IsIdentity()) 
    167                 return mCenter; 
     165        if (mTransform->IsIdentity()) return mCenter; 
    168166 
    169167        return mTransform->GetMatrix() *  mCenter; 
     
    171169 
    172170 
     171void 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); 
    173179} 
     180 
     181 
     182} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r3109 r3110  
    9292        */ 
    9393        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 
    94104        /** If false, the highest (most detailed) LOD level is used for all entities. 
    95105        */ 
    96106        static void SetUseLODs(bool useLODs) { sUseLODs = useLODs; } 
    97  
     107        /** See set 
     108        */ 
    98109        static bool GetUseLODs() { return sUseLODs; } 
    99110 
    100111 
     112        int mId; 
    101113 
    102114protected: 
     
    109121        int GetCurrentLODLevel(); 
    110122 
     123 
     124        ///////////////////// 
    111125 
    112126        /// the bounding box 
     
    127141        Vector3 mCenter; 
    128142 
    129         int mId; 
    130  
    131143        static bool sUseLODs; 
    132144        static int sCurrentId; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3107 r3110  
    523523        CreateAnimation(); 
    524524 
     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 
    525532 
    526533        ////////// 
     
    878885        // draw to 3 color buffers 
    879886        // 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); 
    890890 
    891891        sCurrentMrtSet = 1 - sCurrentMrtSet; 
     
    897897void MainLoop()  
    898898{        
     899        Vector3 oldPos = motionPath->GetCurrentPosition(); 
     900 
    899901        //motionPath->Move(0.3f); 
    900902        motionPath->Move(0.01f); 
    901903 
     904        nMatrix mat =  
    902905        Vector3 planepos = motionPath->GetCurrentPosition(); 
    903906 
     
    20392042 
    20402043 
    2041 /** Toach each material once in order to preload the render queue  
     2044/** Touch each material once in order to preload the render queue  
    20422045        bucket id of each material 
    20432046*/ 
     
    20542057                { 
    20552058                        static Transform3 dummy(IdentityMatrix()); 
    2056                         renderQueue->Enqueue(*sit, &dummy); 
     2059                        renderQueue->Enqueue(*sit, NULL); 
    20572060                } 
    20582061         
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r3092 r3110  
    3838        float4 col: COLOR0; 
    3939        float3 norm: COLOR1; 
    40         float3 pos: COLOR2; 
     40        float3 id: COLOR2; 
    4141}; 
    4242 
     
    8383        // compute eye linear depth 
    8484        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); 
    8788 
    8889        return pix; 
     
    101102        // eye space depth 
    102103        pix.col.w = length(IN.eyePos.xyz); 
    103         // hack: squeeze some information about the ambient term into the target 
    104         //pix.col.w = glstate.material.emission.x; 
    105  
     104        // the scene entity id 
     105        pix.id = glstate.fog.color.xyz; 
     106         
    106107        return pix; 
    107108} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/sky_preetham.cg

    r3041 r3110  
    3737        float4 col: COLOR0; 
    3838        float3 norm: COLOR1; 
    39         float3 pos: COLOR2; 
     39        float3 id: COLOR2; 
    4040}; 
    4141 
     
    8383                              0.055648f, -0.204043f,  1.057311f); 
    8484 
    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); 
    8788 
    8889        OUT.color.rgb *= multiplier; 
     
    9192 
    9293        OUT.normal = IN.normal; 
    93  
     94         
    9495        return OUT; 
    9596} 
     
    103104        pix.col.w = 1e20f; 
    104105        pix.norm = IN.normal; 
    105          
     106        // the scene entity id 
     107        pix.id = glstate.fog.color.xyz; 
     108 
    106109        return pix; 
    107110} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3109 r3110  
    150150        float4x4 trafo; 
    151151         
    152         if (id > 20) trafo = oldModelViewProj; 
    153         else trafo = inverseModelTrafo * oldModelViewProj; 
     152        if (id < 10)  
     153                trafo = oldModelViewProj; 
     154        else  
     155                trafo = inverseModelTrafo * oldModelViewProj; 
    154156 
    155157        // compute translational portion 
     
    350352                   uniform float3 oldtl, 
    351353                   uniform float3 oldtr, 
    352                    uniform sampler2D attribs, 
     354                   uniform sampler2D attribsTex, 
    353355                   uniform float4x4 inverseModelTrafo 
    354356                   ) 
     
    383385        //-- compute temporally smoothing 
    384386 
    385         float id = tex2Dlod(attribs, float4(IN.texCoord, 0, 0)).x; 
     387        float3 id = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
    386388 
    387389        OUT.illum_col = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, ao, IN.texCoord, oldEyePos, 
    388390                                              oldTex, oldModelViewProj, temporalCoherence, 
    389                                               colors, w, bl, br, tl, tr, projPos, inverseModelTrafo, id, 
     391                                              colors, w, bl, br, tl, tr, projPos, inverseModelTrafo, id.z, 
    390392                                                                          noiseTex, samples, scaleFactor, oldbl, oldbr, oldtl, oldtr); 
    391393 
     394        //OUT.illum_col.xyz = id; 
    392395        //OUT.illum_col.xyz = normal * 0.5f + 0.5f; 
    393396        return OUT; 
     
    405408 
    406409        for (int i = 0; i < NUM_SSAO_FILTERSAMPLES; ++ i) 
    407         { 
     410        {        
    408411                average += filterWeights[i] * tex2Dlod(ssaoTex, float4(texCoord + filterOffs[i] * scale, 0, 0)).x; 
    409412                w += filterWeights[i]; 
     
    428431        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    429432 
    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; 
    434437        //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); 
    436440        //OUT.illum_col.xyz = float3(1.0f - ao.x, 1.0f - ao.y * 1e-2f, 1); 
    437441        //OUT.illum_col.xyz = float3(1.0f - ao.x, ao.y, 0); 
Note: See TracChangeset for help on using the changeset viewer.