Changeset 3284 for GTP


Ignore:
Timestamp:
01/18/09 02:25:26 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
11 edited

Legend:

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

    r3262 r3284  
    284284                        </File> 
    285285                        <File 
     286                                RelativePath=".\src\VisibilitySolutionLoader.cpp" 
     287                                > 
     288                        </File> 
     289                        <File 
     290                                RelativePath=".\src\VisibilitySolutionLoader.h" 
     291                                > 
     292                        </File> 
     293                        <File 
    286294                                RelativePath=".\src\WalkThroughRecorder.cpp" 
    287295                                > 
     
    579587                                </File> 
    580588                                <File 
    581                                         RelativePath=".\src\VisibilitySolutionLoader.h" 
    582                                         > 
    583                                 </File> 
    584                                 <File 
    585589                                        RelativePath=".\src\Visualization.h" 
    586590                                        > 
     
    683687                                </File> 
    684688                                <File 
     689                                        RelativePath=".\src\Pvs.cpp" 
     690                                        > 
     691                                </File> 
     692                                <File 
    685693                                        RelativePath=".\src\RenderQueue.cpp" 
    686694                                        > 
     
    778786                                <File 
    779787                                        RelativePath=".\src\ViewCellsTree.cpp" 
    780                                         > 
    781                                 </File> 
    782                                 <File 
    783                                         RelativePath=".\src\VisibilitySolutionLoader.cpp" 
    784788                                        > 
    785789                                </File> 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3282 r3284  
    99#filename=vienna_full_hp 
    1010#bvhname=vienna_full_hp 
    11 filename=tryvienna2 
    12 bvhname=tryvienna2 
     11#filename=tryvienna2 
     12#bvhname=tryvienna2 
    1313#filename=mypompeii 
    1414#bvhname=mypompeii 
    1515#filename=pompeii/pompeii_full 
    1616#filename=pompeii/pompeii_part 
    17 #filename=city 
    18 #bvhname=city 
     17filename=city 
     18bvhname=city 
    1919useLODs=1 
    2020# shadow map size 
     
    3232# if using pvs, this specifies the name of the visibility solutin 
    3333#visibilitySolution=vienna_full-8x3-pgv 
     34#visibilitySolution=vienna_full-8x3-spgvu 
     35#visibilitySolution=vienna_full-8x3-refu 
    3436#visibilitySolution=mypompeii-1x1-pgv 
    3537#visibilitySolution=mypompeii-2x1-obvh-pgv 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp

    r3282 r3284  
    4040        if (delData) 
    4141        { 
    42                 //DEL_ARRAY_PTR(mVertices); 
     42                DEL_ARRAY_PTR(mVertices); 
    4343                DEL_ARRAY_PTR(mNormals); 
    4444                DEL_ARRAY_PTR(mTexCoords); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.cpp

    r3283 r3284  
    77{ 
    88 
    9 bool Pvs::sStoreTimeStamps = false; 
     9 
     10bool operator<(const PvsEntry &a, const PvsEntry &b)  
     11{ 
     12   //return a.mTimeStamp < b.mTimeStamp; 
     13        return true; 
     14} 
    1015 
    1116 
     
    2227 
    2328 
     29void Pvs::Sort() 
     30{ 
     31} 
     32 
     33 
    2434 
    2535} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h

    r3283 r3284  
    1111class Bvh; 
    1212 
     13struct 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 
     32typedef std::vector<PvsEntry> PvsEntryContainer; 
     33 
    1334 
    1435/** Class representing the Potentially Visible Set (PVS) from a view cell. 
     
    1637class Pvs 
    1738{ 
    18  
    1939public: 
    2040 
     
    2242 
    2343        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); 
    2647 
    2748        int GetSize() const; 
    2849 
    29         inline SceneEntity *GetEntry(int i) const; 
     50        inline SceneEntity *GetEntity(int i) const; 
     51         
     52        inline PvsEntry GetEntry(int i) const; 
    3053 
    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(); 
    3258 
    3359 
     
    3561 
    3662        /// vector of PVS entries 
    37         SceneEntityContainer mEntries;  
    38         std::vector<float> mTimeStamps; 
    39  
    40         static bool sStoreTimeStamps; 
     63        PvsEntryContainer mEntries;  
    4164}; 
    4265 
    4366 
    44 inline SceneEntity *Pvs::GetEntry(int i) const  
     67inline SceneEntity *Pvs::GetEntity(int i) const  
     68{ 
     69        return mEntries[i].mEntity;  
     70} 
     71 
     72 
     73inline PvsEntry Pvs::GetEntry(int i) const  
    4574{ 
    4675        return mEntries[i];  
     
    4877 
    4978 
    50 inline void Pvs::AddEntry(SceneEntity *ent, float timeStamp)  
     79inline void Pvs::AddEntry(const PvsEntry &entry)  
    5180{ 
    52         mEntries.push_back(ent);  
    53  
    54         if (sStoreTimeStamps) 
    55         { 
    56                 mTimeStamps.push_back(timeStamp); 
    57         } 
     81        mEntries.push_back(entry); 
    5882} 
    5983 
     
    6589 
    6690 
    67 inline void Pvs::AddEntry(Bvh *bvh, BvhNode *node)  
     91inline void Pvs::AddEntry(Bvh *bvh, BvhNode *node, float timeStamp)  
    6892{ 
    6993        int geometrySize; 
     
    7397        for (int i = 0; i < geometrySize; ++ i) 
    7498        { 
    75                 AddEntry(entities[i]); 
     99                AddEntry(PvsEntry(entities[i], timeStamp)); 
    76100        } 
    77101} 
     102 
    78103 
    79104 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/PvsCollectionRenderer.h

    r3258 r3284  
    4040        void SetViewCell(ViewCell *vc) { mViewCell = vc; } 
    4141 
    42         virtual int GetType() const { return CULL_COLLECTOR; } 
     42        //virtual int GetType() const { return CULL_COLLECTOR; } 
     43        virtual int GetType() const { return -1; } 
    4344 
    4445protected: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h

    r3258 r3284  
    5454                  STOP_AND_WAIT,  
    5555                  CHC, CHCPLUSPLUS,  
    56                   CULL_COLLECTOR, 
     56                  //CULL_COLLECTOR, 
    5757                  NUM_TRAVERSAL_TYPES}; 
    5858 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp

    r3282 r3284  
    149149        if (number != mViewCells.size())  
    150150        { 
    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; 
    152153                return false; 
    153154        } 
     
    176177 
    177178                        outstream << n->GetFirstEntity() << " " << n->GetLastEntity() << " " << n->GetBox() << " " << box << endl; 
    178                          
    179                 } 
    180         } 
    181                  
    182         outstream.close(); 
    183          
    184  
     179                } 
     180        } 
     181                 
    185182        for (int i = 0; i < number; ++ i)  
    186183        { 
     
    196193         
    197194                        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(); 
    201202 
    202203        return true; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3282 r3284  
    154154static int globalVisibleId = 0; 
    155155 
     156PerfTimer applicationTimer; 
     157 
     158float shotRays = .0f; 
    156159 
    157160 
     
    927930                tr = new CHCPlusPlusTraverser(); 
    928931                break; 
    929         case RenderTraverser::CULL_COLLECTOR: 
    930                 tr = new PvsCollectionRenderer(); 
    931                 break; 
     932        //case RenderTraverser::CULL_COLLECTOR: 
     933        //      tr = new PvsCollectionRenderer(); 
     934        //      break; 
    932935        default: 
    933936                tr = new FrustumCullingTraverser(); 
     
    12291232        if (1 && usePvs) 
    12301233        { 
    1231                 if (!viewCellsTree)     LoadVisibilitySolution(); 
     1234                if (!viewCellsTree)      
     1235                { 
     1236                        applicationTimer.Start(); 
     1237                        LoadVisibilitySolution(); 
     1238                } 
    12321239 
    12331240                if (viewCellsTree) LoadPvs(); 
     
    13131320        else 
    13141321        { 
    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 
    13211325                // actually render the scene geometry using the specified algorithm 
    13221326                traverser->RenderScene(); 
     
    23722376                        , "CHC" 
    23732377                        , "CHC ++" 
    2374                         , "Collector" 
     2378//                      , "Collector" 
    23752379                }; 
    2376                  
     2380         
     2381#if 0 
    23772382                if (!showAlgorithmTime) 
    23782383                { 
     
    23882393                        myfont.DrawString(msg[7], 1.3f, 690.0f, 760.0f);//, top_color, bottom_color); 
    23892394                } 
    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 
    23942400        } 
    23952401 
     
    24282434                        RenderShadowMap(newFar); 
    24292435                } 
     2436 
    24302437                // initialize deferred rendering 
    24312438                InitDeferredRendering(); 
     
    26512658        viewCell = viewCellsTree->GetViewCell(camera->GetPosition()); 
    26522659 
    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; 
    26542665 
    26552666        SceneEntity::SetCurrentVisibleId(globalVisibleId); 
     
    26572668        for (int i = 0; i < viewCell->mPvs.GetSize(); ++ i) 
    26582669        { 
    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; 
    26662680        ++ globalVisibleId; 
    26672681} 
     
    27012715void LoadPompeiiFloor() 
    27022716{ 
    2703         AxisAlignedBox3 pompeiiBox = SceneEntity::ComputeBoundingBox(staticObjects); 
     2717        AxisAlignedBox3 pompeiiBox =  
     2718                SceneEntity::ComputeBoundingBox(staticObjects); 
    27042719 
    27052720        // todo: dispose texture 
     
    27222737        depthPass->SetLightingEnabled(false); 
    27232738 
    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"); 
    27262743 
    27272744        deferred->SetFragmentProgram(defaultFragmentTexProgramMrt); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3230 r3284  
    8989        for (int i = 0; i < NUM_PCF_TABS; ++ i)  
    9090        { 
    91                 const float2 offset = samples[i]; 
     91                float2 offset; 
    9292                const float w = weights[i]; 
    9393 
     
    9696                //-- add random noise: reflect around random normal vector (warning: slow!) 
    9797 
    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); 
    100101#else 
    101                 const float2 offsetTransformed = offset; 
     102                offset = samples[i]; 
    102103#endif 
    103104                // weight with projected coordinate to reach similar kernel size for near and far 
    104                 float2 texcoord = lightSpacePos + offsetTransformed * scale; 
     105                float2 texcoord = lightSpacePos + offset * scale; 
    105106 
    106107                float shadowDepth = tex2D(shadowMap, texcoord).x; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3271 r3284  
    249249                { 
    250250                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
    251                         //offsetTransformed = myreflect(offset, mynoise); 
     251                        //offset = myreflect(samples[i], mynoise); 
    252252                        offset = myrotate(samples[i], mynoise.x); 
    253253                } 
Note: See TracChangeset for help on using the changeset viewer.