- Timestamp:
- 12/08/06 23:46:17 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1867 r1876 798 798 return; 799 799 } 800 800 801 char buff[256]; 801 802 envStream.getline(buff, 255); … … 850 851 for (;;) { 851 852 // read in one line 852 envStream.getline(buff, 255);853 envStream.getline(buff, MaxStringLength-1); 853 854 854 855 if (!envStream) -
GTP/trunk/Lib/Vis/Preprocessing/src/Halton.h
r1867 r1876 8 8 9 9 inline float halton(float baseRec, float prev) { 10 float r = 1 - prev - 1e-10f; 10 // float r = 1 - prev - 1e-10f; 11 float r = 1.0f - prev; 11 12 if (baseRec < r) 12 13 return prev + baseRec; 13 14 15 16 17 18 19 return prev + hh + h - 1;14 float h = baseRec; 15 float hh; 16 do { 17 hh = h; 18 h *= baseRec; 19 } while (h >= r); 20 return prev + hh + h - 1.0f; 20 21 } 21 22 … … 131 132 } 132 133 134 void 135 GetNext(const int dimensions, float *p) 136 { 137 for (int i=0; i < dimensions; i++) 138 p[i] = GetNumber(i+1); 139 GenerateNext(); 140 } 141 133 142 void GenerateNext() { 134 143 index++; -
GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp
r1867 r1876 22 22 23 23 int InternalRayCaster::CastRay(const SimpleRay &simpleRay, 24 25 26 27 28 29 { 30 31 32 33 24 VssRayContainer &vssRays, 25 const AxisAlignedBox3 &box, 26 const bool castDoubleRay, 27 const bool pruneInvalidRays 28 ) 29 { 30 if (simpleRay.mType == Ray::GLOBAL_RAY) 31 return CastGlobalRay(simpleRay, vssRays, box, pruneInvalidRays); 32 33 //cout << "internal ray" << endl; 34 34 static Ray ray; 35 35 int hits = 0; … … 41 41 // sbox.Enlarge(Vector3(-Limits::Small)); 42 42 // $$ JB moved here from Validate routine 43 if (!box.IsInside(simpleRay.mOrigin)) { 44 return 0; 45 } 43 44 // if (!box.IsInside(simpleRay.mOrigin)) { 45 // cout<<"out of box "<<simpleRay.mOrigin<<" "<<box<<endl; 46 // return 0; 47 // } 46 48 47 49 mPreprocessor.SetupRay(ray, simpleRay.mOrigin, simpleRay.mDirection); -
GTP/trunk/Lib/Vis/Preprocessing/src/Makefile
r1867 r1876 1 1 ############################################################################# 2 2 # Makefile for building: preprocessor 3 # Generated by qmake (2.00a) (Qt 4.1.2) on: pá 8. XII 16:33:2020063 # Generated by qmake (2.00a) (Qt 4.1.2) on: pá 8. XII 21:21:57 2006 4 4 # Project: preprocessor.pro 5 5 # Template: app … … 63 63 $(MAKE) -f $(MAKEFILE).Debug uninstall 64 64 65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc 2005\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \65 Makefile: preprocessor.pro C:/Qt/4.1.2/mkspecs/win32-msvc.net\qmake.conf C:/Qt/4.1.2/mkspecs/qconfig.pri \ 66 66 C:\Qt\4.1.2\mkspecs\features\qt_config.prf \ 67 67 C:\Qt\4.1.2\mkspecs\features\exclusive_builds.prf \ -
GTP/trunk/Lib/Vis/Preprocessing/src/ObjParser.cpp
r1695 r1876 197 197 while (fgets(str, 80, file) != NULL) 198 198 { 199 199 switch (str[0]) 200 200 { 201 case 'v': // vertex 202 { 203 float x, y, z; //cout << "v"; 204 sscanf(str + 1, "%f %f %f", &x, &y, &z); 205 vertices.push_back(Vector3(x,y,z)); 206 //cout << "vertex: " << vertices.back() << endl; 207 break; 201 case 'v': // vertex or normal 202 { 203 switch (str[1]) { 204 case 'n' : 205 // normal do nothing 206 break; 207 default: 208 float x, y, z; //cout << "v"; 209 sscanf(str + 1, "%f %f %f", &x, &y, &z); 210 vertices.push_back(Vector3(x,y,z)); 211 //cout << "vertex: " << vertices.back() << endl; 208 212 } 213 break; 214 } 209 215 case 'f': 210 216 { -
GTP/trunk/Lib/Vis/Preprocessing/src/QtGlRenderer.cpp
r1867 r1876 17 17 #define USE_CG 1 18 18 19 #ifdef USE_CG 19 20 #if USE_CG 20 21 #include <Cg/cg.h> 21 22 #include <Cg/cgGL.h> -
GTP/trunk/Lib/Vis/Preprocessing/src/RssPreprocessor.cpp
r1867 r1876 19 19 20 20 21 const bool pruneRays = false; 22 23 24 21 const bool pruneInvalidRays = false; 22 23 25 24 #define ADD_RAYS_IN_PLACE 1 26 25 … … 498 497 499 498 if (1) { 500 mDistributions.push_back(new SpatialBoxBasedDistribution(*this));501 //// mDistributions.push_back(new DirectionBasedDistribution(*this));502 //mDistributions.push_back(new ObjectDirectionBasedDistribution(*this));503 //// mDistributions.push_back(new ReverseObjectBasedDistribution(*this));504 //mDistributions.push_back(new ObjectBasedDistribution(*this));505 //mDistributions.push_back(new ReverseViewSpaceBorderBasedDistribution(*this));499 // mDistributions.push_back(new SpatialBoxBasedDistribution(*this)); 500 // mDistributions.push_back(new DirectionBasedDistribution(*this)); 501 mDistributions.push_back(new ObjectDirectionBasedDistribution(*this)); 502 // mDistributions.push_back(new ReverseObjectBasedDistribution(*this)); 503 mDistributions.push_back(new ObjectBasedDistribution(*this)); 504 mDistributions.push_back(new ReverseViewSpaceBorderBasedDistribution(*this)); 506 505 } else { 507 506 mDistributions.push_back(new GlobalLinesDistribution(*this)); … … 547 546 548 547 cout<<"Casting initial rays..."<<endl<<flush; 549 CastRays(rays, mVssRays, true, prune Rays);548 CastRays(rays, mVssRays, true, pruneInvalidRays); 550 549 551 550 ExportObjectRays(mVssRays, 1546); … … 640 639 rssPass++; 641 640 642 //mDistributions.resize(1);641 // mDistributions.resize(1); 643 642 644 643 mRssTree = new RssTree; … … 671 670 672 671 // keep only rss 673 mDistributions.resize(1);672 // mDistributions.resize(1); 674 673 675 674 while (1) { … … 703 702 rays.NormalizePdf((float)rays.size()); 704 703 705 CastRays(rays, tmpVssRays, true, prune Rays);704 CastRays(rays, tmpVssRays, true, pruneInvalidRays); 706 705 castRays += (int)rays.size(); 707 706 -
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.cpp
r1874 r1876 1795 1795 { 1796 1796 stack<RssTreeNode *> tstack; 1797 PushRoots(tstack);1798 1797 1799 1798 float sumPvsSize = 0.0f; … … 1809 1808 for (int i=0; i < mRoots.size(); i++) 1810 1809 UpdateImportance(mRoots[i]); 1811 1810 1811 PushRoots(tstack); 1812 1812 1813 while (!tstack.empty()) { 1813 1814 RssTreeNode *node = tstack.top(); … … 1882 1883 // works only with single root now! 1883 1884 node = mRoots[0]; 1884 1885 1885 while (!node->IsLeaf()) { 1886 1886 RssTreeInterior *in = (RssTreeInterior *)node; … … 1889 1889 // float p = in->GetRelativePosition(); 1890 1890 float p = in->back->GetImportance()/(in->back->GetImportance() + in->front->GetImportance()); 1891 1891 1892 // cout<<"p = "<<p<<endl; 1892 1893 // cout<<"axis="<<axis<<" pos="<<pos<<endl; 1893 1894 // cout<<GetBBox(in)<<endl; … … 1897 1898 if (params[axis] < p) { 1898 1899 node = in->back; 1899 params[axis] = params[axis] / p; 1900 if (p > Limits::Small) 1901 params[axis] = params[axis] / p; 1900 1902 } else { 1901 1903 node = in->front; 1902 params[axis] = (params[axis] - p) / ( 1.0f - p); 1904 if (p < 1.0f - Limits::Small) 1905 params[axis] = (params[axis] - p) / (1.0f - p); 1903 1906 } 1904 1907 } … … 1907 1910 1908 1911 GenerateLeafRay(params, rays, node->bbox, node->dirBBox); 1912 1913 1909 1914 } 1910 1915 … … 1914 1919 SimpleRayContainer &rays) 1915 1920 { 1916 1917 1918 1919 1921 1920 1922 stack<RssTreeNode *> tstack; … … 2228 2230 2229 2231 int startIndex = (int)rays.size(); 2230 2231 2232 // Debug<<"B"<<flush; 2232 2233 2233 2234 AxisAlignedBox3 box = GetBBox(leaf); 2234 2235 AxisAlignedBox3 dirBox = GetDirBBox(leaf); … … 2270 2271 float *params, 2271 2272 SimpleRayContainer &rays, 2272 const AxisAlignedBox3 & box,2273 const AxisAlignedBox3 & dirBBox2273 const AxisAlignedBox3 &sbox, 2274 const AxisAlignedBox3 &sDirBBox 2274 2275 ) 2275 2276 { 2276 Vector3 origin = bbox.GetPoint(Vector3(params[0], params[1], params[2])); 2277 Vector3 dirVector = dirBBox.GetPoint(Vector3(params[3], params[4], 0.0f)); 2277 Vector3 origin = sbox.GetPoint(Vector3(params[0], params[1], params[2])); 2278 2279 Vector3 dirVector = sDirBBox.GetPoint(Vector3(params[3], params[4], 0.0f)); 2280 2278 2281 Vector3 direction = VssRay::GetInvDirParam(dirVector.x, dirVector.y); 2279 2282 … … 2282 2285 float minT, maxT; 2283 2286 2284 float boxSize = Magnitude( bbox.Size());2287 float boxSize = Magnitude(sbox.Size()); 2285 2288 // compute interection of the ray with the box 2286 2289 #if 1 2287 if ( bbox.ComputeMinMaxT(origin, direction, &minT, &maxT) && minT < maxT)2288 dist = (maxT + 1e-2*boxSize);2290 if (sbox.ComputeMinMaxT(origin, direction, &minT, &maxT) && minT < maxT) 2291 dist = (maxT + 0.0f*boxSize); 2289 2292 #else 2290 2293 dist = 0.5f*boxSize; … … 2292 2295 2293 2296 origin += direction*dist; 2294 2295 2297 2296 2298 //Debug<<"dir vector.x="<<dirVector.x<<"direction'.x="<<atan2(direction.x, direction.y)<<endl; 2297 2299 rays.push_back(SimpleRay(origin, direction)); … … 2666 2668 { 2667 2669 2668 float param[5]; 2669 2670 for (int i=0; i < numberOfRays; i++) { 2671 halton.GetNext(param); 2672 GenerateRay(param, rays); 2673 } 2674 2675 return rays.size(); 2670 if (1) { 2671 float param[5]; 2672 2673 for (int i=0; i < numberOfRays; i++) { 2674 mHalton.GetNext(5, param); 2675 GenerateRay(param, rays); 2676 } 2677 2678 return rays.size(); 2679 } 2676 2680 2677 2681 vector<RssTreeLeaf *> leaves; … … 2778 2782 // if 1.0f then weighs = 1 1/2 1/3 1/4 2779 2783 //float passSampleWeightDecay = 1.0f; 2780 float passSampleWeightDecay = 1 .0f;2784 float passSampleWeightDecay = 1000.0f; 2781 2785 2782 2786 float … … 2786 2790 float weight; 2787 2791 if (1) 2788 2792 weight = 1.0f/(passDiff + passSampleWeightDecay); 2789 2793 else 2790 2791 2792 2793 2794 2795 2796 2794 switch (passDiff) { 2795 case 0: 2796 // weight = 1.0f; 2797 // break; 2798 default: 2799 weight = 1.0f; 2800 break; 2797 2801 // case 1: 2798 // weight = 0.5f;2799 // break;2800 // case 2:2801 // weight = 0.25f;2802 // break;2803 // case 3:2804 // weight = 0.12f;2805 // break;2806 // case 4:2807 // weight = 0.06f;2808 // break;2809 // default:2810 // weight = 0.03f;2811 // break;2802 // weight = 0.5f; 2803 // break; 2804 // case 2: 2805 // weight = 0.25f; 2806 // break; 2807 // case 3: 2808 // weight = 0.12f; 2809 // break; 2810 // case 4: 2811 // weight = 0.06f; 2812 // break; 2813 // default: 2814 // weight = 0.03f; 2815 // break; 2812 2816 } 2813 2817 return weight; -
GTP/trunk/Lib/Vis/Preprocessing/src/RssTree.h
r1867 r1876 629 629 630 630 631 Halton <5> halton;631 HaltonSequence mHalton; 632 632 633 633 -
GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp
r1867 r1876 32 32 33 33 // $$JB HACK 34 #define USE_KD_PVS 034 #define USE_KD_PVS 1 35 35 36 36 #define KD_PVS_AREA (1e-5f) … … 2023 2023 2024 2024 ViewCellContainer viewcells; 2025 2026 2027 2028 2025 2029 2026 static Ray hray; … … 2084 2081 // for directional sampling it is important to count only contributions 2085 2082 // made in one direction!!! 2086 2083 // the other contributions of this sample will be counted for the oposite ray! 2087 2084 2088 2085 if (ray.mOriginObject && … … 6047 6044 6048 6045 #define PVS_ADD_DIRTY 1 6046 6049 6047 float 6050 6048 VspOspViewCellsManager::ComputeSampleContribution(VssRay &ray, … … 6060 6058 ViewCellContainer viewcells; 6061 6059 6062 6063 static Ray hray; 6064 hray.Init(ray); 6065 //hray.mFlags |= Ray::CULL_BACKFACES; 6066 //Ray hray(ray); 6067 6068 // if (ray.mPdf!=1.0f) 6069 // cout<<ray.mPdf<<" "; 6070 6071 float tmin = 0, tmax = 1.0; 6072 6073 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 6074 return 0; 6075 6076 Vector3 origin = hray.Extrap(tmin); 6077 Vector3 termination = hray.Extrap(tmax); 6078 6079 ViewCell::NewMail(); 6080 6081 // traverse the view space subdivision 6082 CastLineSegment(origin, termination, viewcells); 6083 6084 if (storeViewCells) 6060 static Ray hray; 6061 hray.Init(ray); 6062 6063 float tmin = 0, tmax = 1.0; 6064 6065 if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 6066 return 0; 6067 6068 Vector3 origin = hray.Extrap(tmin); 6069 Vector3 termination = hray.Extrap(tmax); 6070 6071 ViewCell::NewMail(); 6072 6073 // traverse the view space subdivision 6074 CastLineSegment(origin, termination, viewcells); 6075 6076 if (storeViewCells) 6085 6077 { 6086 6087 6088 6089 } 6090 6091 6092 6093 6094 6078 // copy viewcells memory efficiently 6079 ray.mViewCells.reserve(viewcells.size()); 6080 ray.mViewCells = viewcells; 6081 } 6082 6083 ViewCellContainer::const_iterator it = viewcells.begin(); 6084 6085 Intersectable *terminationObj = GetIntersectable(ray, true); 6086 6095 6087 #if SAMPLE_ORIGIN_OBJECTS 6096 6088 Intersectable *originObj = GetIntersectable(ray, false); 6097 6089 #endif 6098 6099 6100 { 6101 6102 6103 6090 6091 for (; it != viewcells.end(); ++ it) 6092 { 6093 ViewCell *viewcell = *it; 6094 6095 if (viewcell->GetValid()) 6104 6096 { // if ray not outside of view space 6105 6106 6107 6097 float contribution; 6098 6099 if (terminationObj) 6108 6100 { 6109 6101 // todo: maybe not correct for kd node pvs … … 6116 6108 ray.mRelativePvsContribution += contribution; 6117 6109 } 6118 6119 6120 6121 6122 6123 6110 6111 //////////////// 6112 //-- for directional sampling it is important to count 6113 //-- only contributions made in one direction! 6114 //-- the other contributions of this sample will be counted for the opposite ray! 6115 6124 6116 #if SAMPLE_ORIGIN_OBJECTS 6125 6126 6127 6128 6129 6117 6118 if (originObj && 6119 viewcell->GetPvs().GetSampleContribution(originObj, 6120 ray.mPdf, 6121 contribution)) 6130 6122 { 6131 6132 6123 ++ ray.mPvsContribution; 6124 ray.mRelativePvsContribution += contribution; 6133 6125 } 6134 6126 #endif 6135 6127 } 6136 6128 } 6137 6138 if (!addRays) 6139 { 6140 return ray.mRelativePvsContribution; 6141 } 6142 6143 // sampled objects are stored in the pvs 6144 for (it = viewcells.begin(); it != viewcells.end(); ++ it) 6145 { 6146 ViewCell *viewCell = *it; 6147 6148 if (!viewCell->GetValid()) 6149 break; 6150 6151 //$$JB hack 6152 6129 6130 if (!addRays) { 6131 return ray.mRelativePvsContribution; 6132 } 6133 6134 // sampled objects are stored in the pvs 6135 for (it = viewcells.begin(); it != viewcells.end(); ++ it) { 6136 ViewCell *viewCell = *it; 6137 6138 if (!viewCell->GetValid()) 6139 break; 6140 6141 //$$JB hack 6142 6153 6143 #if PVS_ADD_DIRTY 6154 6144 viewCell->GetPvs().AddSampleDirtyCheck(terminationObj, ray.mPdf); 6155 6145 #else 6156 6146 viewCell->GetPvs().AddSample(terminationObj, ray.mPdf); 6157 6147 #endif 6158 6148 6159 6149 #if SAMPLE_ORIGIN_OBJECTS 6160 6150 #if PVS_ADD_DIRTY 6161 6151 viewCell->GetPvs().AddSampleDirtyCheck(originObj, ray.mPdf); 6162 6152 #else 6163 6153 viewCell->GetPvs().AddSample(originObj, ray.mPdf); 6164 6154 #endif 6165 6155 #endif 6166 if (viewCell->GetPvs().RequiresResort()) 6167 { 6168 viewCell->GetPvs().Sort(); 6169 } 6170 } 6171 6172 return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 6173 (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 6156 if (viewCell->GetPvs().RequiresResort()) { 6157 viewCell->GetPvs().Sort(); 6158 } 6159 } 6160 6161 return ABS_CONTRIBUTION_WEIGHT*ray.mPvsContribution + 6162 (1.0f - ABS_CONTRIBUTION_WEIGHT)*ray.mRelativePvsContribution; 6174 6163 } 6175 6164 -
GTP/trunk/Lib/Vis/Preprocessing/src/default.env
r1867 r1876 90 90 RssPreprocessor { 91 91 samplesPerPass 1000 92 initialSamples 100000092 initialSamples 2000000 93 93 vssSamples 20000000 94 vssSamplesPerPass 100000094 vssSamplesPerPass 3000000 95 95 useImportanceSampling true 96 96 … … 273 273 # filename ../scripts/viewcells_atlanta.xml 274 274 # filename ../scripts/viewcells_soda5-2.xml 275 # filename ../data/soda/soda5-viewcells.xml276 275 # filename ../scripts/viewcells_atlanta.xml 277 276 # filename ../data/soda/soda-viewcells.xml.gz 278 277 # filename ../data/test1/test-viewcells.xml 278 279 280 # filename ../data/soda/soda5-viewcells.xml 279 281 280 282 # filename ../data/soda/soda-viewcells-1000.xml.gz -
GTP/trunk/Lib/Vis/Preprocessing/src/preprocessor.pro
r1867 r1876 19 19 20 20 CONFIG(qt) { 21 win32:INCLUDEPATH += "c:/Program Files/NVIDIA Corporation/Cg/include" 21 win32:INCLUDEPATH += "d:/Programs/NVIDIA Corporation/Cg/include" 22 #win32:INCLUDEPATH += "c:/Program Files/NVIDIA Corporation/Cg/include" 22 23 } 23 24 … … 31 32 32 33 CONFIG(qt) { 33 win32:LIBPATH += "c:/Program Files/NVIDIA Corporation/Cg/lib" 34 win32:LIBPATH += "d:/Programs/NVIDIA Corporation/Cg/lib" 35 #win32:LIBPATH += "c:/Program Files/NVIDIA Corporation/Cg/lib" 34 36 } 35 37
Note: See TracChangeset
for help on using the changeset viewer.