- Timestamp:
- 01/11/07 21:40:49 (18 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/generate_viewcells.env
r1746 r1969 46 46 47 47 VssPreprocessor { 48 initialSamples 049 vssSamples 050 48 useImportanceSampling true 51 49 loadInitialSamples false -
GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp
r1960 r1969 427 427 glEndList(); 428 428 } 429 429 430 glCallList(glList); 430 431 } else -
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 } -
GTP/trunk/Lib/Vis/Preprocessing/src/GlobalLinesRenderer.h
r1968 r1969 35 35 36 36 /** Casts global lines in the angle specified by alpha and 37 beta. 38 @returns Computed samples in the container rays37 beta. The computed samples are stored in the ray container. 38 @returns # of layers 39 39 */ 40 voidCastGlobalLines(const float alpha,40 int CastGlobalLines(const float alpha, 41 41 const float beta, 42 42 VssRayContainer &rays); … … 46 46 @returns Computed samples in the container rays 47 47 */ 48 voidCastGlobalLines(const SimpleRay &ray,49 48 int CastGlobalLines(const SimpleRay &ray, 49 VssRayContainer &rays); 50 50 51 51 … … 60 60 int ComputePvs(ObjectContainer &objects, ObjectContainer &pvs) const; 61 61 62 void RenderObject(Intersectable *obj);63 64 65 62 /** Draws the geometry for one pass. 66 63 */ … … 69 66 void GrabDepthBuffer(float *data, RenderTexture *rt); 70 67 void GrabItemBuffer(unsigned char *data, RenderTexture *rt); 71 voidApplyDepthPeeling(VssRayContainer &rays);68 int ApplyDepthPeeling(VssRayContainer &rays); 72 69 void ExportDepthBuffer(); 73 70 void ExportItemBuffer(); … … 120 117 Vector3 &left); 121 118 119 Preprocessor *mPreprocessor; 120 122 121 protected: 123 122 … … 129 128 void InitRenderTexture(RenderTexture *rt); 130 129 131 Preprocessor *mPreprocessor;130 132 131 133 132 GlRenderer *mRenderer; -
GTP/trunk/Lib/Vis/Preprocessing/src/Preprocessor.cpp
r1968 r1969 1352 1352 1353 1353 Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.texHeight", texHeight); 1354 Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.tex Height", texWidth);1354 Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.texWidth", texWidth); 1355 1355 Environment::GetSingleton()->GetFloatValue("Preprocessor.HwGlobalLines.stepSize", eps); 1356 1356 Environment::GetSingleton()->GetIntValue("Preprocessor.HwGlobalLines.maxDepth", maxDepth); 1357 1357 Environment::GetSingleton()->GetBoolValue("Preprocessor.HwGlobalLines.sampleReverse", sampleReverse); 1358 1358 1359 mGlobalLinesRenderer = 1359 Debug << "****** hw global line options *******" << endl; 1360 Debug << "texWidth: " << texWidth << endl; 1361 Debug << "texHeight: " << texHeight << endl; 1362 Debug << "sampleReverse: " << sampleReverse << endl; 1363 Debug << "max depth: " << maxDepth << endl; 1364 Debug << "step size: " << eps << endl; 1365 Debug << endl; 1366 1367 globalLinesRenderer = mGlobalLinesRenderer = 1360 1368 new GlobalLinesRenderer(this, 1361 1369 texHeight, … … 1364 1372 maxDepth, 1365 1373 sampleReverse); 1366 1374 1375 cout << "here2" << endl; 1367 1376 mGlobalLinesRenderer->InitGl(); 1368 } 1369 1370 } 1377 cout << "here8" << endl; 1378 //return mGlobalLinesRenderer; 1379 } 1380 1381 } -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r1942 r1969 1 1 // =================================================================== 2 2 // $Id$ 3 #ifdef USE_QT4 3 5 4 // Qt headers … … 186 185 updateGL(); 187 186 } 187 188 188 } 189 189 190 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h
r1943 r1969 2 2 #define __QTGLVIEWER_H 3 3 4 #ifdef USE_QT5 4 #include <QtOpenGL> 6 5 … … 12 11 class QtGlViewer : public QGLWidget 13 12 { 14 Q_OBJECT13 //Q_OBJECT 15 14 16 15 friend class QtGlRendererWidget; … … 21 20 22 21 QtGlViewer(QWidget *parent, 23 22 QtGlRendererWidget *renderer); 24 23 25 24 virtual ~QtGlViewer(){}; … … 53 52 54 53 #endif 55 #endif -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj
r1947 r1969 67 67 OutputDirectory="Release" 68 68 IntermediateDirectory="Release" 69 ConfigurationType=" 2"69 ConfigurationType="4" 70 70 CharacterSet="2"> 71 71 <Tool … … 81 81 Name="VCCustomBuildTool"/> 82 82 <Tool 83 Name="VCLinkerTool" 84 AdditionalDependencies="Preprocessor.lib qtmain.lib QtGui4.lib Qt3Support4.lib QAxContainer.lib QtCore4.lib QtOpenGL4.lib xerces-c_2.lib glew32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib" 85 OutputFile="Release/QtInterface.dll" 86 LinkIncremental="1" 87 AdditionalLibraryDirectories=""..\$(ConfigurationName)";"..\..\lib\$(ConfigurationName)";..\..\src\GL;..\..\..\..\..\..\..\NonGTP\Zlib\lib;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;"$(CG_LIB_PATH)";"$(QTDIR)\lib"" 88 GenerateDebugInformation="FALSE" 89 SubSystem="2" 90 OptimizeReferences="2" 91 EnableCOMDATFolding="2" 92 ImportLibrary="$(OutDir)/QtInterface.lib" 93 TargetMachine="1"/> 94 <Tool 95 Name="VCMIDLTool"/> 96 <Tool 97 Name="VCPostBuildEventTool" 98 Description=""copy dll to preprocessor dir"" 99 CommandLine="copy $(OutDir)\*.dll ..\..\bin\"/> 100 <Tool 101 Name="VCPreBuildEventTool"/> 102 <Tool 103 Name="VCPreLinkEventTool"/> 104 <Tool 105 Name="VCResourceCompilerTool"/> 106 <Tool 107 Name="VCWebServiceProxyGeneratorTool"/> 108 <Tool 109 Name="VCXMLDataGeneratorTool"/> 110 <Tool 111 Name="VCWebDeploymentTool"/> 83 Name="VCLibrarianTool"/> 84 <Tool 85 Name="VCMIDLTool"/> 86 <Tool 87 Name="VCPostBuildEventTool"/> 88 <Tool 89 Name="VCPreBuildEventTool"/> 90 <Tool 91 Name="VCPreLinkEventTool"/> 92 <Tool 93 Name="VCResourceCompilerTool"/> 94 <Tool 95 Name="VCWebServiceProxyGeneratorTool"/> 96 <Tool 97 Name="VCXMLDataGeneratorTool"/> 112 98 <Tool 113 99 Name="VCManagedWrapperGeneratorTool"/> … … 175 161 OutputDirectory="$(ConfigurationName)" 176 162 IntermediateDirectory="$(ConfigurationName)" 177 ConfigurationType=" 2"163 ConfigurationType="4" 178 164 CharacterSet="2"> 179 165 <Tool … … 189 175 Name="VCCustomBuildTool"/> 190 176 <Tool 191 Name="VCLinkerTool" 192 AdditionalDependencies="Preprocessor.lib qtmain.lib QtGui4.lib Qt3Support4.lib QAxContainer.lib QtCore4.lib QtOpenGL4.lib xerces-c_2.lib glew32.lib OpenGL32.Lib glu32.lib cg.lib cgGL.lib RTScene.lib RTWorld.lib" 193 OutputFile="Release/QtInterface.dll" 194 LinkIncremental="1" 195 AdditionalLibraryDirectories=""$(QTDIR)\lib";..\..\..\..\..\..\..\NonGTP\Zlib\lib;"$(CG_LIB_PATH)";..\..\src\GL;..\..\..\..\..\..\..\NonGTP\Xerces\xercesc\lib;..\..\lib\Release;..\..\MultiLevelRayTracing\RTScene\Release;..\..\MultiLevelRayTracing\RTWorld\Release" 196 GenerateDebugInformation="FALSE" 197 SubSystem="2" 198 OptimizeReferences="2" 199 EnableCOMDATFolding="2" 200 ImportLibrary="Release/QtInterface.lib" 201 TargetMachine="1"/> 177 Name="VCLibrarianTool" 178 OutputFile="Release/$(ProjectName).lib"/> 202 179 <Tool 203 180 Name="VCMIDLTool"/> … … 216 193 <Tool 217 194 Name="VCXMLDataGeneratorTool"/> 218 <Tool219 Name="VCWebDeploymentTool"/>220 195 <Tool 221 196 Name="VCManagedWrapperGeneratorTool"/> … … 238 213 </File> 239 214 <File 240 RelativePath=".\QtGl RendererDll.cpp">215 RelativePath=".\QtGlViewer.cpp"> 241 216 </File> 242 217 <File … … 258 233 Name="VCCustomBuildTool" 259 234 Description="Performing moc on $(InputName).h" 260 CommandLine="%qtdir%\bin\moc.exe $(InputDir)$(InputName).h -o $(InputDir)moc_$(InputName).cpp" 235 CommandLine="%qtdir%\bin\moc.exe $(InputDir)$(InputName).h -o $(InputDir)moc_$(InputName).cpp 236 " 261 237 Outputs="$(InputDir) moc_$(InputName).cpp"/> 262 238 </FileConfiguration> … … 288 264 Outputs="$(InputDir) moc_$(InputName).cpp"/> 289 265 </FileConfiguration> 266 </File> 267 <File 268 RelativePath=".\QtGlViewer.h"> 290 269 </File> 291 270 </Filter> -
GTP/trunk/Lib/Vis/Preprocessing/src/Ray.h
r1942 r1969 341 341 342 342 Vector3 Extrap(const float t) const { 343 return mOrigin + mDirection * t; 344 } 343 return mOrigin + mDirection * t; 344 } 345 346 friend ostream &operator<<(ostream &s, const SimpleRay &r) 347 { 348 return s << "origin=" << r.mOrigin << " dir=" << r.mDirection; 349 }; 345 350 }; 346 351 -
GTP/trunk/Lib/Vis/Preprocessing/src/depth_peeling2d.cg
r1964 r1969 2 2 float3 main(in float4 col : COL0, 3 3 in float3 pos : WPOS, 4 uniform float texWidth,4 uniform float invTexWidth, 5 5 uniform float stepSize, 6 6 uniform sampler2D depthTex) : COLOR 7 7 { 8 float zold = tex2D(depthTex, pos.xy / texWidth);8 float zold = tex2D(depthTex, pos.xy * invTexWidth); 9 9 10 10 if(pos.z < (zold + stepSize)) -
GTP/trunk/Lib/Vis/Preprocessing/src/main.cpp
r1968 r1969 271 271 #ifdef TRY_GLOBAL_LINES 272 272 273 globalLinesRenderer = new GlobalLinesRenderer(preprocessor); 274 globalLinesRenderer->InitGl(); 273 preprocessor->PrepareHwGlobalLines(); 274 //globalLinesRenderer = new GlobalLinesRenderer(preprocessor); 275 //globalLinesRenderer->InitGl(); 276 cout << "here22" << endl; 275 277 globalLinesRenderer->Run(); 276 278 277 //delete renderer;278 279 #else 279 280
Note: See TracChangeset
for help on using the changeset viewer.