Ignore:
Timestamp:
10/23/06 15:37:18 (18 years ago)
Author:
mattausch
Message:

working on render cost evaluation framework for interleaved splits

File:
1 edited

Legend:

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

    r1660 r1666  
    55125512        { 
    55135513                ViewCell *viewcell = *it; 
    5514                  
     5514 
    55155515                if (viewcell->GetValid()) 
    55165516                {       // if ray not outside of view space 
     
    55195519                        if (ray.mTerminationObject)  
    55205520                        { 
    5521                           // todo: maybe not correct for kd node pvs 
    5522                           Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 
    5523                            
    5524                           if (viewcell->GetPvs().GetSampleContribution(obj, 
    5525                                                                                                                    ray.mPdf,  
    5526                                                                                                                    contribution)) 
     5521                                // todo: maybe not correct for kd node pvs 
     5522                                Intersectable *obj = mHierarchyManager->GetIntersectable(ray, true); 
     5523 
     5524                                if (viewcell->GetPvs().GetSampleContribution(obj, 
     5525                                        ray.mPdf,  
     5526                                        contribution)) 
    55275527                                { 
    5528                                   ++ ray.mPvsContribution; 
     5528                                        ++ ray.mPvsContribution; 
    55295529                                } 
    5530                            
    5531                           ray.mRelativePvsContribution += contribution; 
     5530 
     5531                                ray.mRelativePvsContribution += contribution; 
    55325532                        } 
    5533                          
    5534                         // for directional sampling it is important to count only contributions 
    5535                         // made in one direction! 
    5536                         // the other contributions of this sample will be counted for the opposite ray! 
     5533 
     5534                        //-- for directional sampling it is important to count only contributions  
     5535                        //-- made in one direction! 
     5536                        //-- the other contributions of this sample will be counted for the opposite ray! 
    55375537#if SAMPLE_ORIGIN_OBJECTS 
    55385538                        if (ray.mOriginObject &&  
    55395539                                viewcell->GetPvs().GetSampleContribution(ray.mOriginObject, 
    5540                                                                                                                  ray.mPdf, 
    5541                                                                                                                  contribution)) 
     5540                                ray.mPdf, 
     5541                                contribution)) 
    55425542                        { 
    55435543                                ++ ray.mPvsContribution; 
     
    56165616 
    56175617 
     5618typedef priority_queue<ViewCell *, vector<ViewCell *>,  
     5619                                           myless<vector<ViewCell *>::value_type> > ViewCellsQueue; 
     5620 
     5621typedef priority_queue<BvhNode *, vector<BvhNode *>,  
     5622                                           myless<vector<BvhNode *>::value_type> > ObjectsQueue; 
     5623 
     5624void VspOspViewCellsManager::ExportStats(const string &mergeStats) 
     5625{ 
     5626        ofstream stats; 
     5627        stats.open(mergeStats.c_str()); 
     5628 
     5629        ObjectsQueue objectsQueue; 
     5630        ViewCellsQueue viewCellsQueue; 
     5631 
     5632        objectsQueue.push(mHierarchyManager->mBvHierarchy->GetRoot()); 
     5633        viewCellsQueue.push(mViewCellsTree->GetRoot()); 
     5634         
     5635        int numViewCells = 1; 
     5636         
     5637        const AxisAlignedBox3 box = mViewSpaceBox; 
     5638        const float vol = box.GetVolume(); 
     5639 
     5640        const int rootPvs = mViewCellsTree->GetPvsSize(mViewCellsTree->GetRoot()); 
     5641        const int rootEntries = mViewCellsTree->GetPvsEntries(mViewCellsTree->GetRoot()); 
     5642 
     5643        cout << "exporting stats ... " << endl; 
     5644         
     5645        float totalRenderCost, avgRenderCost, expectedCost; 
     5646 
     5647        float deviation = 0; 
     5648        int totalPvs = rootPvs; 
     5649        int entriesInPvs = rootEntries; 
     5650 
     5651        totalRenderCost = avgRenderCost = expectedCost = (float)rootPvs; 
     5652 
     5653        const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 
     5654        const float memoryCost = (float)entriesInPvs *  entrySize / (1024.0f * 1024.0f); 
     5655 
     5656        ///////////// 
     5657        //-- first view cell 
     5658 
     5659/*      mViewCellsTree->UpdateStats(stats,       
     5660                                                                0,  
     5661                                                                numViewCells,  
     5662                                                                0,  
     5663                                                                totalRenderCost,  
     5664                                                                rootPvs,  
     5665                                                                expectedCost,  
     5666                                                                avgRenderCost,  
     5667                                                                deviation, 
     5668                                                                totalPvs,  
     5669                                                                entriesInPvs, 
     5670                                                                memoryCost, 
     5671                                                                0,  
     5672                                                                mRoot->GetVolume()); 
     5673*/               
     5674 
     5675        //-- go through tree in the order of render cost decrease 
     5676        //-- which is the same order as the view cells were merged 
     5677        //-- or the reverse order of subdivision for subdivision-only  
     5678        //-- view cell hierarchies. 
     5679 
     5680        while (!(objectsQueue.empty() && viewCellsQueue.empty())) 
     5681        { 
     5682                ViewCell *viewCell = viewCellsQueue.top(); 
     5683                BvhNode *bvhNode =  objectsQueue.top(); 
     5684 
     5685                if (viewCell->GetMergeCost() < bvhNode->GetMergeCost()) 
     5686                { 
     5687                        viewCellsQueue.pop(); 
     5688/* 
     5689                        if (!vc->IsLeaf())  
     5690                        {        
     5691                                ViewCellInterior *interior = dynamic_cast<ViewCellInterior *>(vc); 
     5692 
     5693                                const int parentPvs = GetPvsSize(interior); 
     5694                                const int parentPvsEntries = GetPvsEntries(interior); 
     5695                                const float parentCost = (float)parentPvs * interior->GetVolume(); 
     5696 
     5697                                float childCost = 0; 
     5698                                int childPvs = 0; 
     5699                                int childPvsEntries = 0; 
     5700 
     5701                                -- numViewCells; 
     5702 
     5703                                ViewCellContainer::const_iterator it, it_end = interior->mChildren.end(); 
     5704 
     5705                                for (it = interior->mChildren.begin(); it != it_end; ++ it) 
     5706                                { 
     5707                                        ViewCell *vc = *it; 
     5708 
     5709                                        const int pvsSize = GetPvsSize(vc); 
     5710                                        const int pvsEntries = GetPvsEntries(vc); 
     5711         
     5712                                        childCost += (float) pvsSize * vc->GetVolume(); 
     5713                                        childPvs += pvsSize; 
     5714                                        childPvsEntries += pvsEntries; 
     5715 
     5716                                        tqueue.push(vc); 
     5717                                        ++ numViewCells; 
     5718                                } 
     5719 
     5720                                // update stats for this view cell 
     5721                                const float costDecr = (parentCost - childCost) / vol; 
     5722 
     5723                                totalRenderCost -= costDecr; 
     5724                                totalPvs += childPvs - parentPvs; 
     5725                                entriesInPvs += childPvsEntries - parentPvsEntries; 
     5726 
     5727                                expectedCost = totalRenderCost / (float)numViewCells; 
     5728                                avgRenderCost = (float)totalPvs / (float)numViewCells; 
     5729 
     5730                                const float entrySize = sizeof(PvsData) + sizeof(Intersectable *); 
     5731                                const float memoryCost = (float)entriesInPvs * entrySize / (1024.0f * 1024.0f); 
     5732 
     5733                                mViewCellsTree->UpdateStats(stats, 
     5734                                                                                        0,  
     5735                                                                                        numViewCells,  
     5736                                                                                        costDecr,  
     5737                                                                                        totalRenderCost, 
     5738                                                                                        parentPvs,  
     5739                                                                                        expectedCost,  
     5740                                                                                        avgRenderCost,  
     5741                                                                                        deviation, 
     5742                                                                                        totalPvs,  
     5743                                                                                        entriesInPvs,  
     5744                                                                                        memoryCost, 
     5745                                                                                        childPvs - parentPvs, 
     5746                                                                                        vc->GetVolume()); 
     5747                                */ 
     5748                        } 
     5749                        else // object space split 
     5750                        { 
     5751                        } 
     5752        } 
     5753 
     5754        stats.close(); 
     5755} 
     5756 
     5757 
    56185758#if TEST_EVALUATION 
    56195759void VspOspViewCellsManager::EvalViewCellPartition() 
     
    56935833        cout << "finished" << endl; 
    56945834 
    5695         vector<int> storageFunc; 
    5696         mViewCellsTree->GetStorageFunction(storageFunc); 
    5697  
    5698         vector<float> costFunc; 
    5699         mViewCellsTree->GetCostFunction(costFunc); 
    5700  
    5701         ofstream outstr("out.txt"); 
    5702  
    5703         for (int i = 0; i < storageFunc.size(); ++ i) 
    5704                 outstr << i << ": " << storageFunc[i] << endl; 
    5705 outstr << endl; 
    5706         for (int i = 0; i < costFunc.size(); ++ i) 
    5707                 outstr << i << ": " << costFunc[i] << endl; 
    5708         if (0) 
    5709         for (int i = 0; i <50; ++ i) 
    5710         { 
    5711                 Vector3 point = GetViewSpaceBox().GetRandomPoint(); 
    5712                 ViewCell *vc = GetViewCell(point); 
    5713         } 
    5714         //RenderBvhNode(mHierarchyManager->mBvHierarchy->GetRoot()); 
    5715  
    57165835        disposeRays(evaluationSamples, NULL); 
    57175836} 
Note: See TracChangeset for help on using the changeset viewer.