- Timestamp:
- 01/10/07 18:20:53 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
r1963 r1964 28 28 static CGprofile sCgFragmentProfile; 29 29 static CGparameter sTextureParam; 30 static CGparameter sTexWidthParam; 31 static CGparameter sStepSizeParam; 30 32 31 33 GlobalLinesRenderer *globalLinesRenderer = NULL; 32 33 //static int texWidth = 32;34 //static int texHeight = 32;35 static int texWidth = 256;36 static int texHeight = 256;37 34 38 35 static bool isDepth = true; … … 137 134 138 135 ++ globalLinesRenderer->mMaxDepth; 139 globalLinesRenderer->ApplyDepthPeeling(rays , Beam(), 0);136 globalLinesRenderer->ApplyDepthPeeling(rays); 140 137 141 138 cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl; … … 150 147 cout << "max depth: " << globalLinesRenderer->mMaxDepth << endl; 151 148 152 globalLinesRenderer->ApplyDepthPeeling(rays , Beam(), 0);149 globalLinesRenderer->ApplyDepthPeeling(rays); 153 150 CLEAR_CONTAINER(rays); 154 151 return; … … 156 153 case '3': 157 154 { 158 //globalLinesRenderer->ApplyDepthPeeling(Beam(), 0);159 155 globalLinesRenderer->ExportDepthBuffer(); 160 161 156 return; 162 157 } 163 158 case '4': 164 159 { 165 //globalLinesRenderer->ApplyDepthPeeling(Beam(), 0);166 160 globalLinesRenderer->ExportItemBuffer(); 167 168 161 return; 169 162 } … … 176 169 { 177 170 VssRayContainer rays; 178 globalLinesRenderer->ApplyDepthPeeling(rays , Beam(), 0);171 globalLinesRenderer->ApplyDepthPeeling(rays); 179 172 VssRayContainer outRays; 180 173 VssRayContainer::const_iterator vit, vit_end = rays.end(); … … 197 190 { 198 191 VssRayContainer rays; 199 globalLinesRenderer->ApplyDepthPeeling(rays , Beam(), 0);192 globalLinesRenderer->ApplyDepthPeeling(rays); 200 193 CLEAR_CONTAINER(rays); 201 194 return; … … 219 212 220 213 GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor, 221 GlRenderer *renderer): 214 GlRenderer *renderer, 215 const float mTexHeight, 216 const float mTexWidth, 217 const float eps): 222 218 mNewTexture(NULL), 223 219 mOldTexture(NULL), 224 220 mMaxDepth(0), 225 221 mRenderer(renderer), 226 mPreprocessor(preprocessor) 227 { 228 } 222 mPreprocessor(preprocessor), 223 mTexHeight(mTexHeight), 224 mTexWidth(mTexWidth), 225 mEpsilon(eps) 226 { 227 } 228 229 230 GlobalLinesRenderer::GlobalLinesRenderer(Preprocessor *preprocessor, 231 GlRenderer *renderer): 232 mNewTexture(NULL), 233 mOldTexture(NULL), 234 mMaxDepth(0), 235 mRenderer(renderer), 236 mPreprocessor(preprocessor), 237 mTexHeight(128), 238 mTexWidth(128), 239 mEpsilon(0.0001) 240 {} 229 241 230 242 … … 279 291 280 292 281 void GlobalLinesRenderer::CastGlobalLines(Beam &beam, const int samples) 282 { 283 VssRayContainer rays; 284 285 // bind pixel shader implementing the front depth buffer functionality 286 ApplyDepthPeeling(rays, beam, samples); 287 } 288 289 290 void GlobalLinesRenderer::RenderObject(Intersectable *obj) 291 { 292 mRenderer->RenderIntersectable(obj); 293 } 294 295 296 void GlobalLinesRenderer::DrawGeometry() 297 { 298 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 299 glMatrixMode(GL_MODELVIEW); 300 301 glPushMatrix(); 302 { 303 //glLoadIdentity(); 304 ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end(); 305 306 Intersectable::NewMail(); 307 308 for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 309 { 310 //cout << (*oit)->GetId() << " "; 311 RenderObject(*oit); 312 } 313 } 314 glPopMatrix(); 315 } 316 317 318 void GlobalLinesRenderer::SwitchRenderTextures() 319 { 320 RenderTexture *buffer = mOldTexture; 321 mOldTexture = mNewTexture; 322 mNewTexture = buffer; 323 } 324 325 326 void GlobalLinesRenderer::ComputeLookAt(const float alpha, 327 const float beta, 328 Vector3 &eye, 329 Vector3 &up, 330 Vector3 left) 331 { 332 //float x = cos(alpha); 333 //float y = sin(alpha); 334 eye.x = sin(alpha) * cos(beta); 335 eye.y = sin(alpha) * sin(beta); 336 eye.z = cos(beta); 337 338 eye.RightHandedBase(up, left); 339 } 340 341 342 void GlobalLinesRenderer::InitGl() 343 { 344 InitDevIl(); 345 346 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 347 glutInitWindowPosition(50, 50); 348 glutInitWindowSize(512, 512); 349 glutCreateWindow("TestRenderDepthTexture"); 350 351 int err = glewInit(); 352 if (GLEW_OK != err) 353 { 354 // problem: glewInit failed, something is seriously wrong 355 fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); 356 exit(-1); 357 } 358 359 glutKeyboardFunc(Keyboard); 360 glutDisplayFunc(Display); 361 glutIdleFunc(Idle); 362 glutReshapeFunc(Reshape); 363 364 Reshape(512, 512); 365 glMatrixMode(GL_MODELVIEW); 366 glLoadIdentity(); 367 368 // initialise the receiving buffers 369 mNewDepthBuffer = new float[texWidth * texHeight]; 370 mNewItemBuffer = new unsigned char[texWidth * texHeight * 4]; 371 372 mOldDepthBuffer = new float[texWidth * texHeight]; 373 mOldItemBuffer = new unsigned char[texWidth * texHeight * 4]; 374 375 for (int i = 0; i < texWidth * texHeight; ++ i) 376 { 377 mNewDepthBuffer[i] = 1; 378 mOldDepthBuffer[i] = 1; 379 380 mNewItemBuffer[i * 4] = 255; 381 mNewItemBuffer[i * 4 + 1] = 255; 382 mNewItemBuffer[i * 4 + 2] = 255; 383 mNewItemBuffer[i * 4 + 3] = 255; 384 385 mOldItemBuffer[i * 4] = 255; 386 mOldItemBuffer[i * 4 + 1] = 255; 387 mOldItemBuffer[i * 4 + 2] = 255; 388 mOldItemBuffer[i * 4 + 3] = 255; 389 } 390 293 void GlobalLinesRenderer::InitScene(const float alpha, const float beta) 294 { 391 295 AxisAlignedBox3 bbox = globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 392 296 297 const float sceneSize = Magnitude(bbox.Diagonal()); 298 299 // compute the center of the scene 393 300 Vector3 midPoint = bbox.Center(); 394 301 395 const float sceneSize = Magnitude(bbox.Diagonal()); 396 mViewPoint = midPoint + Vector3(0.5 * sceneSize, 0, 0.5 * sceneSize); 397 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 398 321 cout << "mid point: " << midPoint << endl; 399 322 cout << "view point: " << mViewPoint << endl; 400 323 cout << "scene: " << bbox << endl; 401 324 402 mNear = 1; 403 mFar = sceneSize * 2; 404 mWidth = sceneSize; 405 406 mEyeVec = Normalize(midPoint - mViewPoint); 407 mEyeVec.RightHandedBase(mUpVec, mLeftVec); 408 409 /*gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 410 midPoint.x, midPoint.y, midPoint.z, 411 0, 1, 0); 412 */ 413 gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0); 414 415 //glDisable(GL_CULL_FACE); 416 glEnable(GL_CULL_FACE); 417 glDisable(GL_LIGHTING); 418 glDisable(GL_COLOR_MATERIAL); 419 glEnable(GL_DEPTH_TEST); 420 glClearColor(0.1, 0.2, 0.3, 1); 421 422 // A square, mipmapped, anisotropically filtered 8-bit RGBA texture with 423 // depth and stencil. 424 // Note that RT_COPY_TO_TEXTURE is required for depth textures on ATI hardware 425 426 mNewTexture = new RenderTexture(texWidth, texHeight, true, true); 427 //mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 428 mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 429 430 mOldTexture = new RenderTexture(texWidth, texHeight, true, true); 431 //mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 432 mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 433 434 // Setup Cg 435 cgSetErrorCallback(cgErrorCallback); 436 437 // Create cgContext. 438 sCgContext = cgCreateContext(); 439 440 // get the best profile for this hardware 441 sCgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); 442 443 //assert(sCgFragmentProfile != CG_PROFILE_UNKNOWN); 444 cgGLSetOptimalOptions(sCgFragmentProfile); 445 446 sCgDepthPeelingProgram = 447 cgCreateProgramFromFile(sCgContext, 448 CG_SOURCE, 449 mNewTexture->IsRectangleTexture() ? 450 "../src/depth_peelingRect.cg" : "../src/depth_peeling2d.cg", 451 GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 452 NULL, 453 NULL); 454 455 if(sCgDepthPeelingProgram != NULL) 456 { 457 cgGLLoadProgram(sCgDepthPeelingProgram); 458 sTextureParam = cgGetNamedParameter(sCgDepthPeelingProgram, "depthTex"); 459 } 460 461 sCgPassThroughProgram = 462 cgCreateProgramFromFile(sCgContext, 463 CG_SOURCE, 464 "../src/passthrough.cg", 465 GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 466 NULL, 467 NULL); 468 469 if(sCgPassThroughProgram != NULL) 470 { 471 cgGLLoadProgram(sCgPassThroughProgram); 472 } 473 474 // setup the rendering context for the RenderTexture 325 // setup the rendering context for the RenderTexture 475 326 mNewTexture->BeginCapture(); 476 327 { 477 //Reshape( texWidth, texHeight);478 glViewport(0, 0, texWidth, texHeight);328 //Reshape(mTexWidth, mTexHeight); 329 glViewport(0, 0, mTexWidth, mTexHeight); 479 330 SetFrustum(mWidth, mWidth, mNear, mFar); 480 331 … … 496 347 gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 497 348 midPoint.x, midPoint.y, midPoint.z, 498 0, 1, 0);349 mUpVec.x, mUpVec.y, mUpVec.z); 499 350 500 351 } … … 507 358 glClearColor(1, 1, 1, 1); 508 359 509 //Reshape( texWidth, texHeight);510 glViewport(0, 0, texWidth, texHeight);360 //Reshape(mTexWidth, mTexHeight); 361 glViewport(0, 0, mTexWidth, mTexHeight); 511 362 SetFrustum(mWidth, mWidth, mNear, mFar); 512 363 … … 525 376 gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 526 377 midPoint.x, midPoint.y, midPoint.z, 527 0, 1, 0); 528 529 //SetFrustum(sceneSize, sceneSize, 1, sceneSize); 378 mUpVec.x, mUpVec.y, mUpVec.z); 530 379 } 531 380 mOldTexture->EndCapture(); 381 382 cout << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 383 } 384 385 386 void GlobalLinesRenderer::CastGlobalLines(const float alpha, 387 const float beta, 388 //const int samples, 389 VssRayContainer &rays) 390 { 391 InitScene(alpha, beta); 392 393 // bind pixel shader implementing the front depth buffer functionality 394 ApplyDepthPeeling(rays); 395 } 396 397 398 void GlobalLinesRenderer::RenderObject(Intersectable *obj) 399 { 400 mRenderer->RenderIntersectable(obj); 401 } 402 403 404 void GlobalLinesRenderer::DrawGeometry() 405 { 406 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 407 glMatrixMode(GL_MODELVIEW); 408 409 glPushMatrix(); 410 { 411 //glLoadIdentity(); 412 ObjectContainer::const_iterator oit, oit_end = mPreprocessor->mObjects.end(); 413 414 Intersectable::NewMail(); 415 416 for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 417 { 418 //cout << (*oit)->GetId() << " "; 419 RenderObject(*oit); 420 } 421 } 422 glPopMatrix(); 423 } 424 425 426 void GlobalLinesRenderer::SwitchRenderTextures() 427 { 428 RenderTexture *buffer = mOldTexture; 429 mOldTexture = mNewTexture; 430 mNewTexture = buffer; 431 } 432 433 434 void GlobalLinesRenderer::ComputeLookAt(const float alpha, 435 const float beta, 436 Vector3 &eye, 437 Vector3 &up, 438 Vector3 &left) 439 { 440 //float x = cos(alpha); 441 //float y = sin(alpha); 442 eye.x = sin(alpha) * cos(beta); 443 eye.y = sin(alpha) * sin(beta); 444 eye.z = cos(alpha); 445 446 //eye = Normalize(eye); 447 eye.RightHandedBase(up, left); 448 } 449 450 451 void GlobalLinesRenderer::InitGl() 452 { 453 InitDevIl(); 454 455 glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE); 456 glutInitWindowPosition(50, 50); 457 glutInitWindowSize(512, 512); 458 glutCreateWindow("TestRenderDepthTexture"); 459 460 int err = glewInit(); 461 if (GLEW_OK != err) 462 { 463 // problem: glewInit failed, something is seriously wrong 464 fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err)); 465 exit(-1); 466 } 467 468 glutKeyboardFunc(Keyboard); 469 glutDisplayFunc(Display); 470 glutIdleFunc(Idle); 471 glutReshapeFunc(Reshape); 472 473 Reshape(512, 512); 474 glMatrixMode(GL_MODELVIEW); 475 glLoadIdentity(); 476 477 // initialise the receiving buffers 478 mNewDepthBuffer = new float[mTexWidth * mTexHeight]; 479 mNewItemBuffer = new unsigned char[mTexWidth * mTexHeight * 4]; 480 481 mOldDepthBuffer = new float[mTexWidth * mTexHeight]; 482 mOldItemBuffer = new unsigned char[mTexWidth * mTexHeight * 4]; 483 484 for (int i = 0; i < mTexWidth * mTexHeight; ++ i) 485 { 486 mNewDepthBuffer[i] = 1; 487 mOldDepthBuffer[i] = 1; 488 489 mNewItemBuffer[i * 4] = 255; 490 mNewItemBuffer[i * 4 + 1] = 255; 491 mNewItemBuffer[i * 4 + 2] = 255; 492 mNewItemBuffer[i * 4 + 3] = 255; 493 494 mOldItemBuffer[i * 4] = 255; 495 mOldItemBuffer[i * 4 + 1] = 255; 496 mOldItemBuffer[i * 4 + 2] = 255; 497 mOldItemBuffer[i * 4 + 3] = 255; 498 } 499 500 /*gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z, 501 midPoint.x, midPoint.y, midPoint.z, 502 0, 1, 0); 503 */ 504 gluLookAt(0, 0, 3, 0, 0, 0, 0, 1, 0); 505 506 //glDisable(GL_CULL_FACE); 507 glEnable(GL_CULL_FACE); 508 glDisable(GL_LIGHTING); 509 glDisable(GL_COLOR_MATERIAL); 510 glEnable(GL_DEPTH_TEST); 511 glClearColor(0.1, 0.2, 0.3, 1); 512 513 // A square, mipmapped, anisotropically filtered 8-bit RGBA texture with 514 // depth and stencil. 515 // Note that RT_COPY_TO_TEXTURE is required for depth textures on ATI hardware 516 517 mNewTexture = new RenderTexture(mTexWidth, mTexHeight, true, true); 518 #ifdef ATI 519 mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 520 #else 521 mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 522 #endif 523 524 mOldTexture = new RenderTexture(mTexWidth, mTexHeight, true, true); 525 526 #ifdef ATI 527 mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 528 #else 529 mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 530 #endif 531 532 // Setup Cg 533 cgSetErrorCallback(cgErrorCallback); 534 535 // Create cgContext. 536 sCgContext = cgCreateContext(); 537 538 // get the best profile for this hardware 539 sCgFragmentProfile = cgGLGetLatestProfile(CG_GL_FRAGMENT); 540 541 //assert(sCgFragmentProfile != CG_PROFILE_UNKNOWN); 542 cgGLSetOptimalOptions(sCgFragmentProfile); 543 544 sCgDepthPeelingProgram = 545 cgCreateProgramFromFile(sCgContext, 546 CG_SOURCE, 547 mNewTexture->IsRectangleTexture() ? 548 "../src/depth_peelingRect.cg" : "../src/depth_peeling2d.cg", 549 GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 550 NULL, 551 NULL); 552 553 if(sCgDepthPeelingProgram != NULL) 554 { 555 cgGLLoadProgram(sCgDepthPeelingProgram); 556 sTextureParam = cgGetNamedParameter(sCgDepthPeelingProgram, "depthTex"); 557 558 // we need size of texture for scaling 559 if (!mNewTexture->IsRectangleTexture()) 560 { 561 sTexWidthParam = cgGetNamedParameter(sCgDepthPeelingProgram, "texWidth"); 562 } 563 564 sStepSizeParam = cgGetNamedParameter(sCgDepthPeelingProgram, "stepSize"); 565 566 cgGLSetParameter1f(sTexWidthParam, (float)mTexWidth); 567 cgGLSetParameter1f(sStepSizeParam, mEpsilon); 568 } 569 570 sCgPassThroughProgram = 571 cgCreateProgramFromFile(sCgContext, 572 CG_SOURCE, 573 "../src/passthrough.cg", 574 GLEW_ARB_fragment_program ? CG_PROFILE_ARBFP1 : CG_PROFILE_FP30, 575 NULL, 576 NULL); 577 578 if(sCgPassThroughProgram != NULL) 579 { 580 cgGLLoadProgram(sCgPassThroughProgram); 581 } 582 583 const float alpha = 1.1; 584 const float beta = 0.9; 585 InitScene(alpha, beta); 532 586 533 587 PrintGLerror("init"); … … 542 596 const bool isFrontBuffer) const 543 597 { 544 const int depthIndex = x + texWidth * y;598 const int depthIndex = x + mTexWidth * y; 545 599 const int itemIndex = 4 * depthIndex; 546 600 … … 548 602 const float eyeDist = mNear + (mFar - mNear) * depth; 549 603 550 const float leftDist = 0.5f * mWidth - mWidth * ((float)x + 0.5f) / texWidth; 551 //const float upDist = 0.5f * mWidth - (float)mWidth * ((float)y + 0.5f) / texHeight; 552 const float upDist = -0.5f * mWidth + mWidth * ((float)y + 0.5f) / texHeight; 553 604 const float leftDist = -0.5f * mWidth + mWidth * ((float)x + 0.5f) / mTexWidth; 605 //const float leftDist = 0.5f * mWidth - mWidth * ((float)x + 0.5f) / mTexWidth; 606 607 const float upDist = -0.5f * mWidth + mWidth * ((float)y + 0.5f) / mTexHeight; 608 //const float upDist = 0.5f * mWidth - mWidth * ((float)y + 0.5f) / mTexHeight; 609 554 610 hitPoint = mViewPoint + 555 611 eyeDist * mEyeVec + 556 leftDist * mUpVec +557 upDist * mLeftVec;612 upDist * mUpVec + 613 leftDist * mLeftVec; 558 614 559 615 unsigned char r = itemBuffer[itemIndex]; … … 595 651 else 596 652 { 597 for (int i = 0; i < texWidth * texHeight; ++ i)653 for (int i = 0; i < mTexWidth * mTexHeight; ++ i) 598 654 { 599 655 mOldDepthBuffer[i] = 0; … … 606 662 } 607 663 608 //cout << "vp: " << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 609 610 for (int y = 0; y < texHeight; ++ y) 611 { 612 for (int x = 0; x < texWidth; ++ x) 664 for (int y = 0; y < mTexHeight; ++ y) 665 { 666 for (int x = 0; x < mTexWidth; ++ x) 613 667 { 614 668 Vector3 newPt, oldPt; … … 724 778 } 725 779 726 if (ray->mPass == 4)780 //if (ray->mPass == 4) 727 781 outRays.push_back(ray); 728 782 } … … 738 792 rt->BindDepth(); 739 793 rt->EnableTextureTarget(); 740 //cout << "depth: " << mNewTexture->GetDepthBits() << endl;741 794 742 795 const int texFormat = GL_DEPTH_COMPONENT; … … 751 804 rt->Bind(); 752 805 rt->EnableTextureTarget(); 753 //cout << "depth: " << mNewTexture->GetDepthBits() << endl;754 806 755 807 const int texFormat = GL_RGBA; … … 768 820 const int components = 1;//mNewTexture->GetDepthBits() / 8; 769 821 770 float *data = new float[ texWidth * texHeight * components];822 float *data = new float[mTexWidth * mTexHeight * components]; 771 823 //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 772 824 const int texFormat = GL_DEPTH_COMPONENT; … … 780 832 const int bpp = components; 781 833 782 ilTexImage( texWidth, texHeight, depth, bpp, IL_LUMINANCE, IL_FLOAT, data);834 ilTexImage(mTexWidth, mTexHeight, depth, bpp, IL_LUMINANCE, IL_FLOAT, data); 783 835 ilSaveImage((char *const)filename.c_str()); 784 836 … … 799 851 const int components = 4;//mNewTexture->GetDepthBits() / 8; 800 852 801 unsigned char *data = new unsigned char [ texWidth * texHeight * components];853 unsigned char *data = new unsigned char [mTexWidth * mTexHeight * components]; 802 854 //const int texFormat = WGL_TEXTURE_DEPTH_COMPONENT_NV; 803 855 const int texFormat = GL_RGBA; … … 810 862 const int bpp = components; 811 863 812 ilTexImage( texWidth, texHeight, depth, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data);864 ilTexImage(mTexWidth, mTexHeight, depth, bpp, IL_RGBA, IL_UNSIGNED_BYTE, data); 813 865 ilSaveImage((char *const)filename.c_str()); 814 866 … … 821 873 822 874 823 void GlobalLinesRenderer::ApplyDepthPeeling(VssRayContainer &rays, 824 Beam &beam, 825 const int samples) 875 void GlobalLinesRenderer::ApplyDepthPeeling(VssRayContainer &rays) 826 876 { 827 877 mNewTexture->BeginCapture(); -
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h
r1963 r1964 21 21 { 22 22 public: 23 /*GlobalLinesRenderer(RenderTexture *buffer1, 24 RenderTexture *buffer2, 25 Preprocessor *preprocessor, 26 GlRenderer *renderer); 27 */ 23 24 GlobalLinesRenderer(Preprocessor *preprocessor, 25 GlRenderer *renderer, 26 const float texHeight, 27 const float mTexWidth, 28 const float eps); 29 28 30 GlobalLinesRenderer(Preprocessor *preprocessor, GlRenderer *renderer); 29 31 30 32 ~GlobalLinesRenderer(); 31 33 32 void CastGlobalLines(Beam &beam, const int samples); 34 /** Casts global lines in the angle specified by alpha and 35 beta. 36 @returns Computed samples in the container rays 37 */ 38 void CastGlobalLines(const float alpha, 39 const float beta, 40 VssRayContainer &rays); 33 41 34 42 void InitGl(); … … 51 59 void GrabDepthBuffer(float *data, RenderTexture *rt); 52 60 void GrabItemBuffer(unsigned char *data, RenderTexture *rt); 53 void ApplyDepthPeeling(VssRayContainer &rays , Beam &beam, const int samples);61 void ApplyDepthPeeling(VssRayContainer &rays); 54 62 void ExportDepthBuffer(); 55 63 void ExportItemBuffer(); 56 void ProcessDepthBuffer(VssRayContainer &vssRays, const bool oldBufferInitialised, const int pass); 64 void ProcessDepthBuffer(VssRayContainer &vssRays, 65 const bool oldBufferInitialised, 66 const int pass); 67 57 68 void DisplayBuffer(const bool isDepth); 58 69 … … 93 104 Vector3 &eye, 94 105 Vector3 &up, 95 Vector3 left);106 Vector3 &left); 96 107 protected: 97 108 98 109 void SwitchRenderTextures(); 99 110 100 void SetupProjection(const Vector3 &viewPoint, 101 const Beam &beam); 102 103 111 void InitScene(const float alpha, const float beta); 104 112 105 113 Preprocessor *mPreprocessor; 106 114 107 115 GlRenderer *mRenderer; 116 117 int mTexWidth; 118 int mTexHeight; 119 float mEpsilon; 108 120 }; 109 121 -
GTP/trunk/Lib/Vis/Preprocessing/src/InternalRayCaster.cpp
r1883 r1964 29 29 { 30 30 if (simpleRay.mType == Ray::GLOBAL_RAY) 31 return CastGlobalRay(simpleRay, vssRays, box, pruneInvalidRays);31 return CastGlobalRay(simpleRay, vssRays, box, pruneInvalidRays); 32 32 33 33 //cout << "internal ray" << endl; … … 82 82 int 83 83 InternalRayCaster::CastGlobalRay(const SimpleRay &simpleRay, 84 85 86 87 84 VssRayContainer &vssRays, 85 const AxisAlignedBox3 &box, 86 const bool pruneInvalidRays 87 ) 88 88 { 89 89 static Ray ray; -
GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.h
r1952 r1964 59 59 virtual bool GenerateSample(SimpleRay &ray) = 0; 60 60 61 62 63 64 65 66 67 68 69 70 return a->mRatio < b->mRatio;71 61 // true if the strategy keeps pointers to rays and thus they should get deleted 62 // outside, in that case the strategy has to use reference counting and deleting the rays 63 // by itself if the number of references drops to zero 64 virtual bool RequiresRays() { return false; } 65 66 67 virtual void Update(VssRayContainer &vssRays) {} 68 69 friend bool LowerRatio(const SamplingStrategy *a, const SamplingStrategy *b) { 70 return a->mRatio < b->mRatio; 71 } 72 72 73 73 public: … … 262 262 263 263 264 class HwGlobalLinesDistribution: public SamplingStrategy 265 { 266 public: 267 268 HwGlobalLinesDistribution(Preprocessor &preprocessor): 269 SamplingStrategy(preprocessor) { 270 //mType = HW_GLOBAL_LINES_DISTRIBUTION; 271 } 272 273 private: 274 275 virtual bool GenerateSample(SimpleRay &ray); 276 static HaltonSequence sHalton; 277 }; 278 264 279 /** This strategy generates samples inside of the objects, e.g., 265 280 for sampling the inside of a colon. -
GTP/trunk/Lib/Vis/Preprocessing/src/depth_peeling2d.cg
r1962 r1964 2 2 float3 main(in float4 col : COL0, 3 3 in float3 pos : WPOS, 4 uniform float texWidth, 5 uniform float stepSize, 4 6 uniform sampler2D depthTex) : COLOR 5 7 { 6 float zold = tex2D(depthTex, pos.xy / 256.0);8 float zold = tex2D(depthTex, pos.xy / texWidth); 7 9 8 if(pos.z < (zold + 0.00001))10 if(pos.z < (zold + stepSize)) 9 11 discard; 10 12 else; -
GTP/trunk/Lib/Vis/Preprocessing/src/depth_peelingRect.cg
r1950 r1964 2 2 float3 main(in float4 col : COL0, 3 3 in float3 pos : WPOS, 4 uniform float stepSize, 4 5 uniform samplerRect depthTex) : COLOR 5 6 { 6 7 float zold = texRect(depthTex, pos.xy); 7 8 8 if(pos.z < (zold + 0.1))9 if(pos.z < (zold + stepSize)) 9 10 discard; 10 11 else;
Note: See TracChangeset
for help on using the changeset viewer.