- Timestamp:
- 01/11/07 21:40:49 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.cpp
r1968 r1969 7 7 #include "Exporter.h" 8 8 #include "ViewCellsManager.h" 9 #include "SamplingStrategy.h" 9 10 10 11 … … 161 162 return; 162 163 } 164 case '5': 165 { 166 VssRayContainer rays; 167 168 HwGlobalLinesDistribution glStrategy(*globalLinesRenderer->mPreprocessor); 169 170 SimpleRayContainer simpleRays; 171 glStrategy.GenerateSamples(5, simpleRays); 172 173 //cout << "simple ray: " << simpleRays[4] << endl; 174 globalLinesRenderer->CastGlobalLines(simpleRays[1], rays); 175 176 // visualize 177 VssRayContainer outRays; 178 VssRayContainer::const_iterator vit, vit_end = rays.end(); 179 180 const float p = 8.0f / (float)rays.size(); 181 182 for (vit = rays.begin(); vit != vit_end; ++ vit) 183 { 184 if (Random(1.0f) < p) 185 { 186 outRays.push_back(*vit); 187 } 188 } 189 190 globalLinesRenderer->Visualize(rays); 191 192 CLEAR_CONTAINER(rays); 193 return; 194 } 163 195 case '8': 164 196 { … … 170 202 VssRayContainer rays; 171 203 globalLinesRenderer->ApplyDepthPeeling(rays); 204 205 // visualize 172 206 VssRayContainer outRays; 173 207 VssRayContainer::const_iterator vit, vit_end = rays.end(); … … 209 243 mOldTexture(NULL), 210 244 mPreprocessor(preprocessor), 211 mTexHeight( mTexHeight),212 mTexWidth( mTexWidth),245 mTexHeight(texHeight), 246 mTexWidth(texWidth), 213 247 mEpsilon(eps), 214 248 mMaxDepth(maxDepth), … … 325 359 void GlobalLinesRenderer::InitScene(const float alpha, const float beta) 326 360 { 361 cout << "here44"<<endl; 327 362 AxisAlignedBox3 bbox = 328 363 globalLinesRenderer->mPreprocessor->mKdTree->GetBox(); 329 364 cout << "here77"<<endl; 330 365 const float sceneSize = Magnitude(bbox.Diagonal()); 331 366 … … 356 391 mViewPoint = mTermination - 0.5f * sceneSize * mEyeVec; 357 392 358 cout << "termination point: " << mTermination << endl;359 cout << "view point: " << mViewPoint << endl;360 cout << "scene: " << bbox << endl;393 //cout << "termination point: " << mTermination << endl; 394 //cout << "view point: " << mViewPoint << endl; 395 //cout << "scene: " << bbox << endl; 361 396 362 397 InitRenderTexture(mNewTexture); 363 398 InitRenderTexture(mOldTexture); 364 399 365 cout << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl;400 //cout << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 366 401 } 367 402 … … 385 420 386 421 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; 422 423 //cout << "termination point: " << mTermination << endl; 424 //cout << "view point: " << mViewPoint << endl; 425 //cout << "scene: " << bbox << endl; 392 426 393 427 InitRenderTexture(mNewTexture); 394 428 InitRenderTexture(mOldTexture); 395 429 396 cout << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl;397 } 398 399 400 voidGlobalLinesRenderer::CastGlobalLines(const float alpha,430 //cout << "eye: " << mEyeVec << " left: " << mLeftVec << " up: " << mUpVec << endl; 431 } 432 433 434 int GlobalLinesRenderer::CastGlobalLines(const float alpha, 401 435 const float beta, 402 //const int samples,403 436 VssRayContainer &rays) 404 437 { … … 406 439 407 440 // bind pixel shader implementing the front depth buffer functionality 408 ApplyDepthPeeling(rays); 409 } 410 411 412 void GlobalLinesRenderer::CastGlobalLines(const SimpleRay &ray, 441 const int layers = ApplyDepthPeeling(rays); 442 443 return layers; 444 } 445 446 447 int GlobalLinesRenderer::CastGlobalLines(const SimpleRay &ray, 413 448 VssRayContainer &rays) 414 449 { 450 const long startTime = GetTime(); 451 cout << "casting global lines ... " << endl; 452 415 453 InitScene(ray); 416 454 417 455 // bind pixel shader implementing the front depth buffer functionality 418 ApplyDepthPeeling(rays); 419 } 420 421 void GlobalLinesRenderer::RenderObject(Intersectable *obj) 422 { 423 mRenderer->RenderIntersectable(obj); 456 const int layers = ApplyDepthPeeling(rays); 457 458 const float rays_per_sec = rays.size() / TimeDiff(startTime, GetTime()) * 1e-3; 459 cout << "cast " << rays.size() << " samples in " << layers << " layers in " << TimeDiff(startTime, GetTime()) * 1e-3 << " secs (" << rays_per_sec << " r / s)" << endl; 460 return layers; 424 461 } 425 462 … … 436 473 437 474 Intersectable::NewMail(); 438 439 for (oit = mPreprocessor->mObjects.begin(); oit != oit_end; ++ oit) 440 { 441 //cout << (*oit)->GetId() << " "; 442 RenderObject(*oit); 443 } 475 476 mRenderer->RenderScene(); 444 477 } 445 478 glPopMatrix(); … … 534 567 // depth and stencil. 535 568 // Note that RT_COPY_TO_TEXTURE is required for depth textures on ATI hardware 536 569 cout << "texwidth: " << mTexWidth << " texheight: " << mTexHeight << endl; 537 570 mNewTexture = new RenderTexture(mTexWidth, mTexHeight, true, true); 538 571 #ifdef ATI 539 mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE);572 mNewTexture->Initialize(true, true, false, false, false, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 540 573 #else 541 mNewTexture->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE);574 mNewTexture->Initialize(true, true, false, false, false, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 542 575 #endif 543 576 … … 545 578 546 579 #ifdef ATI 547 mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE);580 mOldTexture ->Initialize(true, true, false, false, false, 8, 8, 8, 8, RenderTexture::RT_COPY_TO_TEXTURE); 548 581 #else 549 mOldTexture ->Initialize(true, true, false, true, true, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE);582 mOldTexture ->Initialize(true, true, false, false, false, 8, 8, 8, 8);//, RenderTexture::RT_COPY_TO_TEXTURE); 550 583 #endif 551 584 … … 579 612 if (!mNewTexture->IsRectangleTexture()) 580 613 { 581 sTexWidthParam = cgGetNamedParameter(sCgDepthPeelingProgram, " texWidth");614 sTexWidthParam = cgGetNamedParameter(sCgDepthPeelingProgram, "invTexWidth"); 582 615 } 583 616 584 617 sStepSizeParam = cgGetNamedParameter(sCgDepthPeelingProgram, "stepSize"); 585 618 586 cgGLSetParameter1f(sTexWidthParam, (float)mTexWidth);619 cgGLSetParameter1f(sTexWidthParam, 1.0f / (float)mTexWidth); 587 620 cgGLSetParameter1f(sStepSizeParam, mEpsilon); 588 621 } … … 600 633 cgGLLoadProgram(sCgPassThroughProgram); 601 634 } 602 635 cout << "here45" << endl; 603 636 const float alpha = 1.1; 604 637 const float beta = 0.9; 605 638 InitScene(alpha, beta); 606 639 cout << "here4005" << endl; 607 640 PrintGLerror("init"); 608 641 } … … 748 781 Vector3 clippedOldPt, clippedNewPt; 749 782 750 ClipToViewSpaceBox(oldPt, newPt, clippedOldPt, clippedNewPt); 751 //clippedOldPt = oldPt; 752 //clippedNewPt = newPt; 753 754 // create rays in both directions 755 if (termObj1) 783 ClipToViewSpaceBox(oldPt, newPt, clippedOldPt, clippedNewPt);if(1) 756 784 { 757 vssRays.push_back(new VssRay(clippedOldPt, clippedNewPt, NULL, termObj1, pass)); 758 //cout << "new pt: " << newPt << endl; 759 } 760 761 if (mSampleReverse && termObj2) 762 { 763 vssRays.push_back(new VssRay(clippedNewPt, clippedOldPt, NULL, termObj2, pass)); 764 //cout << "old pt: " << oldPt << endl; 785 //clippedOldPt = oldPt; 786 //clippedNewPt = newPt; 787 788 // create rays in both directions 789 if (termObj1) 790 { 791 vssRays.push_back(new VssRay(clippedOldPt, clippedNewPt, NULL, termObj1, pass)); 792 //cout << "new pt: " << newPt << endl; 793 } 794 795 if (mSampleReverse && termObj2) 796 { 797 vssRays.push_back(new VssRay(clippedNewPt, clippedOldPt, NULL, termObj2, pass)); 798 //cout << "old pt: " << oldPt << endl; 799 } 765 800 } 766 801 } … … 936 971 937 972 938 void GlobalLinesRenderer::ApplyDepthPeeling(VssRayContainer &rays) 939 { 973 int GlobalLinesRenderer::ApplyDepthPeeling(VssRayContainer &rays) 974 { 975 int layers = 1; 976 940 977 mNewTexture->BeginCapture(); 941 978 { … … 952 989 ProcessDepthBuffer(rays, false, 0); 953 990 954 for( int i = 1; i < mMaxDepth; ++ i)991 for(; layers < mMaxDepth; ++ layers) 955 992 { 956 993 // Peel another layer … … 976 1013 // process the buffers for following layer 977 1014 // jump out of loop for the first invalid buffer 978 if (!ProcessDepthBuffer(rays, true, i))1015 if (!ProcessDepthBuffer(rays, true, layers)) 979 1016 break; 980 1017 } 981 1018 982 1019 PrintGLerror("endpeeling"); 983 } 984 985 986 } 1020 1021 return layers; 1022 } 1023 1024 1025 }
Note: See TracChangeset
for help on using the changeset viewer.