Changeset 3246


Ignore:
Timestamp:
01/04/09 21:48:45 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp

    r3161 r3246  
    122122                        } 
    123123 
    124                         ++ dummy; 
    125124                        if (!texcoords.empty()) 
    126125                        { 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj

    r3238 r3246  
    154154                                GenerateDebugInformation="true" 
    155155                                SubSystem="1" 
     156                                LargeAddressAware="2" 
    156157                                OptimizeReferences="2" 
    157158                                EnableCOMDATFolding="2" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp

    r3243 r3246  
    2020#define TYPE_LEAF -3 
    2121 
    22 //const int maxVertices = 20000000; 
    23  
     22 
     23static const float sScale = 0.05f; 
    2424 
    2525 
     
    125125 
    126126 
    127                         if (!normals.empty()) 
     127                        /*if (!normals.empty()) 
    128128                        { 
    129129                                faceNormals.push_back(normals[nIndices[idx1]]); 
     
    144144                                faceNormals.push_back(n); 
    145145                                faceNormals.push_back(n); 
    146                         } 
     146                        }*/ 
    147147 
    148148                        if (!texCoords.empty()) 
     
    196196        { 
    197197                // convert to our camera system: change y and z 
    198                 geom->mVertices[i].x =  vertices[i].x; 
    199                 geom->mVertices[i].y = -vertices[i].z; 
    200                 geom->mVertices[i].z =  vertices[i].y; 
    201          
    202                 geom->mNormals[i].x =  normals[i].x; 
    203                 geom->mNormals[i].y = -normals[i].z; 
    204                 geom->mNormals[i].z =  normals[i].y; 
    205  
     198                geom->mVertices[i] =  vertices[i]; 
     199                geom->mNormals[i] =  normals[i]; 
     200                 
    206201                if (i < geom->mTexcoordCount) 
    207202                { 
     
    249244        UpdateBvh(mRoot); 
    250245 
    251         cout << "bvh: " << mRoot->first << " " << mRoot->last << " bb: " << mRoot->box << endl; 
     246        cout << "loading bvh, bb: " << mRoot->box << endl; 
    252247 
    253248        cout << "writing scene" << endl; 
     
    277272        vector<TexCoord> texCoords; 
    278273 
    279         if (ReadSimpleObj(filename, vertices, normals, texCoords)) 
    280         //if (ReadObj(filename, vertices, normals, texCoords))  
     274        //if (ReadSimpleObj(filename, vertices, normals, texCoords)) 
     275        if (ReadObj(filename, vertices, normals, texCoords))  
    281276        { 
    282277                ConstructBvhObjects(vertices, normals, texCoords); 
     
    297292        if ((file = fopen(filename.c_str(), "r")) == NULL) return false; 
    298293         
    299         VertexArray tempVertices;  
     294        VertexArray tempVertices; 
     295        //tempVertices.reserve(11000000); 
     296        //tempVertices.reserve(13000000 * 3); 
     297 
    300298        VertexArray tempNormals; 
    301299        vector<TexCoord> tempTexcoords; 
     
    307305        char str[len]; 
    308306 
    309         while (fgets(str, len, file) != NULL) 
    310         { 
    311                 if (line % 500000 == 0) 
    312                         cout << line << " " << str << endl; 
    313  
    314                 ++ line; 
    315  
    316                 switch (str[0]) 
    317                 { 
    318                 case 'v': // vertex or normal 
    319                         { 
    320                                 float x, y, z; 
    321  
    322                                 //if (tempVertices.size() >= maxVertices * 3) continue; 
    323  
    324                                 switch (str[1])  
    325                                 { 
    326                                 case 'n' : 
    327                                         sscanf(str + 2, "%f %f %f", &x, &y, &z); 
    328                                         tempNormals.push_back(CHCDemoEngine::Vector3(x, y, z)); 
    329                                         break; 
    330                                 case 't': 
    331                                         sscanf(str + 2, "%f %f", &x, &y); 
    332                                         tempTexcoords.push_back(pair<float, float>(x, y)); 
    333                                         break; 
    334                                 default: 
    335                                         sscanf(str + 1, "%f %f %f", &x, &y, &z); 
    336                                         const float scale = 1.0f; 
    337                                         //const float scale = 0.1f; 
    338                                         tempVertices.push_back(CHCDemoEngine::Vector3(x * scale, y * scale, z * scale)); 
    339                                         //cout <<"v " << x << " " << y << " "<< z << " "; 
    340                                 } 
    341                                 break; 
    342                         } 
    343                 case 'f':  
    344                         { 
    345                                 ////////// 
    346                                 //-- indices in the current line 
    347  
    348                                 //if (tempVertices.size() >= maxVertices * 3) continue; 
    349                                 LoadIndices(str,  
    350                                                 tempVertices, tempNormals, tempTexcoords,  
    351                                                 vertices, normals, texcoords); 
    352  
    353                                 break; 
    354                         }   
    355                         break; 
    356                 default: 
    357                         // throw away line 
    358                         break; 
    359                 } 
    360         } 
    361  
    362         fclose(file); 
    363  
    364         return !vertices.empty(); 
    365 } 
    366  
    367  
    368 bool VisibilitySolutionConverter::ReadSimpleObj(const string &filename, 
    369                                                                                                 VertexArray &vertices, 
    370                                                                                                 VertexArray &normals, 
    371                                                                                                 vector<TexCoord> &texcoords) 
    372 { 
    373307        const string binFilename = ReplaceSuffix(filename, ".obj", ".bn"); 
    374308 
    375         if (!ReadBinObj(binFilename, vertices, 1)) 
     309        if (!ReadBinObj(binFilename, vertices)) 
    376310        { 
    377311                cout << "binary dump " << binFilename << " not available, loading ascii obj" << endl; 
    378  
    379                 FILE *file; 
    380                 if ((file = fopen(filename.c_str(), "r")) == NULL) return false; 
    381  
    382                 int line = 0; 
    383                 const int len = 10000; 
    384                 char str[len]; 
    385312 
    386313                while (fgets(str, len, file) != NULL) 
    387314                { 
    388315                        if (line % 500000 == 0) 
    389                                 cout << line << " " << str << endl; 
     316                                cout << line << " " << str; 
    390317 
    391318                        ++ line; 
     
    397324                                        float x, y, z; 
    398325 
    399                                         sscanf(str + 1, "%f %f %f", &x, &y, &z); 
    400                                         const float scale = 1.0f; 
    401                                         vertices.push_back(CHCDemoEngine::Vector3(x * scale, y * scale, z * scale)); 
     326                                        //if (tempVertices.size() >= maxVertices * 3) continue; 
     327 
     328                                        switch (str[1])  
     329                                        { 
     330                                        case 'n' : 
     331                                                sscanf(str + 2, "%f %f %f", &x, &y, &z); 
     332                                                tempNormals.push_back(CHCDemoEngine::Vector3(x, -z, y)); 
     333                                                break; 
     334                                        case 't': 
     335                                                sscanf(str + 2, "%f %f", &x, &y); 
     336                                                tempTexcoords.push_back(pair<float, float>(x, y)); 
     337                                                break; 
     338                                        default: 
     339                                                sscanf(str + 1, "%f %f %f", &x, &y, &z); 
     340                                                 
     341                                                CHCDemoEngine::Vector3 v = CHCDemoEngine::Vector3(x, -z, y) * sScale; 
     342                                                tempVertices.push_back(v); 
     343                                                //cout <<"v " << x << " " << y << " "<< z << " "; 
     344                                        } 
    402345                                        break; 
    403346                                } 
     347                        case 'f':  
     348                                { 
     349                                        ////////// 
     350                                        //-- indices in the current line 
     351 
     352                                        //if (tempVertices.size() >= maxVertices * 3) continue; 
     353                                        LoadIndices(str,  
     354                                                tempVertices, tempNormals, tempTexcoords,  
     355                                                vertices, normals, texcoords); 
     356 
     357                                        break; 
     358                                }   
     359                                break; 
    404360                        default: 
    405361                                // throw away line 
     
    408364                } 
    409365 
    410                 fclose(file); 
    411  
    412                 cout << "dumping " << vertices.size() << " to binary " << binFilename << endl; 
    413366                ExportBinObj(binFilename, vertices); 
    414367        } 
    415  
    416         for (size_t i = 0; i < vertices.size(); i += 3) 
    417         { 
    418                 // no face normals? => create normals 
    419                 const CHCDemoEngine::Triangle3  
    420                         tri(vertices[i], vertices[i + 1], vertices[i + 2]); 
    421  
    422                 const CHCDemoEngine::Vector3 n = tri.GetNormal(); 
    423  
    424                 normals.push_back(n); 
    425                 normals.push_back(n); 
    426                 normals.push_back(n); 
    427         } 
     368        else if (0) 
     369        { 
     370                cout << "creating normals" << endl; 
     371                normals.reserve(vertices.size()); 
     372 
     373                for (size_t i = 0; i < vertices.size(); i += 3) 
     374                { 
     375                        // no face normals? => create normals 
     376                        const CHCDemoEngine::Triangle3  
     377                                tri(vertices[i], vertices[i + 1], vertices[i + 2]); 
     378 
     379                        const CHCDemoEngine::Vector3 n = tri.GetNormal(); 
     380 
     381                        normals.push_back(n); 
     382                        normals.push_back(n); 
     383                        normals.push_back(n); 
     384                } 
     385        } 
     386 
     387        cout << "finished creating normals" << endl; 
     388 
     389        fclose(file); 
    428390 
    429391        return !vertices.empty(); 
    430392} 
    431  
    432393 
    433394 
     
    554515                                                                                                          const vector<TexCoord> &texCoords) 
    555516{ 
    556         VertexArray _vertices; 
    557         VertexArray _normals; 
    558         vector<TexCoord> _texCoords; 
    559  
    560517        CHCDemoEngine::AxisAlignedBox3 testBox; 
    561518        testBox.Initialize(); 
     
    566523        } 
    567524 
    568         cout << "testbox: " << testBox << endl; 
     525        cout << "geometry bounds: " << testBox << endl; 
    569526 
    570527        mGeometry.reserve(mBvhLeaves.size()); 
     
    576533                BvhLeaf *node = mBvhLeaves[i]; 
    577534 
     535                VertexArray _vertices;   
     536                VertexArray _normals; 
     537                vector<TexCoord> _texCoords; 
     538 
     539                const int size = node->last - node->first + 1; 
     540 
     541                _vertices.reserve(size); 
     542                _normals.reserve(size); 
     543 
     544                //cout << "vtx: " << size << endl; 
    578545                for (int j = node->first; j <= node->last; ++ j) 
    579546                { 
     
    583550                        { 
    584551                                _vertices.push_back(vertices[idx + k]); 
    585                                 _normals.push_back(normals[idx + k]); 
     552                                //_normals.push_back(normals[idx + k]); 
    586553                                //_texCoords.push_back(texCoords[idx + k]); 
    587554                        } 
     555 
     556                        // no face normals? => create normals 
     557                        const CHCDemoEngine::Triangle3  
     558                                tri(vertices[idx], vertices[idx + 1], vertices[idx + 2]); 
     559 
     560                        const CHCDemoEngine::Vector3 n = tri.GetNormal(); 
     561 
     562                        _normals.push_back(n); 
     563                        _normals.push_back(n); 
     564                        _normals.push_back(n); 
    588565                } 
    589566 
     
    595572                node->last = (int)mGeometry.size() - 1; 
    596573 
    597                 _vertices.clear(); 
    598                 _normals.clear(); 
    599                 _texCoords.clear(); 
     574                //_vertices.clear(); 
     575                //_normals.clear(); 
     576                //_texCoords.clear(); 
    600577        } 
    601578} 
     
    621598        // load triangle ids 
    622599        size_t numTriangles = buffer[2]; 
     600        mGlobalTriangleIds.reserve(numTriangles); 
    623601 
    624602        for (size_t i = 0; i < numTriangles; ++i)  
     
    778756 
    779757bool VisibilitySolutionConverter::ReadBinObj(const string &filename, 
    780                                                                                          VertexArray &vertices, 
    781                                                                                          float scale) 
     758                                                                                         VertexArray &vertices 
     759                                                                                         ) 
    782760{ 
    783761        igzstream inStream(filename.c_str()); 
     
    862840        stream.write(reinterpret_cast<char *>(&nodeType), sizeof(int)); 
    863841 
    864         CHCDemoEngine::Vector3 bMin = node->box.Min(); 
    865         CHCDemoEngine::Vector3 bMax = node->box.Max(); 
     842        CHCDemoEngine::AxisAlignedBox3 box = node->box; 
     843        //box.Scale(sScale); 
     844 
     845        CHCDemoEngine::Vector3 bMin = box.Min(); 
     846        CHCDemoEngine::Vector3 bMax = box.Max(); 
    866847 
    867848        stream.write(reinterpret_cast<char *>(&(node->first)), sizeof(int)); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h

    r3243 r3246  
    120120                                 VertexArray &normals, 
    121121                                 std::vector<TexCoord> &texcoords); 
    122          
    123         bool ReadSimpleObj(const std::string &filename, 
    124                                VertexArray &vertices, 
    125                                            VertexArray &normals, 
    126                                            std::vector<TexCoord> &texcoords); 
    127122 
    128123        bool ReadBinObj(const std::string &filename, 
    129                     VertexArray &vertices, 
    130                                         float scale); 
     124                    VertexArray &vertices); 
    131125 
    132126        bool WriteBinObj(const std::string &filename, 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3245 r3246  
    77# misc stuff 
    88 
    9 filename=vienna_full_hp 
     9#filename=vienna_full_hp 
    1010useLODs=1 
    1111# shadow map size 
     
    1616statsFilename=mystats.log 
    1717 
     18# use potentially viible sets? 
     19usePvs=0 
     20 
     21# if using pvs, this specifies the name of the visibility solutin 
    1822#visibilitySolution=vienna_full-8x3-refu 
    1923visibilitySolution=vienna_full-8x3-pgv 
    20 #visibilitySolution=vienna_full-8x3-spgvu 
     24 
     25 
    2126 
    2227############ 
     
    3540 
    3641# move speed 
    37 keyForwardMotion=5.0f 
    38 keyRotation=0.5f 
     42#keyForwardMotion=5.0f 
     43#keyRotation=0.5f 
    3944#keyForwardMotion=20.0f 
    40 #keyRotation=1.5f 
     45keyRotation=1.5f 
    4146 
    4247# initial camera position 
     
    5055#lightDirection=-0.8f 1.0f -0.7f 
    5156lightDirection=-0.3f 0.2f -0.7f 
     57 
     58########################### 
     59## powerplant options 
     60 
     61filename=PowerPlantM 
     62 
     63keyForwardMotion=200.0f 
     64mouseMotion=1.0f; 
     65visibilitySolution=power-plant-2c-xx-1000b-pgv2 
     66camPosition=-1320.57 -6306.34 3603 
     67camDirection=0.292156 0.9556 0.0383878 
    5268 
    5369 
     
    93109 
    94110# use full resolution ssao (vs. half resoltion) 
    95 ssaoUseFullResolution=1 
     111ssaoUseFullResolution=0 
    96112# ssao kernel radius 
    97113#ssaoKernelRadius=8e-1f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3242 r3246  
    7373 
    7474// ssao random spherical samples 
    75 //static Sample2 samples2[NUM_SAMPLES]; 
    76 #define NUM_PRECOMPUTED_SAMPLES 240 
    77 static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 
     75static Sample2 samples2[NUM_SAMPLES]; 
     76//#define NUM_PRECOMPUTED_SAMPLES 240 
     77//static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 
    7878// pcf samples 
    7979static Sample2 pcfSamples[NUM_PCF_TABS]; 
     
    210210        case DeferredRenderer::SAMPLING_QUADRATIC: 
    211211                { 
    212                         static QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 
     212                        //static QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 
     213                        static QuadraticDiscSampleGenerator2D g(NUM_SAMPLES, 1.0f); 
    213214                        g.Generate((float *)samples2); 
    214215                } 
     
    753754                // in the first case, the sample patterns look nicer, but the kernel 
    754755                // needs longer to converge 
    755                 if (currentPos + NUM_SAMPLES >= NUM_PRECOMPUTED_SAMPLES) 
    756                 { 
     756                //if (currentPos + NUM_SAMPLES >= NUM_PRECOMPUTED_SAMPLES)      { 
    757757                        currentPos = 0; 
    758758                        GenerateSamples(mSamplingMethod); 
    759                 } 
     759                //} 
    760760 
    761761                //if (mSortSamples) { SortSamples(); } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp

    r3193 r3246  
    108108        Vector3 position = camera->GetPosition(); 
    109109 
    110         const float scaleFactor = 80.0f; 
    111         //const float scaleFactor = 5.0f; 
     110        // scale the sky dome so no intersection with the scene is visible 
     111        //const float scaleFactor = 80.0f; 
     112        const float scaleFactor = 200.0f; 
    112113 
    113114        position.z -= 3.0f * scaleFactor; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.cpp

    r3245 r3246  
    1313 
    1414#define VIEWCELLS_VERSION 1.0f 
     15 
     16static const float sScale = 0.05f; 
     17 
    1518 
    1619namespace CHCDemoEngine 
     
    7578        } 
    7679 
     80        AxisAlignedBox3 box; 
    7781        // get the bounding box 
    7882        // exchange x and y coordinates and recompute box 
    79         fread(&mBox, sizeof(AxisAlignedBox3), 1, fr); 
     83        fread(&box, sizeof(AxisAlignedBox3), 1, fr); 
    8084 
    81         Vector3 v1(mBox.Min().x, -mBox.Min().z, mBox.Min().y); 
    82         Vector3 v2(mBox.Max().x, -mBox.Max().z, mBox.Max().y); 
     85        box.Scale(sScale); 
     86 
     87        Vector3 v1(box.Min().x, -box.Min().z, box.Min().y); 
     88        Vector3 v2(box.Max().x, -box.Max().z, box.Max().y); 
    8389         
    8490        mBox.Initialize(); 
     
    119125                        float mypos; 
    120126                        fread(&mypos, sizeof(float), 1, fr); 
     127 
     128                        mypos *= sScale; 
     129 
    121130                        // changed coordinate system must be considered also here 
    122131                        if (node->mAxis == 1)  
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp

    r3245 r3246  
    175175        { 
    176176                vcTechnique.Render(mRenderState); 
    177                 Visualization::RenderBoxForViz(mViewCell->GetBox()); 
     177                RenderBoxForViz(mViewCell->GetBox()); 
    178178        } 
    179179 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3245 r3246  
    113113/// max depth where candidates for tighter bounds are searched 
    114114int maxDepthForTestingChildren = 3; 
    115  
     115/// use full resolution for ssao or half 
    116116bool ssaoUseFullResolution = false; 
    117117 
     
    140140 
    141141ViewCellsTree *viewCellsTree = NULL; 
     142ViewCell *viewCell = NULL; 
    142143 
    143144static int globalVisibleId = 0; 
    144145 
    145 ViewCell *viewCell = NULL; 
    146146 
    147147 
     
    255255bool useLenseFlare = true; 
    256256 
     257bool usePvs = false; 
     258 
     259 
    257260PerfTimer frameTimer, algTimer; 
    258261/// the performance graph window 
     
    263266static Matrix4x4 invTrafo = IdentityMatrix(); 
    264267 
     268float mouseMotion = 0.2f; 
     269 
    265270 
    266271////////////// 
    267 //-- algorithm parameters 
     272//-- chc++ algorithm parameters 
    268273 
    269274/// the pixel threshold where a node is still considered invisible  
     
    356361SceneQuery *GetOrCreateSceneQuery(); 
    357362 
    358 void RenderPvs(); 
     363void LoadPvs(); 
     364 
     365void LoadVisibilitySolution(); 
     366 
     367void RenderViewCell(); 
    359368 
    360369 
     
    419428                env.GetFloatParam(string("keyForwardMotion"), keyForwardMotion); 
    420429                env.GetFloatParam(string("keyRotation"), keyRotation); 
     430                env.GetFloatParam(string("mouseMotion"), mouseMotion); 
    421431                env.GetFloatParam(string("tempCohFactor"), ssaoTempCohFactor); 
    422432                env.GetFloatParam(string("turbitity"), turbitity); 
     
    443453                env.GetStringParam(string("filename"), filename); 
    444454                env.GetStringParam(string("visibilitySolution"), visibilitySolution); 
     455 
     456                env.GetBoolParam(string("usePvs"), usePvs); 
    445457 
    446458                //env.GetStringParam(string("modelPath"), model_path); 
     
    474486                cout << "stats filename: " << statsFilename << endl; 
    475487                cout << "filename: " << filename << endl; 
     488                cout << "use PVS: " << usePvs << endl; 
    476489                cout << "visibilitySolution: " << visibilitySolution << endl; 
    477490                 
     
    558571 
    559572        //LoadModel("fisch.dem", dynamicObjects); 
    560         LoadModel("hbuddha.dem", dynamicObjects); 
     573        //LoadModel("hbuddha.dem", dynamicObjects); 
    561574 
    562575        //LoadModel("venusm.dem", dynamicObjects); 
     
    568581        resourceManager->mUseSpecialColors = false; 
    569582 
     583        /* 
    570584        buddha = dynamicObjects.back(); 
    571585         
     
    594608                dynamicObjects.push_back(ent); 
    595609        } 
    596  
     610        */ 
    597611 
    598612/*      int cityEntities = LoadModel("vienna_full_hp.dem", dynamicObjects); 
     
    619633        /// set the depth of the bvh depending on the triangles per leaf node 
    620634        bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 
    621  
    622         /////////// 
    623         //-- load the visibility solution 
    624  
    625         const string vis_filename =  
    626                 string(model_path + visibilitySolution + ".vis"); 
    627  
    628         VisibilitySolutionLoader visLoader; 
    629  
    630         viewCellsTree = visLoader.Load(vis_filename, bvh); 
    631  
    632635 
    633636        // set far plane based on scene extent 
     
    753756void InitGLstate()  
    754757{ 
    755         glClearColor(0.4f, 0.4f, 0.4f, 1.0f); 
     758        glClearColor(0.4f, 0.4f, 0.4f, 1e20f); 
    756759         
    757760        glPixelStorei(GL_UNPACK_ALIGNMENT, 1); 
     
    10631066void MainLoop()  
    10641067{        
    1065         Matrix4x4 oldTrafo = buddha->GetTransform()->GetMatrix(); 
    1066         Vector3 buddhaPos = motionPath->GetCurrentPosition(); 
    1067         Matrix4x4 trafo = TranslationMatrix(buddhaPos); 
    1068          
    1069         buddha->GetTransform()->SetMatrix(trafo); 
    1070  
    1071 #if TODO 
    1072         /*for (int i = 0; i < 10; ++ i) 
    1073         { 
    1074                 SceneEntity *ent = dynamicObjects[i]; 
    1075                 Vector3 newPos = ent->GetWorldCenter(); 
    1076  
    1077                 if (GetOrCreateSceneQuery()->CalcIntersection(newPos)) 
     1068        if (buddha) 
     1069        { 
     1070                Matrix4x4 oldTrafo = buddha->GetTransform()->GetMatrix(); 
     1071                Vector3 buddhaPos = motionPath->GetCurrentPosition(); 
     1072                Matrix4x4 trafo = TranslationMatrix(buddhaPos); 
     1073 
     1074                buddha->GetTransform()->SetMatrix(trafo); 
     1075 
     1076#if TODO // drop objects on ground floor 
     1077                for (int i = 0; i < 10; ++ i) 
    10781078                { 
    1079                         Matrix4x4 mat = TranslationMatrix(newPos - ent->GetCenter()); 
    1080                         ent->GetTransform()->SetMatrix(mat); 
     1079                        SceneEntity *ent = dynamicObjects[i]; 
     1080                        Vector3 newPos = ent->GetWorldCenter(); 
     1081 
     1082                        if (GetOrCreateSceneQuery()->CalcIntersection(newPos)) 
     1083                        { 
     1084                                Matrix4x4 mat = TranslationMatrix(newPos - ent->GetCenter()); 
     1085                                ent->GetTransform()->SetMatrix(mat); 
     1086                        } 
    10811087                } 
    1082         }*/ 
    10831088#endif 
    10841089 
    10851090 
    1086         ///////////////////////// 
    1087         //-- update animations 
    1088  
    1089         //const float rotAngle = M_PI * 1e-3f; 
    1090         const float rotAngle = 1.0f * M_PI / 180.0f; 
    1091  
    1092         Matrix4x4 rotMatrix = RotationZMatrix(rotAngle); 
    1093         dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 
    1094  
    1095         motionPath->Move(0.01f); 
    1096  
     1091                ///////////////////////// 
     1092                //-- update animations 
     1093 
     1094                //const float rotAngle = M_PI * 1e-3f; 
     1095                const float rotAngle = 1.0f * M_PI / 180.0f; 
     1096 
     1097                Matrix4x4 rotMatrix = RotationZMatrix(rotAngle); 
     1098                dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 
     1099 
     1100                motionPath->Move(0.01f); 
     1101        } 
    10971102 
    10981103 
     
    11811186        glEnableClientState(GL_VERTEX_ARRAY); 
    11821187 
     1188        if (usePvs) 
     1189        { 
     1190                if (!viewCellsTree) LoadVisibilitySolution(); 
     1191                LoadPvs();       
     1192        } 
     1193 
    11831194        // render with the specified method (forward rendering, forward + depth, deferred) 
    11841195        switch (renderMethod) 
     
    12601271        else 
    12611272        { 
    1262                 RenderPvs(); 
    1263  
    12641273                // actually render the scene geometry using the specified algorithm 
    12651274                traverser->RenderScene(); 
     
    12831292        const int sunVisiblePixels = useLenseFlare  &&  useDeferred ? TestSunVisible() : 0; 
    12841293 
     1294         
    12851295 
    12861296        /////////////// 
     
    15741584                // make a snapshot of the current frame 
    15751585                makeSnapShot = true; 
     1586                break; 
     1587        case '.': 
     1588                // enable / disable view cells 
     1589                usePvs = !usePvs; 
     1590                if (!usePvs) SceneEntity::SetGlobalVisibleId(-1); 
    15761591                break; 
    15771592        default: 
     
    18291844        camera->Pitch(eyeXAngle); 
    18301845 
    1831         pos += horView * (yMotionBegin - y) * 0.2f; 
     1846        pos += horView * (yMotionBegin - y) * mouseMotion; 
    18321847         
    18331848        camera->SetPosition(pos); 
     
    18971912        rVec = rot * rVec; 
    18981913         
    1899         pos -= rVec * (x - horizontalMotionBegin) * 0.1f; 
    1900         pos[2] += (verticalMotionBegin - y) * 0.1f; 
     1914        pos -= rVec * (x - horizontalMotionBegin) * mouseMotion; 
     1915        pos[2] += (verticalMotionBegin - y) * mouseMotion; 
    19011916 
    19021917        camera->SetPosition(pos); 
     
    19601975void DisplayVisualization() 
    19611976{ 
     1977        // render current view cell 
     1978        if (usePvs) RenderViewCell(); 
     1979         
     1980        visualization->SetViewCell(usePvs ? viewCell : NULL); 
    19621981        visualization->SetFrameId(traverser->GetCurrentFrameId()); 
    1963         visualization->SetViewCell(viewCell); 
     1982         
    19641983 
    19651984        Begin2D(); 
     
    22292248                        sprintf(msg[i ++], "multiqueries: %d, tight bounds: %d, render queue: %d",  
    22302249                                        useMultiQueries, useTightBounds, useRenderQueue); 
    2231                         sprintf(msg[i ++], "render technique: %s, SSAO: %d", renderMethodStr[renderMethod], useAdvancedShading); 
     2250                        sprintf(msg[i ++], "render technique: %s, use pvss: %d", renderMethodStr[renderMethod], usePvs); 
    22322251                        sprintf(msg[i ++], "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf); 
    22332252                        sprintf(msg[i ++], "assumed visible frames: %4d, max batch size: %4d",  
     
    22672286                        sprintf(msg[i ++], "traversed: %5d, frustum culled: %5d, query culled: %5d", 
    22682287                                traversedNodes, frustumCulledNodes, queryCulledNodes); 
    2269                         sprintf(msg[i ++], "issued queries: %5d, renderState changes: %5d, render batches: %5d",  
     2288                        sprintf(msg[i ++], "issued queries: %5d, renderstate changes: %5d, render batches: %5d",  
    22702289                                issuedQueries, stateChanges, numBatches); 
    22712290 
     
    25312550        tech.Init(); 
    25322551 
    2533         //tech.SetLightingEnabled(false); 
    2534         //tech.SetDepthWriteEnabled(false); 
    2535  
    25362552        tech.SetEmmisive(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 
    25372553        tech.SetDiffuse(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 
     
    25422558 
    25432559 
    2544 void RenderPvs() 
     2560void LoadPvs() 
    25452561{ 
    25462562        viewCell = viewCellsTree->GetViewCell(camera->GetPosition()); 
     
    25512567        { 
    25522568                SceneEntity *ent = viewCell->mPvs.GetEntry(i); 
    2553                 //ent->Render(&renderState); 
    25542569                ent->SetVisibleId(globalVisibleId); 
    25552570 
     
    25582573 
    25592574        SceneEntity::SetGlobalVisibleId(globalVisibleId ++); 
    2560  
     2575} 
     2576 
     2577 
     2578void LoadVisibilitySolution() 
     2579{ 
     2580        /////////// 
     2581        //-- load the visibility solution 
     2582 
     2583        const string vis_filename =  
     2584                string(model_path + visibilitySolution + ".vis"); 
     2585 
     2586        VisibilitySolutionLoader visLoader; 
     2587 
     2588        viewCellsTree = visLoader.Load(vis_filename, bvh); 
     2589} 
     2590 
     2591 
     2592void RenderViewCell() 
     2593{ 
    25612594        // render current view cell 
    25622595        static Technique vcTechnique = GetVizTechnique(); 
     
    25642597        vcTechnique.Render(&renderState); 
    25652598        Visualization::RenderBoxForViz(viewCell->GetBox()); 
    2566  
    2567         visualization->SetViewCell(viewCell); 
    2568  
    2569         //cout << "pvs: " << vc->mPvs.Size() << " triangles: " << numTriangles << endl; 
    2570 } 
     2599} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3232 r3246  
    66//-- ssao + gi parameters 
    77 
    8 #define NUM_SAMPLES 8 
     8//#define NUM_SAMPLES 8 
    99//#define NUM_SAMPLES 16 
    10 //#define NUM_SAMPLES 24 
     10#define NUM_SAMPLES 24 
    1111//#define NUM_SAMPLES 48 
    1212 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3232 r3246  
    115115        float4 ao =  tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    116116 
    117 #if 0 // use half size 
     117#if 1 // use half resolution 
    118118 
    119119        // the following has to be done for half resolution ssao: 
Note: See TracChangeset for help on using the changeset viewer.