Changeset 1968 for GTP/trunk/Lib/Vis/Preprocessing/src
- Timestamp:
- 01/11/07 04:18:36 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/Environment.cpp
r1966 r1968 1188 1188 "1000000"); 1189 1189 1190 RegisterOption("Preprocessor.useHwGlobalLines", 1191 optBool, 1192 "preprocessor_use_hw_global_lines=", 1193 "false"); 1194 1195 RegisterOption("Preprocessor.HwGlobalLines.texHeight", 1196 optInt, 1197 "preprocessor_hw_global_lines_texheight=", 1198 "128"); 1199 1200 RegisterOption("Preprocessor.HwGlobalLines.texWidth", 1201 optInt, 1202 "preprocessor_hw_global_lines_texwidth=", 1203 "128"); 1204 1205 RegisterOption("Preprocessor.HwGlobalLines.stepSize", 1206 optFloat, 1207 "preprocessor_hw_global_lines_stepsize=", 1208 "0.0001"); 1209 1210 RegisterOption("Preprocessor.HwGlobalLines.maxDepth", 1211 optInt, 1212 "preprocessor_hw_global_lines_max_depth=", 1213 "50"); 1214 1215 RegisterOption("Preprocessor.HwGlobalLines.sampleReverse", 1216 optBool, 1217 "preprocessor_hw_global_lines_sample_reverse=", 1218 "true"); 1219 1190 1220 RegisterOption("RenderSampler.samples", 1191 1221 optInt, … … 1198 1228 "0"); 1199 1229 1200 1201 1230 RegisterOption("RenderSampler.useOcclusionQueries", 1202 1231 optBool, … … 1252 1281 1253 1282 1254 /************************************************************************* ***********/1255 /* GvsPrerpocessor related options*/1256 /************************************************************************* ***********/1283 /*************************************************************************/ 1284 /* GvsPrerpocessor related options */ 1285 /*************************************************************************/ 1257 1286 1258 1287 … … 1287 1316 "gvsStats.log"); 1288 1317 1289 /***********************************************************************************/ 1290 /* View cells related options */ 1291 /***********************************************************************************/ 1318 1319 /**********************************************************************/ 1320 /* View cells related options */ 1321 /**********************************************************************/ 1292 1322 1293 1323 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.h
r1960 r1968 224 224 public: 225 225 226 GlRendererBuffer(SceneGraph *sceneGraph,227 228 229 230 226 GlRendererBuffer(SceneGraph *sceneGraph, 227 ViewCellsManager *viewcells, 228 KdTree *tree); 229 230 virtual ~GlRendererBuffer(); 231 231 232 232 /** Evaluates render cost of a point sample. 233 234 235 236 */ 237 238 239 233 @param sample the render cost sample to be evaluated 234 @param useOcclusionQueries if occlusion queries should be used or item buffer 235 @param threshold number of pixels / samples from where an object is considered visible. 236 */ 237 virtual void EvalRenderCostSample(RenderCostSample &sample, 238 const bool useOcclusionQueries, 239 const int threshold); 240 240 241 241 /** Evaluates render cost of a number of point samples. The point samples 242 243 244 245 246 247 248 */ 249 250 251 252 253 242 are distributed uniformly over the defined view space. 243 244 @param numSamples the number of point samples taken 245 @param samples stores the taken point samples in a container 246 @param useOcclusionQueries if occlusion queries should be used or item buffer 247 @param threshold number of pixels / samples from where an object is considered visible. 248 */ 249 virtual void SampleRenderCost(const int numSamples, 250 vector<RenderCostSample> &samples, 251 const bool useOcclusionQueries, 252 const int threshold = 0); 253 254 254 255 255 /** Implerment in subclasses. 256 256 */ 257 virtual void EvalPvsStat(); 258 259 260 virtual int GetWidth() const = 0; 261 virtual int GetHeight() const = 0; 262 263 virtual void MakeCurrent() = 0; 264 virtual void DoneCurrent() = 0; 265 266 267 virtual void SampleBeamContributions( 268 Intersectable *sourceObject, 269 Beam &beam, 270 const int samples, 271 BeamSampleStatistics &stat 272 ); 273 274 virtual void 275 SampleViewpointContributions( 276 Intersectable *sourceObject, 277 const Vector3 viewPoint, 278 Beam &beam, 279 const int desiredSamples, 280 BeamSampleStatistics &stat 281 ); 282 283 virtual void InitGL(); 284 285 /** Computes rays from information gained with hw sampling- 286 */ 287 virtual void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays); 288 289 virtual int ComputePvs() const = 0; 290 291 292 virtual int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const = 0; 293 294 295 296 257 virtual void EvalPvsStat(); 258 259 260 virtual int GetWidth() const = 0; 261 virtual int GetHeight() const = 0; 262 263 virtual void MakeCurrent() = 0; 264 virtual void DoneCurrent() = 0; 265 266 267 virtual void SampleBeamContributions( 268 Intersectable *sourceObject, 269 Beam &beam, 270 const int samples, 271 BeamSampleStatistics &stat 272 ); 273 274 virtual void 275 SampleViewpointContributions( 276 Intersectable *sourceObject, 277 const Vector3 viewPoint, 278 Beam &beam, 279 const int desiredSamples, 280 BeamSampleStatistics &stat 281 ); 282 283 virtual void InitGL(); 284 285 /** Computes rays from information gained with hw sampling- 286 */ 287 virtual void ComputeRays(Intersectable *sourceObj, VssRayContainer &rays); 288 289 virtual int ComputePvs() const = 0; 290 291 virtual int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const = 0; 292 293 297 294 protected: 298 unsigned int *mPixelBuffer; 299 300 static void GenQueries(const int numQueries); 301 302 virtual void SetupProjectionForViewPoint(const Vector3 &viewPoint, 303 const Beam &beam, 304 305 Intersectable *sourceObject); 295 296 unsigned int *mPixelBuffer; 297 298 static void GenQueries(const int numQueries); 299 300 virtual void SetupProjectionForViewPoint(const Vector3 &viewPoint, 301 const Beam &beam, 302 303 Intersectable *sourceObject); 306 304 307 305 /** Evaluates query for one direction using item buffer. 308 306 */ 309 307 virtual void EvalQueryWithItemBuffer(); 310 308 311 309 /** Evaluates query for one direction using occlusion queries. 312 310 */ 313 311 virtual void EvalQueryWithOcclusionQueries(); 314 312 315 313 public: 316 314 // matt: remove qt dependencies 317 318 // void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &);315 // signals: 316 // void UpdatePvsErrorItem(int i, GlRendererBuffer::PvsErrorEntry &); 319 317 }; 320 318 … … 325 323 { 326 324 public: 327 325 328 326 GlRendererWidget(SceneGraph *sceneGraph, ViewCellsManager *vcm, KdTree *kdTree): 329 327 GlRenderer(sceneGraph, vcm, kdTree) 330 {}331 332 333 334 335 336 //virtual void Create() {}337 virtual void Show() {}338 328 {} 329 330 GlRendererWidget() {} 331 332 virtual ~GlRendererWidget() {} 333 334 //virtual void Create() {} 335 virtual void Show() {} 336 339 337 340 338 protected: 341 339 342 340 343 344 345 341 // SceneGraph *mSceneGraph; 342 // ViewCellsManager *mViewCellsManager; 343 // KdTree *mKdTree; 346 344 }; 347 345 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
r1964 r1968 200 200 201 201 202 /*GlobalLinesRenderer::GlobalLinesRenderer(RenderTexture *buffer1,203 RenderTexture *buffer2,204 Preprocessor *preprocessor,205 GlRenderer *renderer)206 : mNewTexture(buffer1), mOldTexture(buffer2), mPreprocessor(preprocessor), mMaxDepth(100),207 mRenderer(renderer)208 {209 }210 */211 212 213 202 GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor, 214 GlRenderer *renderer, 215 const float mTexHeight, 216 const float mTexWidth, 217 const float eps): 203 const int texHeight, 204 const int texWidth, 205 const float eps, 206 const int maxDepth, 207 const bool sampleReverse): 218 208 mNewTexture(NULL), 219 209 mOldTexture(NULL), 220 mMaxDepth(0),221 mRenderer(renderer),222 210 mPreprocessor(preprocessor), 223 211 mTexHeight(mTexHeight), 224 212 mTexWidth(mTexWidth), 225 mEpsilon(eps) 226 { 227 } 228 229 230 GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor, 231 GlRenderer *renderer): 213 mEpsilon(eps), 214 mMaxDepth(maxDepth), 215 mSampleReverse(sampleReverse) 216 { 217 mRenderer = new GlRenderer(mPreprocessor->mSceneGraph, 218 mPreprocessor->mViewCellsManager, 219 mPreprocessor->mKdTree); 220 221 } 222 223 224 GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor): 232 225 mNewTexture(NULL), 233 226 mOldTexture(NULL), 234 mMaxDepth(0), 235 mRenderer(renderer), 227 mMaxDepth(40), 236 228 mPreprocessor(preprocessor), 237 229 mTexHeight(128), 238 230 mTexWidth(128), 239 mEpsilon(0.0001) 240 {} 231 mEpsilon(0.0001), 232 mSampleReverse(true) 233 { 234 mRenderer = new GlRenderer(mPreprocessor->mSceneGraph, 235 mPreprocessor->mViewCellsManager, 236 mPreprocessor->mKdTree); 237 } 241 238 242 239 … … 288 285 delete mNewItemBuffer; 289 286 delete mOldItemBuffer; 287 288 DEL_PTR(mRenderer); 290 289 } 291 290 292 291 293 void GlobalLinesRenderer::InitScene(const float alpha, const float beta) 294 { 295 AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 296 297 const float sceneSize = Magnitude(bbox.Diagonal()); 298 299 // compute the center of the scene 300 Vector3 midPoint = bbox.Center(); 301 302 // add a small offset to provide some randomness in the sampling 303 Vector3 offset(Random(sceneSize * 1e-3f), 304 Random(sceneSize * 1e-3f), 305 Random(sceneSize * 1e-3f)); 306 307 midPoint += offset; 308 309 mNear = 1; 310 mFar = sceneSize * 2; 311 mWidth = sceneSize; 312 313 ComputeLookAt(alpha, 314 beta, 315 mEyeVec, 316 mUpVec, 317 mLeftVec); 318 319 mViewPoint = midPoint - 0.5f * sceneSize * mEyeVec; 320 321 cout << "mid point: " << midPoint << endl; 322 cout << "view point: " << mViewPoint << endl; 323 cout << "scene: " << bbox << endl; 324 292 void GlobalLinesRenderer::InitRenderTexture(RenderTexture *rt) 293 { 325 294 // setup the rendering context for the RenderTexture 326 mNewTexture->BeginCapture();295 rt->BeginCapture(); 327 296 { 328 297 //Reshape(mTexWidth, mTexHeight); … … 346 315 glLoadIdentity(); 347 316 gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 348 m idPoint.x, midPoint.y, midPoint.z,317 mTermination.x, mTermination.y, mTermination.z, 349 318 mUpVec.x, mUpVec.y, mUpVec.z); 350 319 351 320 } 352 mNewTexture->EndCapture(); 353 354 // setup the rendering context for the other depth buffer 355 mOldTexture->BeginCapture(); 356 { 357 // for item buffer: white means no color 358 glClearColor(1, 1, 1, 1); 359 360 //Reshape(mTexWidth, mTexHeight); 361 glViewport(0, 0, mTexWidth, mTexHeight); 362 SetFrustum(mWidth, mWidth, mNear, mFar); 363 364 glMatrixMode(GL_MODELVIEW); 365 glLoadIdentity(); 321 rt->EndCapture(); 322 } 323 324 325 void GlobalLinesRenderer::InitScene(const float alpha, const float beta) 326 { 327 AxisAlignedBox3 bbox = 328 globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 329 330 const float sceneSize = Magnitude(bbox.Diagonal()); 331 332 // compute the center of the scene 333 mTermination = bbox.Center(); 334 335 // add a small offset to provide some randomness in the sampling 336 if (0) 337 { 338 Vector3 offset( 339 Random(sceneSize * 1e-3f), 340 Random(sceneSize * 1e-3f), 341 Random(sceneSize * 1e-3f)); 342 343 mTermination += offset; 344 } 366 345 367 glFrontFace(GL_CCW); 368 glCullFace(GL_BACK); 369 370 glDisable(GL_CULL_FACE); 371 //glEnable(GL_CULL_FACE); 372 373 glShadeModel(GL_FLAT); 374 glEnable(GL_DEPTH_TEST); 375 376 gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 377 midPoint.x, midPoint.y, midPoint.z, 378 mUpVec.x, mUpVec.y, mUpVec.z); 379 } 380 mOldTexture->EndCapture(); 381 346 mNear = 1; 347 mFar = sceneSize * 2; 348 mWidth = sceneSize; 349 350 ComputeLookAt(alpha, 351 beta, 352 mEyeVec, 353 mUpVec, 354 mLeftVec); 355 356 mViewPoint = mTermination - 0.5f * sceneSize * mEyeVec; 357 358 cout << "termination point: " << mTermination << endl; 359 cout << "view point: " << mViewPoint << endl; 360 cout << "scene: " << bbox << endl; 361 362 InitRenderTexture(mNewTexture); 363 InitRenderTexture(mOldTexture); 364 365 cout << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 366 } 367 368 369 void GlobalLinesRenderer::InitScene(const SimpleRay &ray) 370 { 371 AxisAlignedBox3 bbox = 372 globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 373 374 const float sceneSize = Magnitude(bbox.Diagonal()); 375 376 // compute the center of the scene 377 mViewPoint = ray.mOrigin; 378 mTermination = ray.mOrigin + ray.mDirection; 379 380 mEyeVec = Normalize(ray.mDirection); 381 382 mNear = 1; 383 mFar = sceneSize * 2; 384 mWidth = sceneSize; 385 386 mEyeVec.RightHandedBase(mUpVec, mLeftVec); 387 mViewPoint = mTermination - 0.5f * sceneSize * mEyeVec; 388 389 cout << "termination point: " << mTermination << endl; 390 cout << "view point: " << mViewPoint << endl; 391 cout << "scene: " << bbox << endl; 392 393 InitRenderTexture(mNewTexture); 394 InitRenderTexture(mOldTexture); 395 382 396 cout << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 383 397 } … … 395 409 } 396 410 411 412 void GlobalLinesRenderer::CastGlobalLines(const SimpleRay &ray, 413 VssRayContainer &rays) 414 { 415 InitScene(ray); 416 417 // bind pixel shader implementing the front depth buffer functionality 418 ApplyDepthPeeling(rays); 419 } 397 420 398 421 void GlobalLinesRenderer::RenderObject(Intersectable *obj) … … 438 461 Vector3 &left) 439 462 { 440 //float x = cos(alpha);441 //float y = sin(alpha);442 463 eye.x = sin(alpha) * cos(beta); 443 464 eye.y = sin(alpha) * sin(beta); 444 465 eye.z = cos(alpha); 445 466 446 //eye = Normalize(eye);447 467 eye.RightHandedBase(up, left); 448 468 } … … 637 657 638 658 639 voidGlobalLinesRenderer::ProcessDepthBuffer(VssRayContainer &vssRays,659 bool GlobalLinesRenderer::ProcessDepthBuffer(VssRayContainer &vssRays, 640 660 const bool oldBufferInitialised, 641 661 const int pass) … … 660 680 mOldItemBuffer[i * 4 + 3] = 255; 661 681 } 682 } 683 684 ///////////////// 685 // test for validity 686 687 bool buffersEqual = true; 688 bool bufferEmpty = true; 689 690 for (int y = 0; y < mTexHeight; ++ y) 691 { 692 for (int x = 0; x < mTexWidth; ++ x) 693 { 694 const int depthIndex = x + mTexWidth * y; 695 const int itemIndex = 4 * depthIndex; 696 697 if (mOldItemBuffer[itemIndex] != mNewItemBuffer[itemIndex]) 698 { 699 buffersEqual = false; 700 } 701 702 unsigned char r = mNewItemBuffer[itemIndex]; 703 unsigned char g = mNewItemBuffer[itemIndex + 1]; 704 unsigned char b = mNewItemBuffer[itemIndex + 2]; 705 706 // 3 times 255 means no valid object 707 if (!((r == 255) && (g == 255) && (b == 255))) 708 { 709 bufferEmpty = false; 710 } 711 } 712 713 // early exit 714 if (!buffersEqual && !bufferEmpty) 715 break; 716 } 717 718 // depth buffer not valid 719 if (buffersEqual || bufferEmpty) 720 { 721 cout << "stopped at layer " << pass << endl; 722 return false; 662 723 } 663 724 … … 698 759 } 699 760 700 if ( termObj2)761 if (mSampleReverse && termObj2) 701 762 { 702 763 vssRays.push_back(new VssRay(clippedNewPt, clippedOldPt, NULL, termObj2, pass)); … … 705 766 } 706 767 } 768 769 return true; 707 770 } 708 771 … … 912 975 913 976 // process the buffers for following layer 914 ProcessDepthBuffer(rays, true, i); 977 // jump out of loop for the first invalid buffer 978 if (!ProcessDepthBuffer(rays, true, i)) 979 break; 915 980 } 916 981 -
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h
r1964 r1968 15 15 class Preprocessor; 16 16 class GlRenderer; 17 struct SimpleRay; 17 18 18 19 struct VssRayContainer; … … 23 24 24 25 GlobalLinesRenderer(Preprocessor *preprocessor, 25 GlRenderer *renderer, 26 const float texHeight, 27 const float mTexWidth, 28 const float eps); 26 const int texHeight, 27 const int mTexWidth, 28 const float eps, 29 const int maxDepth, 30 const bool sampleReverse); 29 31 30 GlobalLinesRenderer(Preprocessor *preprocessor , GlRenderer *renderer);32 GlobalLinesRenderer(Preprocessor *preprocessor); 31 33 32 34 ~GlobalLinesRenderer(); … … 39 41 const float beta, 40 42 VssRayContainer &rays); 43 44 /** Casts global lines using the given ray as origin and 45 direction vector. 46 @returns Computed samples in the container rays 47 */ 48 void CastGlobalLines(const SimpleRay &ray, 49 VssRayContainer &rays); 50 41 51 42 52 void InitGl(); … … 62 72 void ExportDepthBuffer(); 63 73 void ExportItemBuffer(); 64 voidProcessDepthBuffer(VssRayContainer &vssRays,74 bool ProcessDepthBuffer(VssRayContainer &vssRays, 65 75 const bool oldBufferInitialised, 66 76 const int pass); … … 83 93 84 94 int mMaxDepth; 95 85 96 Vector3 mEyeVec; 86 97 Vector3 mLeftVec; 87 98 Vector3 mUpVec; 99 Vector3 mTermination; 100 88 101 float mFar; 89 102 float mNear; … … 94 107 float *mNewDepthBuffer; 95 108 float *mOldDepthBuffer; 109 96 110 unsigned char *mNewItemBuffer; 97 111 unsigned char *mOldItemBuffer; … … 105 119 Vector3 &up, 106 120 Vector3 &left); 121 107 122 protected: 108 123 … … 110 125 111 126 void InitScene(const float alpha, const float beta); 127 void InitScene(const SimpleRay &ray); 128 129 void InitRenderTexture(RenderTexture *rt); 112 130 113 131 Preprocessor *mPreprocessor; … … 118 136 int mTexHeight; 119 137 float mEpsilon; 138 139 bool mSampleReverse; 120 140 }; 121 141 -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1966 r1968 21 21 #include "IntelRayCaster.h" 22 22 #include "InternalRayCaster.h" 23 23 #include "GlobalLinesRenderer.h" 24 24 25 25 … … 134 134 mRayCaster(NULL), 135 135 mStopComputation(false), 136 mThread(NULL) 136 mThread(NULL), 137 mGlobalLinesRenderer(NULL) 137 138 { 138 139 Environment::GetSingleton()->GetBoolValue("Preprocessor.useGlRenderer", mUseGlRenderer); … … 174 175 mSamplesPerEvaluation); 175 176 176 177 177 Debug << "******* Preprocessor Options **********" << endl; 178 178 Debug << "detect empty view space=" << mDetectEmptyViewSpace << endl; … … 211 211 DEL_PTR(renderer); 212 212 DEL_PTR(mRayCaster); 213 214 DEL_PTR(mGlobalLinesRenderer); 213 215 } 214 216 … … 1074 1076 1075 1077 1076 bool Preprocessor::InitRayCast(const string externKdTree, const string internKdTree) 1078 bool Preprocessor::InitRayCast(const string externKdTree, 1079 const string internKdTree) 1077 1080 { 1078 1081 // always try to load the kd tree … … 1081 1084 if (!LoadKdTree(internKdTree)) 1082 1085 { 1083 cout << "error loading kd tree with filename " << internKdTree << ", rebuilding it instead ... " << endl; 1086 cout << "error loading kd tree with filename " 1087 << internKdTree << ", rebuilding it instead ... " << endl; 1084 1088 // build new kd tree from scene geometry 1085 1089 BuildKdTree(); … … 1091 1095 if (!ExportKdTree(internKdTree)) 1092 1096 { 1093 cout << " error exporting kd tree with filename " << internKdTree << endl; 1097 cout << " error exporting kd tree with filename " 1098 << internKdTree << endl; 1094 1099 } 1095 1100 else 1096 1101 { 1097 cout << "finished in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs" << endl; 1102 cout << "finished in " 1103 << TimeDiff(startTime, GetTime()) * 1e-3 1104 << " secs" << endl; 1098 1105 } 1099 1106 } … … 1114 1121 1115 1122 int rayCastMethod; 1116 Environment::GetSingleton()->GetIntValue("Preprocessor.rayCastMethod", rayCastMethod); 1123 Environment::GetSingleton()-> 1124 GetIntValue("Preprocessor.rayCastMethod", rayCastMethod); 1117 1125 1118 1126 if (rayCastMethod == 0) … … 1145 1153 for (int i = 0; i < (int)rays.size();) 1146 1154 { 1155 // HACK: does not really go together with the 16 ray bundles 1156 if (rays[i].mDistribution == SamplingStrategy::HW_GLOBAL_LINES_DISTRIBUTION) 1157 { 1158 mGlobalLinesRenderer->CastGlobalLines(rays[i], vssRays); 1159 i ++; 1160 continue; 1161 } 1162 1147 1163 if (i + 16 < (int)rays.size()) 1148 1164 { … … 1173 1189 if (rays.size() > 10000) 1174 1190 { 1175 cout<<endl;1176 1177 long t2 = GetTime();1191 cout << endl; 1192 1193 long t2 = GetTime(); 1178 1194 1179 1195 #if SHOW_RAYCAST_TIMING 1180 if (castDoubleRays)1181 1182 else1183 cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl;1196 if (castDoubleRays) 1197 cout << 2 * rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 1198 else 1199 cout << rays.size() / (1e3f * TimeDiff(t1, t2)) << "M rays/s" << endl; 1184 1200 #endif 1185 1201 } … … 1230 1246 ray.Init(point, direction, Ray::LOCAL_RAY); 1231 1247 } 1248 1232 1249 1233 1250 void Preprocessor::EvalViewCellHistogram() … … 1326 1343 } 1327 1344 1328 } 1345 1346 void Preprocessor::PrepareHwGlobalLines() 1347 { 1348 int texHeight, texWidth; 1349 float eps; 1350 int maxDepth; 1351 bool sampleReverse; 1352 1353 Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.texHeight", texHeight); 1354 Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.texHeight", texWidth); 1355 Environment::GetSingleton()->GetFloatValue("Preprocessor.HwGlobalLines.stepSize", eps); 1356 Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.maxDepth", maxDepth); 1357 Environment::GetSingleton()->GetBoolValue("Preprocessor.HwGlobalLines.sampleReverse", sampleReverse); 1358 1359 mGlobalLinesRenderer = 1360 new GlobalLinesRenderer(this, 1361 texHeight, 1362 texWidth, 1363 eps, 1364 maxDepth, 1365 sampleReverse); 1366 1367 mGlobalLinesRenderer->InitGl(); 1368 } 1369 1370 } -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.h
r1966 r1968 29 29 class VssRay; 30 30 class RayCaster; 31 31 class GlobalLinesRenderer; 32 32 33 33 … … 174 174 Intersectable *GetObjectById(const int id); 175 175 176 176 void PrepareHwGlobalLines(); 177 177 //////////////////////////////////////////////// 178 178 … … 234 234 235 235 int mTotalSamples; 236 237 236 int mSamplesPerPass; 237 int mSamplesPerEvaluation; 238 238 239 239 protected: … … 253 253 ///////////////////////// 254 254 255 GlobalLinesRenderer *mGlobalLinesRenderer; 255 256 RayCaster *mRayCaster; 256 257 /// samples used for construction of the BSP view cells tree. -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.vcproj
r1958 r1968 316 316 OptimizeForWindowsApplication="TRUE" 317 317 AdditionalIncludeDirectories="..\src;..\..\..\..\..\..\NonGTP\Devil\include;..\..\..\..\..\..\NonGTP\Zlib\include;..\..\..\..\..\..\NonGTP\Xerces;..\..\..\..\..\..\NonGTP\Boost;..\MultiLevelRayTracing;"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtGui";"$(QTDIR)\include";"$(QTDIR)\include\QtOpenGl";"$(CG_INC_PATH)"" 318 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_QT "318 PreprocessorDefinitions="WIN32;NDEBUG;_LIB;USE_QT;ATI" 319 319 ExceptionHandling="TRUE" 320 320 RuntimeLibrary="2" -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp
r1966 r1968 18 18 HaltonSequence ObjectDirectionBasedDistribution::sHalton; 19 19 HaltonSequence DirectionBasedDistribution::sHalton; 20 HaltonSequence HwGlobalLinesDistribution::sHalton; 20 21 21 22 22 23 SamplingStrategy::SamplingStrategy(Preprocessor &preprocessor): 23 mPreprocessor(preprocessor), mRatio(1.0f), mTotalRays(0), mTotalContribution(0.0f) 24 { 25 24 mPreprocessor(preprocessor), 25 mRatio(1.0f), 26 mTotalRays(0), 27 mTotalContribution(0.0f) 28 { 26 29 } 27 30 … … 415 418 return true; 416 419 } 417 418 419 420 420 421 … … 839 840 } 840 841 841 } 842 843 842 843 bool HwGlobalLinesDistribution::GenerateSample(SimpleRay &ray) 844 { 845 Vector3 origin, termination, direction; 846 847 float radius = 0.5f * 848 Magnitude(mPreprocessor.mViewCellsManager->GetViewSpaceBox().Size()); 849 850 Vector3 center = mPreprocessor.mViewCellsManager->GetViewSpaceBox().Center(); 851 852 const int tries = 1000; 853 int i; 854 for (i=0; i < tries; i++) 855 { 856 float r[2]; 857 sHalton.GetNext(2, r); 858 859 origin = center + (radius * UniformRandomVector(r[0], r[1])); 860 termination = center; 861 862 if (0) 863 { 864 // add a small offset to provide some more randomness in the sampling 865 Vector3 offset(Random(radius * 1e-3f), 866 Random(radius * 1e-3f), 867 Random(radius * 1e-3f)); 868 termination += offset; 869 } 870 871 direction = termination - origin; 872 873 // $$ jb the pdf is yet not correct for all sampling methods! 874 const float c = Magnitude(direction); 875 876 if (c <= Limits::Small) 877 return false; 878 879 direction *= 1.0f / c; 880 881 // check if the ray intersects the view space box 882 static Ray ray; 883 ray.Init(origin, direction, Ray::LOCAL_RAY); 884 885 float tmin, tmax; 886 if (mPreprocessor.mViewCellsManager-> 887 GetViewSpaceBox().ComputeMinMaxT(ray, &tmin, &tmax) && (tmin < tmax)) 888 break; 889 } 890 891 if (i != tries) 892 { 893 // $$ jb the pdf is yet not correct for all sampling methods! 894 const float pdf = 1.0f; 895 896 ray = SimpleRay(origin, direction, HW_GLOBAL_LINES_DISTRIBUTION, pdf); 897 ray.mType = Ray::GLOBAL_RAY; 898 return true; 899 } 900 901 return false; 902 } 903 904 905 } 906 907 -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
r1966 r1968 25 25 enum 26 26 { 27 28 27 DUMMY_DISTRIBUTION = 0, 28 DIRECTION_BASED_DISTRIBUTION, 29 29 OBJECT_BASED_DISTRIBUTION, 30 30 DIRECTION_BOX_BASED_DISTRIBUTION, … … 39 39 VIEWSPACE_BORDER_BASED_DISTRIBUTION, 40 40 REVERSE_VIEWSPACE_BORDER_BASED_DISTRIBUTION, 41 42 43 MUTATION_BASED_DISTRIBUTION44 41 GLOBAL_LINES_DISTRIBUTION, 42 GVS, 43 MUTATION_BASED_DISTRIBUTION, 44 HW_GLOBAL_LINES_DISTRIBUTION 45 45 }; 46 46 -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1949 r1968 258 258 } 259 259 260 261 bool useHwGlobalLines; 262 Environment::GetSingleton()->GetBoolValue("Preprocessor.useHwGlobalLines", 263 useHwGlobalLines); 264 265 if (useHwGlobalLines) 266 preprocessor->PrepareHwGlobalLines(); 267 260 268 // create a preprocessor thread (note: capsulates calls to boost fuctions!) 261 269 PreprocessorThread *pt = NULL; 262 270 263 271 #ifdef TRY_GLOBAL_LINES 264 GlRenderer *renderer = new GlRenderer(preprocessor->mSceneGraph, 265 preprocessor->mViewCellsManager, 266 preprocessor->mKdTree); 267 268 globalLinesRenderer = new GlobalLinesRenderer(preprocessor, renderer); 272 273 globalLinesRenderer = new GlobalLinesRenderer(preprocessor); 269 274 globalLinesRenderer->InitGl(); 270 275 globalLinesRenderer->Run(); 271 276 277 //delete renderer; 272 278 #else 273 279
Note: See TracChangeset
for help on using the changeset viewer.