Ignore:
Timestamp:
06/02/08 19:02:06 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r2729 r2730  
    1414#include "IntersectableWrapper.h" 
    1515#include "Timer/PerfTimer.h" 
     16#include "Vector2.h" 
     17#include "RndGauss.h" 
     18 
    1619 
    1720 
     
    13261329        // export the preprocessed information to a file 
    13271330        if (0 && mExportVisibility) 
    1328         { 
    13291331                ExportPreprocessedData(mVisibilityFileName); 
    1330         } 
    13311332         
    13321333        // compute the pixel error of this visibility solution 
    1333         if (mEvaluatePixelError) 
    1334         { 
     1334        if (0 && mEvaluatePixelError) 
    13351335                ComputeRenderError(); 
    1336         } 
    13371336 
    13381337        return true; 
     
    14241423        mGvsStats.mGvsSamples = 0; 
    14251424 
     1425        //renderer->mPvsStat.currentPass = 0; 
     1426        mPass = 0; 
     1427 
    14261428        int oldContribution = 0; 
    14271429        int passSamples = 0; 
     
    15071509                        mGvsStats.mPassContribution = 0; 
    15081510                        passSamples = 0; 
     1511                         
     1512                        // compute the pixel error of this visibility solution 
     1513                        if (mEvaluatePixelError) 
     1514                                ComputeRenderError(); 
    15091515                } 
    15101516        } 
     
    16271633        cout << "raw cast time          : " << rawCastTime << endl; 
    16281634 
    1629         float randomRaysPerSec = mGvsStats.mRandomSamples / (1e6f * initialTime); 
    1630         float gvsRaysPerSec = mGvsStats.mGvsSamples / (1e6f * gvsTime); 
    1631         float rawRaysPerSec = mGvsStats.mPerViewCellSamples / (1e6f * rawCastTime); 
     1635        double randomRaysPerSec = mGvsStats.mRandomSamples / (1e6 * initialTime); 
     1636        double gvsRaysPerSec = mGvsStats.mGvsSamples / (1e6 * gvsTime); 
     1637        double rawRaysPerSec = mGvsStats.mPerViewCellSamples / (1e6 * rawCastTime); 
    16321638 
    16331639        cout << "cast " << randomRaysPerSec << " M random rays/s: " << endl; 
     
    18041810} 
    18051811 
    1806 } 
     1812 
     1813void GvsPreprocessor::ComputeRenderError() 
     1814{ 
     1815        // compute rendering error       
     1816        if (renderer && renderer->mPvsStatFrames)  
     1817        { 
     1818                if (!mViewCellsManager->GetViewCellPointsList()->empty())  
     1819                { 
     1820                        ViewCellPointsList *vcPoints = mViewCellsManager->GetViewCellPointsList(); 
     1821                        ViewCellPointsList::const_iterator vit = vcPoints->begin(),     vit_end = vcPoints->end(); 
     1822 
     1823                        SimpleRayContainer viewPoints; 
     1824 
     1825                        for (; vit != vit_end; ++ vit)  
     1826                        { 
     1827                                ViewCellPoints *vp = *vit; 
     1828                                 
     1829                                SimpleRayContainer::const_iterator rit = vp->second.begin(), rit_end = vp->second.end(); 
     1830                         
     1831                                for (; rit!=rit_end; ++rit) 
     1832                                { 
     1833                                        ViewCell *vc = mViewCellsManager->GetViewCell((*rit).mOrigin); 
     1834                                        if (vc == mCurrentViewCell) 
     1835                                                viewPoints.push_back(*rit); 
     1836                                } 
     1837                        } 
     1838 
     1839                        renderer->mPvsErrorBuffer.clear(); 
     1840 
     1841                        if (viewPoints.size() != renderer->mPvsErrorBuffer.size())  
     1842                        { 
     1843                                renderer->mPvsErrorBuffer.resize(viewPoints.size()); 
     1844                                renderer->ClearErrorBuffer(); 
     1845                        } 
     1846 
     1847                        cout << "evaluating list of " << viewPoints.size() << " pts" << endl; 
     1848                        renderer->EvalPvsStat(viewPoints); 
     1849                }  
     1850                else 
     1851                { 
     1852                        cout << "evaluating random points" << endl; 
     1853                        renderer->EvalPvsStat(); 
     1854                } 
     1855 
     1856                mStats << 
     1857                        "#AvgPvsRenderError\n" <<renderer->mPvsStat.GetAvgError()<<endl<< 
     1858                        "#AvgPixelError\n" <<renderer->GetAvgPixelError()<<endl<< 
     1859                        "#MaxPixelError\n" <<renderer->GetMaxPixelError()<<endl<< 
     1860                        "#MaxPvsRenderError\n" <<renderer->mPvsStat.GetMaxError()<<endl<< 
     1861                        "#ErrorFreeFrames\n" <<renderer->mPvsStat.GetErrorFreeFrames()<<endl<< 
     1862                        "#AvgRenderPvs\n" <<renderer->mPvsStat.GetAvgPvs()<<endl; 
     1863        } 
     1864} 
     1865 
     1866 
     1867SimpleRay GvsPreprocessor::GenerateJitteredSample(const SimpleRay &sray) 
     1868{ 
     1869        // mutate the origin 
     1870        Vector3 d = sray.mDirection; 
     1871   
     1872        // Compute right handed coordinate system from direction 
     1873        Vector3 U, V; 
     1874        d.RightHandedBase(U, V); 
     1875 
     1876        float rr[2]; 
     1877 
     1878        rr[0] = RandomValue(0, 1); 
     1879        rr[1] = RandomValue(0, 1); 
     1880 
     1881        Vector2 vr2(rr[0], rr[1]); 
     1882        Vector2 gaussvec2; 
     1883 
     1884        const float sigma = 0.2f; 
     1885 
     1886        GaussianOn2D(vr2, sigma, // input 
     1887                         gaussvec2); // output 
     1888         
     1889        Vector3 shift = gaussvec2.xx * U + gaussvec2.yy * V; 
     1890         
     1891        d += shift; 
     1892   
     1893        d.Normalize(); 
     1894 
     1895        return SimpleRay(sray.mOrigin, d, SamplingStrategy::GVS, 1.0f); 
     1896} 
     1897 
     1898 
     1899} 
Note: See TracChangeset for help on using the changeset viewer.