Changeset 3242


Ignore:
Timestamp:
01/02/09 17:29:48 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
6 added
9 edited

Legend:

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

    r3238 r3242  
    503503                                </File> 
    504504                                <File 
     505                                        RelativePath=".\src\Pvs.h" 
     506                                        > 
     507                                </File> 
     508                                <File 
    505509                                        RelativePath=".\src\RenderQueue.h" 
    506510                                        > 
     
    540544                                <File 
    541545                                        RelativePath=".\src\Transform3.h" 
     546                                        > 
     547                                </File> 
     548                                <File 
     549                                        RelativePath=".\src\ViewCellsTree.h" 
     550                                        > 
     551                                </File> 
     552                                <File 
     553                                        RelativePath=".\src\VisibilitySolutionLoader.h" 
    542554                                        > 
    543555                                </File> 
     
    639651                                </File> 
    640652                                <File 
     653                                        RelativePath=".\src\Pvs.cpp" 
     654                                        > 
     655                                </File> 
     656                                <File 
    641657                                        RelativePath=".\src\RenderQueue.cpp" 
    642658                                        > 
     
    730746                                <File 
    731747                                        RelativePath=".\src\Transform3.cpp" 
     748                                        > 
     749                                </File> 
     750                                <File 
     751                                        RelativePath=".\src\ViewCellsTree.cpp" 
     752                                        > 
     753                                </File> 
     754                                <File 
     755                                        RelativePath=".\src\VisibilitySolutionLoader.cpp" 
    732756                                        > 
    733757                                </File> 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp

    r3241 r3242  
    246246 
    247247        // update bvh bounding boxes with loaded geometry 
    248         UpdateNodeBox(mRoot); 
     248        UpdateBvh(mRoot); 
     249 
     250        cout << "bvh: " << mRoot->first << " " << mRoot->last << " bb: " << mRoot->box << endl; 
    249251 
    250252        cout << "writing scene" << endl; 
     
    331333                                default: 
    332334                                        sscanf(str + 1, "%f %f %f", &x, &y, &z); 
    333                                         //const float scale = 5e-3f; 
    334                                         const float scale = 0.1f; 
     335                                        const float scale = 1.0f; 
     336                                        //const float scale = 0.1f; 
    335337                                        tempVertices.push_back(CHCDemoEngine::Vector3(x * scale, y * scale, z * scale)); 
    336338                                        //cout <<"v " << x << " " << y << " "<< z << " "; 
     
    395397 
    396398                                        sscanf(str + 1, "%f %f %f", &x, &y, &z); 
    397                                         const float scale = 0.1f; 
     399                                        const float scale = 1.0f; 
    398400                                        vertices.push_back(CHCDemoEngine::Vector3(x * scale, y * scale, z * scale)); 
    399401                                        break; 
     
    558560        vector<TexCoord> _texCoords; 
    559561 
     562        CHCDemoEngine::AxisAlignedBox3 testBox; 
     563        testBox.Initialize(); 
     564 
     565        for (int i = 0; i < vertices.size(); ++ i) 
     566        { 
     567                testBox.Include(vertices[i]); 
     568        } 
     569 
     570        cout << "testbox: " << testBox << endl; 
     571 
    560572        mGeometry.reserve(mBvhLeaves.size()); 
    561573 
     
    580592                LoadShape(_vertices, _normals, _texCoords); 
    581593                 
    582                 node->geometry = mGeometry.back(); 
     594                // we store geometry in our bvh => change first and last pointer 
     595                // fromt triangles to geometry 
     596                node->first = (int)mGeometry.size() - 1; 
     597                node->last = (int)mGeometry.size() - 1; 
    583598 
    584599                _vertices.clear(); 
     
    639654        leaf->box.Initialize(); 
    640655 
    641         Geometry *geom = leaf->geometry; 
     656        Geometry *geom = mGeometry[leaf->first]; 
    642657 
    643658        for (size_t i = 0; i < geom->mVertexCount; ++ i) 
     
    842857        int nodeType; 
    843858 
    844         if (!node->IsLeaf()) 
     859        if (node->IsLeaf()) 
    845860                nodeType = TYPE_LEAF; 
    846861        else  
     
    856871 
    857872        stream.write(reinterpret_cast<char *>(&bMin), sizeof(CHCDemoEngine::Vector3)); 
    858         stream.write(reinterpret_cast<char *>(&bMin), sizeof(CHCDemoEngine::Vector3)); 
    859 } 
    860  
    861  
    862 void VisibilitySolutionConverter::UpdateNodeBox(BvhNode *node) 
     873        stream.write(reinterpret_cast<char *>(&bMax), sizeof(CHCDemoEngine::Vector3)); 
     874} 
     875 
     876 
     877void VisibilitySolutionConverter::UpdateBvh(BvhNode *node) 
    863878{ 
    864879        if (!node->IsLeaf()) 
    865880        { 
    866881                BvhInterior *interior = (BvhInterior *)node; 
     882 
     883                UpdateBvh(interior->front); 
     884                UpdateBvh(interior->back); 
     885 
     886                interior->first = min(interior->front->first, interior->back->first); 
     887                interior->last = max(interior->front->last, interior->back->last); 
     888                 
    867889                node->box = Union(interior->front->box, interior->back->box); 
    868  
    869                 UpdateNodeBox(interior->front); 
    870                 UpdateNodeBox(interior->back); 
    871890        } 
    872891        else 
    873892        { 
    874893                UpdateLeafBox((BvhLeaf *)node); 
     894                //cout << "bb: " << node->box << endl; 
    875895        } 
    876896} 
     
    883903 
    884904        if (!stream.is_open()) return NULL; 
    885  
    886         cout << "loading bvh" << endl; 
    887905 
    888906        WriteNextNode(stream, mRoot); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h

    r3241 r3242  
    6868struct BvhLeaf: public BvhNode 
    6969{ 
    70         Geometry *geometry; 
    71  
    72         BvhLeaf(): BvhNode(), geometry(NULL) {} 
     70        BvhLeaf(): BvhNode() {} 
    7371}; 
    7472 
     
    141139 
    142140        void UpdateLeafBox(BvhLeaf *leaf); 
    143  
    144         void UpdateNodeBox(BvhNode *node); 
     141        /** Prepare bvh for exporting. 
     142        */ 
     143        void UpdateBvh(BvhNode *node); 
    145144 
    146145 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/main.cpp

    r3238 r3242  
    2323        } 
    2424         
    25         //std::cin.get(); 
    2625        cout << "conversion successful" << endl; 
     26 
     27        std::cin.get(); 
    2728 
    2829        return 0; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3238 r3242  
    77# misc stuff 
    88 
    9 filename=city 
     9filename=vienna_full_hp 
    1010useLODs=1 
    1111# shadow map size 
     
    6161 
    6262# the used render method (forward, forward + depth pass, deferred, deferred + depth pass 
    63 renderMethod=2 
     63#renderMethod=2 
     64renderMethod=0 
    6465 
    6566#modelPath=data/city/model/ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp

    r3239 r3242  
    8282        bvh->mNumNodes = 3; 
    8383 
     84        cout << "*******************\nbox: " << root->mBox << " area: " << root->mArea << endl; 
     85 
    8486        tQueue.push(root); 
    8587         
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3235 r3242  
    302302mSavedFrameNumber(-1), 
    303303mSavedFrameSuffix(""), 
    304 mMaxDistance(1e6f) 
     304mMaxDistance(1e6f), 
     305mTempCohFactor(.0f), 
     306mUseToneMapping(false), 
     307mUseAntiAliasing(false), 
     308mUseDepthOfField(false) 
    305309{ 
    306310        /////////// 
     
    537541 
    538542void DeferredRenderer::Render(FrameBufferObject *fbo,  
    539                                                           float tempCohFactor, 
    540543                                                          DirectionalLight *light, 
    541                                                           bool useToneMapping, 
    542                                                           bool useAntiAliasing, 
    543544                                                          ShadowMap *shadowMap 
    544545                                                          ) 
     
    562563        { 
    563564        case SSAO: 
    564                 ComputeSsao(fbo, tempCohFactor); 
     565                ComputeSsao(fbo, mTempCohFactor); 
    565566                CombineSsao(fbo); 
    566567                break; 
    567568        case GI: 
    568                 ComputeGlobIllum(fbo, tempCohFactor); 
     569                ComputeGlobIllum(fbo, mTempCohFactor); 
    569570                CombineIllum(fbo); 
    570571                break; 
     
    574575        } 
    575576 
    576         /// do depth of field 
    577         DepthOfField(fbo); 
    578  
    579         if (useToneMapping) 
     577        /// depth of field 
     578        if (mUseDepthOfField) 
     579        { 
     580                DepthOfField(fbo); 
     581        } 
     582 
     583        if (mUseToneMapping) 
    580584        { 
    581585                float imageKey, whiteLum, middleGrey; 
     
    593597        // multisampling is difficult / costly with deferred shading 
    594598        // at least do some edge blurring  
    595         if (useAntiAliasing) AntiAliasing(fbo, light, displayAfterAA);  
     599        if (mUseAntiAliasing) AntiAliasing(fbo, light, displayAfterAA);  
    596600         
    597601        /// store the current frame 
     
    599603 
    600604        // if it hasn't been done yet => just output the latest buffer 
    601         if (!useAntiAliasing || !displayAfterAA) 
     605        if (!mUseAntiAliasing || !displayAfterAA) 
    602606                Output(fbo);  
    603607 
     
    12661270                                                                  ) 
    12671271{ 
    1268         // light source not visible 
     1272        // light source visible? 
    12691273        if (!mSunVisiblePixels) return; 
    12701274 
     
    14371441 
    14381442 
    1439 void DeferredRenderer::SetSortSamples(bool sortSamples)  
     1443/*void DeferredRenderer::SetSortSamples(bool sortSamples)  
    14401444{ 
    14411445        mSortSamples = sortSamples;  
    1442 } 
     1446}*/ 
    14431447 
    14441448 
     
    14521456{ 
    14531457        mMaxDistance = maxDist; 
     1458} 
     1459 
     1460 
     1461void DeferredRenderer::SetUseToneMapping(bool toneMapping) 
     1462{ 
     1463        mUseToneMapping = toneMapping; 
     1464} 
     1465         
     1466 
     1467void DeferredRenderer::SetUseAntiAliasing(bool antiAliasing) 
     1468{ 
     1469        mUseAntiAliasing = antiAliasing; 
     1470} 
     1471 
     1472 
     1473void DeferredRenderer::SetUseDepthOfField(bool dof) 
     1474{ 
     1475        mUseDepthOfField = dof; 
     1476} 
     1477 
     1478 
     1479void DeferredRenderer::SetTemporalCoherenceFactorForSsao(float factor) 
     1480{ 
     1481        mTempCohFactor = factor; 
    14541482} 
    14551483 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3235 r3242  
    3636                and a buffer holding the difference of the pixel positions from the last frame. 
    3737 
    38                 Set useToneMapping to true if tone mapping should be applied 
    39                 Set useAntiAliasing true if some basic edge antialiasing should be performed 
    4038                If a shadowMap is specified that is not NULL, the shadow mapped shading algorithm is applied. 
    41  
     39        */ 
     40        void Render(FrameBufferObject *fbo,  
     41                                DirectionalLight *light, 
     42                                ShadowMap *shadowMap = NULL 
     43                                ); 
     44 
     45         
     46        enum SAMPLING_METHOD {SAMPLING_POISSON, SAMPLING_QUADRATIC, SAMPLING_DEFAULT}; 
     47        /** Use ssao or ssao + color bleeding 
     48        */ 
     49        enum SHADING_METHOD {DEFAULT, SSAO, GI}; 
     50        /** Set the samplig method for the indirect illumination 
     51        */ 
     52        void SetSamplingMethod(SAMPLING_METHOD s); 
     53        /** Set the shading method (SSAO, SSAO + color bleeding 
     54        */ 
     55        void SetShadingMethod(SHADING_METHOD s); 
     56        /** Sort the samples in order to provide faster texture accesses. 
     57        */ 
     58        //void SetSortSamples(bool sortSamples); 
     59        /** Sets ssao sample intensity. 
     60        */ 
     61        void SetSampleIntensity(float sampleIntensity); 
     62        /** Sets ssao kernel radius. 
     63        */ 
     64        void SetKernelRadius(float kernelRadius); 
     65        /** Sets ssao filter radius. 
     66        */ 
     67        void SetSsaoFilterRadius(float radius); 
     68        /** Passes the number of pixels that are visible from the sun. 
     69        */ 
     70        void SetSunVisiblePixels(int visiblePixels); 
     71        /** If true temporal coherence is used for ssao 
     72        */ 
     73        void SetUseTemporalCoherence(bool temporal); 
     74        /** if set to something other than -1 the current frame is stored on disc 
     75                using the specified frame number 
     76        */ 
     77        void SetSaveFrame(const std::string &suffix, int frameNumber); 
     78        /** Sets the maximal visible distance. 
     79        */ 
     80        void SetMaxDistance(float maxDist); 
     81        /**     Enables / disables toneMapping 
     82        */ 
     83        void SetUseToneMapping(bool toneMapping); 
     84         
     85        /** Enable antiAliasing if some basic edge antialiasing should be performed 
     86        */ 
     87        void SetUseAntiAliasing(bool antiAliasing); 
     88        /** Enables / disables depth of field. 
     89        */ 
     90        void SetUseDepthOfField(bool dof); 
     91        /** 
    4292                The temporal coherence factor is the maximal number of ssao samples that are accumulated 
    4393                without losing any prior sample information. 
     
    4696                1000 samples a flickering cannot be seen. 
    4797        */ 
    48         void Render(FrameBufferObject *fbo,  
    49                                 float tempCohFactor,  
    50                                 DirectionalLight *light, 
    51                                 bool useToneMapping, 
    52                                 bool useAntiAliasing, 
    53                                 ShadowMap *shadowMap = NULL 
    54                                 ); 
    55  
    56          
    57         enum SAMPLING_METHOD {SAMPLING_POISSON, SAMPLING_QUADRATIC, SAMPLING_DEFAULT}; 
    58         /** Use ssao or ssao + color bleeding 
    59         */ 
    60         enum SHADING_METHOD {DEFAULT, SSAO, GI}; 
    61         /** Set the samplig method for the indirect illumination 
    62         */ 
    63         void SetSamplingMethod(SAMPLING_METHOD s); 
    64         /** Set the shading method (SSAO, SSAO + color bleeding 
    65         */ 
    66         void SetShadingMethod(SHADING_METHOD s); 
    67         /** Sort the samples so texture access is faster 
    68         */ 
    69         void SetSortSamples(bool sortSamples); 
    70         /** Sets ssao sample intensity. 
    71         */ 
    72         void SetSampleIntensity(float sampleIntensity); 
    73         /** Sets ssao kernel radius. 
    74         */ 
    75         void SetKernelRadius(float kernelRadius); 
    76         /** Sets ssao filter radius. 
    77         */ 
    78         void SetSsaoFilterRadius(float radius); 
    79         /** Sets the number of visible pixels of the sun 
    80         */ 
    81         void SetSunVisiblePixels(int visiblePixels); 
    82         /** If true tem poral coherence is used for ssao 
    83         */ 
    84         void SetUseTemporalCoherence(bool temporal); 
    85         /** if set to something other than -1 the current frame is stored on disc 
    86                 using the specified frame number 
    87         */ 
    88         void SetSaveFrame(const std::string &suffix, int frameNumber); 
    89  
    90         void SetMaxDistance(float maxDist); 
     98        void SetTemporalCoherenceFactorForSsao(float factor); 
    9199 
    92100 
     
    116124 
    117125        void CombineSsao(FrameBufferObject *fbo); 
     126 
    118127        void CombineIllum(FrameBufferObject *fbo); 
    119128        /** Does some basic antialiasing (searches for edges using a edge detector, 
     
    210219 
    211220        float mMaxDistance; 
     221 
     222        float mTempCohFactor; 
     223        bool mUseToneMapping; 
     224        bool mUseAntiAliasing; 
     225        bool mUseDepthOfField;     
    212226}; 
    213227 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3238 r3242  
    381381#endif 
    382382 
    383         cout << "=== reading environment file ===" << endl << endl; 
    384383 
    385384        int returnCode = 0; 
     
    582581 
    583582 
    584         int cityEntities = LoadModel("vienna_full_hp.dem", dynamicObjects); 
     583/*      int cityEntities = LoadModel("vienna_full_hp.dem", dynamicObjects); 
    585584         
    586585        for (int i = (int)dynamicObjects.size() - cityEntities; i < (int)dynamicObjects.size(); ++ i) 
    587586                dynamicObjects[i]->GetTransform()->SetMatrix(transl); 
    588  
     587*/ 
    589588 
    590589        /////////// 
     
    12951294                deferredShader->SetSsaoFilterRadius(ssaoFilterRadius); 
    12961295                deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 
    1297                 deferredShader->SetSortSamples(sortSamples); 
     1296                //deferredShader->SetSortSamples(sortSamples); 
     1297                deferredShader->SetTemporalCoherenceFactorForSsao(ssaoTempCohFactor); 
     1298                deferredShader->SetUseToneMapping(useHDR); 
     1299                deferredShader->SetUseAntiAliasing(useAntiAliasing); 
     1300 
    12981301 
    12991302                if (recordFrames && replayPath) 
     
    13071310 
    13081311                ShadowMap *sm = showShadowMap ? shadowMap : NULL; 
    1309                 deferredShader->Render(fbo, ssaoTempCohFactor, light, useHDR, useAntiAliasing, sm); 
     1312                deferredShader->Render(fbo, light, sm); 
    13101313        } 
    13111314 
Note: See TracChangeset for help on using the changeset viewer.