Changeset 2736


Ignore:
Timestamp:
06/04/08 11:13:41 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh

    r2735 r2736  
    4343-gvs_initial_samples=16 \ 
    4444-gvs_max_viewcells=3 \ 
    45 -gvs_min_contribution=100 \ 
     45-gvs_min_contribution=200 \ 
    4646-gvs_per_viewcell=true \ 
    4747-preprocessor_detect_empty_viewspace+ \ 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp

    r2731 r2736  
    840840GlRenderer::RenderKdNode(KdNode *node) 
    841841{ 
    842   if (node->IsLeaf())  
    843         { 
    844 #if !EVAL_ERROR 
     842        if (node->IsLeaf())  
     843        { 
    845844                RenderKdLeaf(static_cast<KdLeaf *>(node)); 
    846 #else 
    847                 KdLeaf *leaf = static_cast<KdLeaf *>(node); 
    848                 for (int i=0; i < leaf->mObjects.size(); i++)  
    849                   { 
    850                         RenderIntersectable(leaf->mObjects[i]); 
    851                          
    852                   } 
    853 #endif 
     845 
    854846        }  
    855847        else  
     
    19461938 
    19471939 
    1948  
    1949 } 
     1940void GlRenderer::_RenderColoredPvs(const ObjectPvs &pvs) 
     1941{ 
     1942        // note: could be done more efficiently using color buffers 
     1943        ObjectPvsIterator it = pvs.GetIterator(); 
     1944 
     1945        PvsData pvsData; 
     1946 
     1947        while (it.HasMoreEntries()) 
     1948        { 
     1949                Intersectable *obj = it.Next(pvsData); 
     1950 
     1951                RgbColor color; 
     1952 
     1953                //cerr << "sumpdf: " << pvsData.mSumPdf << endl; 
     1954                if (1)//mUseRandomColorPerPvsObject) 
     1955                { 
     1956                        if (obj->Type() == Intersectable::KD_INTERSECTABLE) 
     1957                        { 
     1958                                KdIntersectable *kdint = static_cast<KdIntersectable *>(obj); 
     1959 
     1960                                if (kdint->mGenericIdx == -1) 
     1961                                { 
     1962                                        kdint->mGenericIdx = (int)mColors.size(); 
     1963                                        mColors.push_back(RandomColor(0, 1)); 
     1964                                } 
     1965                                color = mColors[kdint->mGenericIdx]; 
     1966                        } 
     1967                }  
     1968                else 
     1969                { 
     1970                        color = RainbowColorMapping(log10(pvsData.mSumPdf + 1)); 
     1971                } 
     1972 
     1973                glColor3f(color.r, color.g, color.b); 
     1974 
     1975                mUseForcedColors = true; 
     1976                RenderIntersectable(obj); 
     1977                mUseForcedColors = false; 
     1978        } 
     1979} 
     1980 
     1981 
     1982 
     1983} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h

    r2730 r2736  
    88#include "Renderer.h" 
    99#include "Beam.h" 
     10#include <vector> 
     11#include "Material.h" 
    1012 
    1113 
     
    221223  bool GetUseVbos() const { return mUseVbos; } 
    222224 
     225  /** Render pvs using false colors. 
     226  */ 
     227  void _RenderColoredPvs(const ObjectPvs &pvs); 
    223228 
    224229public: 
     
    296301 
    297302        int mRenderedNodes; 
     303 
     304        std::vector<RgbColor> mColors; 
    298305}; 
    299306 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2735 r2736  
    192192        else 
    193193        { 
     194                float scale = 0.01f; 
     195 
    194196                if (0) 
    195197                        CastRayBundle4(simpleRay, reverseRays, mViewCellsManager->GetViewSpaceBox()); 
    196198                else 
    197                         CastRayBundle16(simpleRay, reverseRays); 
     199                        CastRayBundle16(simpleRay, reverseRays, scale); 
    198200        } 
    199201 
     
    502504                                                                                  1.0f); 
    503505                         
    504                         GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0); 
     506                        GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0, 0.01f); 
    505507                } 
    506508                else 
     
    625627                                                                  SamplingStrategy::GVS, 1.0f); 
    626628 
    627         GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0); 
     629        GenerateJitteredRays(simpleRays, mainRay, numRandomRays, 0, 0.01f); 
    628630        //GenerateRays(numRandomRays, *mDistribution, simpleRays, sInvalidSamples); 
    629631 
     
    799801        generationTimer.Entry(); 
    800802 
    801         if (mUseProbablyVisibleSampling && (RandomValue(0, 1) > 0.5)) 
     803        if (mUseProbablyVisibleSampling)// && (RandomValue(0, 1) > 0.5)) 
    802804        { 
    803805                ProbablyVisibleDistribution distr(*this, mCurrentViewCell, &mProbablyVisibleTriangles); 
     
    827829        else 
    828830        { 
     831                float scale = 0.1f; 
    829832                if (0) 
    830833                        // casting bundles of 4 rays generated from the simple rays 
    831834                        CastRayBundles4(simpleRays, vssRays); 
    832835                else 
    833                         CastRayBundles16(simpleRays, vssRays); 
     836                        CastRayBundles16(simpleRays, vssRays, scale); 
    834837        } 
    835838 
     
    18201823 
    18211824 
    1822 void GvsPreprocessor::CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays) 
     1825void GvsPreprocessor::CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays, float scale) 
    18231826{ 
    18241827        static SimpleRayContainer simpleRays; 
     
    18261829 
    18271830        simpleRays.push_back(ray); 
    1828         GenerateJitteredRays(simpleRays, ray, 15, 0); 
     1831        GenerateJitteredRays(simpleRays, ray, 15, 0, scale); 
    18291832 
    18301833        CastRays(simpleRays, vssRays, false, false); 
     
    18321835 
    18331836 
    1834 void GvsPreprocessor::CastRayBundles16(const SimpleRayContainer &rays, VssRayContainer &vssRays) 
     1837void GvsPreprocessor::CastRayBundles16(const SimpleRayContainer &rays, VssRayContainer &vssRays, float scale) 
    18351838{ 
    18361839        SimpleRayContainer::const_iterator it, it_end = rays.end(); 
    18371840 
    18381841        for (it = rays.begin(); it != it_end; ++ it) 
    1839                 CastRayBundle16(*it, vssRays); 
     1842                CastRayBundle16(*it, vssRays, scale); 
    18401843} 
    18411844 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h

    r2735 r2736  
    258258        void CastRayBundles4(const SimpleRayContainer &rays, VssRayContainer &vssRays); 
    259259         
    260         void CastRayBundles16(const SimpleRayContainer &rays, VssRayContainer &vssRays); 
     260        void CastRayBundles16(const SimpleRayContainer &rays, VssRayContainer &vssRays, float scale); 
    261261 
    262262        /** Generates a ray bundle of 4 jittered rays and casts them using optimized 4 eye ray casting. 
     
    270270        void Cast4Rays(float *dist, Vector3 *dirs, Vector3 *origs, VssRayContainer &vssRays, const AxisAlignedBox3 &box); 
    271271 
    272         void CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays); 
     272        void CastRayBundle16(const SimpleRay &ray, VssRayContainer &vssRays, float scale); 
    273273 
    274274        virtual void ComputeRenderError(); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp

    r2729 r2736  
    13281328                                                                                const SimpleRay &mainRay, 
    13291329                                                                                int number, 
    1330                                                                                 int pertubType) const 
    1331 { 
    1332         //rayBundle.push_back(mainRay); 
    1333         //const float pertubOrigin = 0.0f; 
    1334         const float pertubDir = 0.01f; 
     1330                                                                                int pertubType, 
     1331                                                                                float scale) const 
     1332{ 
    13351333        Vector3 pertub; 
    13361334 
    13371335        for (int i = 0; i < number; ++ i) 
    13381336        { 
    1339                 pertub.x = RandomValue(-pertubDir, pertubDir); 
    1340                 pertub.y = RandomValue(-pertubDir, pertubDir); 
    1341                 pertub.z = RandomValue(-pertubDir, pertubDir); 
     1337                pertub.x = RandomValue(-scale, scale); 
     1338                pertub.y = RandomValue(-scale, scale); 
     1339                pertub.z = RandomValue(-scale, scale); 
    13421340 
    13431341                Vector3 newDir = mainRay.mDirection + pertub; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h

    r2726 r2736  
    144144                                                         const SimpleRay &mainRay, 
    145145                                                         int number, 
    146                                                          int shuffleType) const; 
     146                                                         int shuffleType, 
     147                                                         float scale) const; 
    147148 
    148149        virtual void CastRays(SimpleRayContainer &rays, 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp

    r2730 r2736  
    377377                        im.save(qstr, "PNG"); 
    378378 
    379                         if (0) 
     379                        if (1) 
    380380                        { 
    381381                                /////////// 
     
    391391 
    392392                                KdNode::NewMail2(); 
    393                                 //Intersectable::NewMail(); 
    394393 
    395394                                ++ mCurrentFrame; 
    396395 
    397396                                // render pvs once 
    398                                 RenderPvs(pvs); 
     397                                //RenderPvs(pvs); 
     398                                _RenderColoredPvs(pvs); 
    399399                                // hack for gvs visualization 
    400400                                //RenderTrianglePvs(); 
     
    405405 
    406406                                im = toImage(); 
    407                                 sprintf_s(filename, "error-frame-%04d-%04d-%08d-pvs.png", mFrame, viewcell->GetId(), pixelCount); 
     407                                sprintf_s(filename, "error-frame-%05d-%05d-%08d-pvs.png", viewcell->GetId(), mFrame, pixelCount); 
    408408                                str = mSnapPrefix + filename; 
    409409                                qstr = str.c_str(); 
     
    713713                                _RenderPvs(); 
    714714                        else 
    715                                 _RenderColoredPvs(); 
     715                                _RenderColoredPvs(mPvsCache.mPvs); 
    716716                } 
    717717 
     
    26342634 
    26352635 
    2636 void QtGlRendererWidget::_RenderColoredPvs() 
    2637 { 
    2638         // note: could be done more efficiently using color buffers 
    2639         mPvsSize = mPvsCache.mPvs.GetSize(); 
    2640  
    2641         ObjectPvsIterator it = mPvsCache.mPvs.GetIterator(); 
    2642  
    2643         PvsData pvsData; 
    2644  
    2645         while (it.HasMoreEntries()) 
    2646         { 
    2647                 Intersectable *obj = it.Next(pvsData); 
    2648  
    2649                 RgbColor color; 
    2650  
    2651                 //cerr << "sumpdf: " << pvsData.mSumPdf << endl; 
    2652                 if (mUseRandomColorPerPvsObject) 
    2653                 { 
    2654                         if (obj->Type() == Intersectable::KD_INTERSECTABLE) 
    2655                         { 
    2656                                 KdIntersectable *kdint = static_cast<KdIntersectable *>(obj); 
    2657  
    2658                                 if (kdint->mGenericIdx == -1) 
    2659                                 { 
    2660                                         kdint->mGenericIdx = (int)mColors.size(); 
    2661                                         mColors.push_back(RandomColor(0, 1)); 
    2662                                 } 
    2663                                 color = mColors[kdint->mGenericIdx]; 
    2664                         } 
    2665                 }  
    2666                 else 
    2667                 { 
    2668                         color = RainbowColorMapping(mTransferFunction * log10(pvsData.mSumPdf + 1)); 
    2669                 } 
    2670  
    2671                 glColor3f(color.r, color.g, color.b); 
    2672  
    2673                 mUseForcedColors = true; 
    2674                 RenderIntersectable(obj); 
    2675                 mUseForcedColors = false; 
    2676         } 
    2677 } 
    2678  
    26792636 
    26802637void QtGlRendererWidget::UpdateDynamicObjects() 
  • GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h

    r2730 r2736  
    239239        int mCurrentPvsCost; 
    240240 
    241         vector<RgbColor> mColors; 
    242  
    243241        bool mUseRandomColorPerPvsObject; 
    244242 
     
    590588        */ 
    591589        void _RenderPvs(); 
    592         /** Render pvs using false colors. 
    593         */ 
    594         void _RenderColoredPvs(); 
    595590 
    596591        float ComputeRenderCost(ViewCell *vc); 
Note: See TracChangeset for help on using the changeset viewer.