Changeset 3362 for GTP


Ignore:
Timestamp:
04/24/09 18:00:06 (15 years ago)
Author:
mattausch
Message:

cleaned up algorithm

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter.vcproj

    r3359 r3362  
    156156                                AdditionalLibraryDirectories="libs\Zlib\lib" 
    157157                                IgnoreDefaultLibraryNames="libCMT" 
    158                                 GenerateDebugInformation="false" 
     158                                GenerateDebugInformation="true" 
    159159                                SubSystem="1" 
    160160                                LargeAddressAware="2" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/PlyConverter.cpp

    r3361 r3362  
    4141                Face face = faces[i]; 
    4242 
     43                if (faces[i].indices.empty()) cout << "error!!" << endl; 
     44 
    4345                //cout << "size: " << face.indices.size() << endl; 
    44                 for (size_t j = 0; j < face.indices.size(); ++ j) 
     46                for (int j = (int)face.indices.size() - 1; j >= 0; -- j) 
    4547                { 
    46                         SimpleVec h = vertices[faces[i].indices[j]]; 
     48                        //cout << "h " << j << " " << face.indices.size() << endl; 
     49 
     50                        SimpleVec h = vertices[face.indices[j]]; 
    4751                        SimpleVec v; 
    4852                         
    49                         v.x = h.x * 14; 
     53                        v.x = -h.x * 14; 
    5054                        v.y = h.z * 14; 
    5155                        v.z = h.y * 14; 
     
    7680 
    7781                // no face normals? => create normals 
    78                 const SimpleTri tri(geom->mVertices[idx + 2], 
     82                const SimpleTri tri(geom->mVertices[idx + 0], 
    7983                                        geom->mVertices[idx + 1],  
    80                                                         geom->mVertices[idx + 0]); 
     84                                                        geom->mVertices[idx + 2]); 
    8185 
    8286                const SimpleVec n = tri.GetNormal(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/plot_friendly

    r3294 r3362  
    1010PREFIX=myvienna 
    1111PREFIX=vienna 
    12 PREFIX=pp 
     12#PREFIX=pp 
    1313 
    1414#FILES="$PREFIX-vfc.log $PREFIX_chc.log $PREFIX-vfc_pvs.log $PREFIX-chc++_b20.log $PREFIX-chc++_pvs_b20.log" 
     
    2020FILES="$PREFIX-notindexed.log $PREFIX-indexed.log" 
    2121#FILES="$PREFIX-vfc.log $PREFIX-chc++.log $PREFIX-vfc_pvs.log" 
     22#FILES="$PREFIX-ssao.log $PREFIX-ssao_tmp.log $PREFIX-deferred.log" 
     23FILES="$PREFIX-ssao_1024.log $PREFIX-ssao_tmp.log" 
     24#FILES="$PREFIX-ssao.log" 
    2225 
    2326echo $FILES 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/ps_memory_plot2

    r3294 r3362  
    2323#echo set xrange \[100:20000\] >> $FILE 
    2424#echo set xrange \[4200:4600\] >> $FILE 
    25 echo set xrange \[100:400\] >> $FILE 
    26 echo set xrange \[1000:1600\] >> $FILE 
     25#echo set xrange \[100:400\] >> $FILE 
     26#echo set xrange \[1000:1600\] >> $FILE 
    2727#echo set xrange \[1600:2100\] >> $FILE 
    2828#echo set xrange \[3000:3500\] >> $FILE 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env

    r3360 r3362  
    120120camDirection=-0.0136068 0.974275 -0.224952 
    121121lightDirection=0.556361 0.559966 -0.613923 
     122 
     123 
     124camPosition=-13.4875 10.9779 10.0881 
     125camDirection=-0.97437 -3.55818e-006 -0.224952  
     126lightDirection=0.556361 0.559966 -0.613 923 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3361 r3362  
    15051505        sprintf(imageName, "%s_%05d.tga", mSavedFrameSuffix.c_str(), mSavedFrameNumber); 
    15061506 
     1507        //cout << "writing " << imageName << endl; 
     1508 
    15071509        ILstring fileName = ILstring(imageName); 
    15081510        ilRegisterType(IL_FLOAT); 
     
    15251527        } 
    15261528 
     1529        //cout << "wrote " << fileName << endl; 
     1530 
    15271531        delete [] data; 
    15281532        stopil(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3361 r3362  
    628628 
    629629        if (0) LoadPompeiiFloor(); 
     630 
    630631#if 1 
    631632 
     
    642643        // sibenik positions 
    643644        VertexArray positions; 
    644          
     645        const float factor2 = 1.6f; 
    645646        // for buddha (lowres) 
    646         positions.push_back(Vector3(6.07307, 8.20723, 6.62)); 
    647         positions.push_back(Vector3(-17.1935, 11.1687, 8.8781)); 
    648         positions.push_back(Vector3(1.50032, 31.1943, 19.1f)); 
     647        positions.push_back(Vector3(6.07307, 8.20723, 6.62 - factor2)); 
     648        positions.push_back(Vector3(-17.1935, 11.1687, 8.8781 - factor2)); 
     649        //positions.push_back(Vector3(1.50032, 31.1943, 19.1f)); 
    649650 
    650651        // for happy buddha 
     
    655656        // for dragon 
    656657        //positions.push_back(Vector3(6.07307, 8.20723, 5.0f)); 
    657         //positions.push_back(Vector3(0, 0, -0.8)); 
     658        //positions.push_back(Vector3(0, 0, -0.8f)); 
    658659 
    659660#endif 
     
    661662        //const Vector3 sceneCenter(470.398f, 240.364f, 180.3); 
    662663        Matrix4x4 transl = TranslationMatrix(positions[0]); 
    663          
     664        //LoadModel("dragon.dem", dynamicObjects); 
     665 
     666#if 1 
     667 
    664668        //LoadModel("hbuddha.dem", dynamicObjects); 
    665669        //LoadModel("horse.dem", dynamicObjects); 
    666         LoadModel("happy.dem", dynamicObjects); 
    667         //LoadModel("dragon.dem", dynamicObjects); 
     670        LoadModel("happy2.dem", dynamicObjects); 
    668671        //LoadModel("torus.dem", dynamicObjects); 
    669672        //LoadModel("venusm.dem", dynamicObjects); 
     
    678681        } 
    679682 
    680         /* 
     683 
    681684        const float rotAngle = M_PI / 2.0f; 
    682685        const Matrix4x4 rotMatrix = RotationXMatrix(rotAngle); 
     
    685688        // hack: second buddha 
    686689        dynamicObjects[0]->GetTransform()->MultMatrix(rotMatrix); 
    687         dynamicObjects[0]->GetTransform()->MultMatrix(scaleMatrix); 
    688  
    689         dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 
     690        //dynamicObjects[0]->GetTransform()->MultMatrix(scaleMatrix); 
     691 
     692        /*dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 
    690693        dynamicObjects[1]->GetTransform()->MultMatrix(scaleMatrix); 
    691694 
     
    698701 
    699702#endif 
    700  
     703#endif 
    701704        // hack 
    702705        resourceManager->mUseNormalMapping = false; 
     
    732735 
    733736        // set far plane based on scene extent 
    734         //farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
    735         farDist = 1000.0f; 
     737        farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
     738        //farDist = 1000.0f; 
    736739        camera->SetFar(farDist); 
    737740 
     
    11801183                buddha->GetTransform()->SetMatrix(trafo); 
    11811184 
     1185                const float rotAngle3 = M_PI / 2.0f; 
     1186                const Matrix4x4 rotMatrix3 = RotationZMatrix(rotAngle3); 
     1187 
     1188                // hack: second buddha 
     1189                buddha->GetTransform()->MultMatrix(rotMatrix3); 
     1190 
    11821191#if TODO // drop objects on ground floor 
    11831192                for (int i = 0; i < 10; ++ i) 
     
    11941203#endif 
    11951204 
    1196 #if 1 
    11971205                ///////////////////////// 
    11981206                //-- update animations 
    11991207 
     1208 
    12001209                //const float rotAngle = M_PI * 1e-3f; 
    1201                 const float rotAngle = 0.3f * M_PI / 180.0f; 
    1202                 //const float rotAngle = 0.6f * M_PI / 180.0f; 
     1210                //const float rotAngle = 0.3f * M_PI / 180.0f; 
     1211                const float rotAngle = 0.6f * M_PI / 180.0f; 
    12031212 
    12041213                Matrix4x4 rotMatrix = RotationZMatrix(rotAngle); 
     
    12141223                const float moveSpeed = 1e-1f; 
    12151224                motionPath->Move(moveSpeed); 
    1216 #endif 
    12171225        } 
    12181226 
     
    14881496                } 
    14891497                 
    1490                 if (makeSnapShot) makeSnapShot = false; 
     1498                static int dummy = 0; 
     1499                if (makeSnapShot && (dummy ++ == 650)) makeSnapShot = false; 
    14911500 
    14921501                ShadowMap *sm = showShadowMap ? shadowMap : NULL; 
     
    20172026void RightMotionLight(int x, int y)  
    20182027{ 
    2019         float theta = 0.2f * M_PI * (xEyeBegin - x) / 180.0f; 
    2020         float phi = 0.2f * M_PI * (yMotionBegin - y) / 180.0f; 
     2028        const float theta = .2f * M_PI * (xEyeBegin - x) / 180.0f; 
     2029        const float phi   = .2f * M_PI * (yMotionBegin - y) / 180.0f; 
    20212030         
    20222031        Vector3 lightDir = light->GetDirection(); 
     
    20692078        Vector3 rVec(viewDir[0], viewDir[1], 0); 
    20702079         
    2071         Matrix4x4 rot = RotationZMatrix(M_PI * 0.5f); 
     2080        Matrix4x4 rot = RotationZMatrix(M_PI * .5f); 
    20722081        rVec = rot * rVec; 
    20732082         
    2074         pos -= rVec * (x - horizontalMotionBegin) * mouseMotion; 
     2083        pos    -= rVec * (x - horizontalMotionBegin) * mouseMotion; 
    20752084        pos[2] += (verticalMotionBegin - y) * mouseMotion; 
    20762085 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3361 r3362  
    2626#define VIEW_CORRECTION_SCALE 1.0f 
    2727 
     28//#define SSAO_CONVERGENCE_THRESHOLD 300.0f 
    2829#define SSAO_CONVERGENCE_THRESHOLD 700.0f 
    2930//#define SSAO_CONVERGENCE_THRESHOLD 1500.0f 
     
    7374#define PERFORMANCE_TEST 1 
    7475 
     76#define USE_OPTIMIZATION 0 
     77 
     78 
    7579#endif // __SHADERENV_H 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg

    r3361 r3362  
    105105                           ) 
    106106{ 
    107         float2 result = float2(0.0f, 0.0f); 
     107        //return tex2Dlod(ssaoTex, float4(texCoord, .0f, .0f)).x; 
     108        float2 result = float2(.0f); 
    108109         
    109110        const float3 centerPos = ReconstructSamplePos(colorsTex, texCoord, bl, br, tl, tr); 
    110111 
     112#if 0 
     113        //const float scale = saturate((SSAO_CONVERGENCE_THRESHOLD - convergence + 100) / SSAO_CONVERGENCE_THRESHOLD); 
    111114        const float scale = saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
    112         //const int radius = SSAO_FILTER_RADIUS * saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
    113115         
    114         //for (int i = -radius; i <= radius; ++ i) 
    115         for (int i = -SSAO_FILTER_RADIUS; i <= SSAO_FILTER_RADIUS; ++ i) 
     116        //for (int i = -SSAO_FILTER_RADIUS; i <= SSAO_FILTER_RADIUS; ++ i) 
    116117        { 
    117118                const float4 sampleTexCoord = float4(texCoord + i * xyStep * scale, .0f, .0f); 
    118119                result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence, spatialWeight); 
    119120        } 
    120  
     121#else 
     122 
     123        const int radius = SSAO_FILTER_RADIUS * saturate((SSAO_CONVERGENCE_THRESHOLD - convergence + 100) / SSAO_CONVERGENCE_THRESHOLD); 
     124 
     125        for (int i = -radius; i <= radius; ++ i) 
     126        { 
     127                const float4 sampleTexCoord = float4(texCoord + i * xyStep, .0f, .0f); 
     128                result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence, spatialWeight); 
     129        } 
     130 
     131#endif 
    121132        result.x /= max(result.y, 1e-6f); 
    122133        return saturate(result.x); 
     
    133144                                                uniform float3 tl, 
    134145                                                uniform float3 tr, 
    135                                                 uniform float2 res 
     146                                                uniform float2 res, 
     147                                                uniform float maxConvergence, 
     148                                                uniform float spatialWeight 
     149 
    136150                                                 ) 
    137151{ 
     
    151165 
    152166        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    153         if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     167        if ((!USE_OPTIMIZATION || (convergence < SSAO_CONVERGENCE_THRESHOLD)) &&  
     168                (depth < DEPTH_THRESHOLD)) 
    154169        { 
    155170                // the filtered ssao value 
    156                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
     171                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex,  
     172                                               bl, br, tl, tr, xyStep,  
     173                                                                   convergence, maxConvergence, spatialWeight); 
    157174        } 
    158175 
     
    185202        // afterwards we do not use the filter anymore 
    186203 
    187         float2 xyStep = float2(1.0f / res.x, 0); 
     204        float2 xyStep = float2(1.0f / res.x, .0f); 
    188205 
    189206        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    190         if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     207        if ((!USE_OPTIMIZATION || convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
    191208        { 
    192209                // the filtered ssao value 
    193                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
     210                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex,  
     211                                               bl, br, tl, tr, xyStep,  
     212                                                                   convergence, maxConvergence, spatialWeight); 
    194213        } 
    195214 
     
    228247 
    229248        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    230         if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     249        if ((!USE_OPTIMIZATION || (convergence < SSAO_CONVERGENCE_THRESHOLD))  
     250                && (depth < DEPTH_THRESHOLD)) 
    231251        { 
    232252                // the filtered ssao value 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3361 r3362  
    307307        else if ( // check if changed from dynamic to not dynamic object 
    308308                 ( 
    309                           (oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) || 
     309                         // (oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) || 
    310310                         ( 
    311311                          (oldEyeSpaceDepth < DEPTH_THRESHOLD) && (projectedEyeSpaceDepth < DEPTH_THRESHOLD) && 
    312                           (oldDynamic || newDynamic) &&  // check if we have a dynamic object  
    313                           (depthDif > MIN_DEPTH_DIFF))) 
     312                          //(oldDynamic || newDynamic) &&  // check if we have a dynamic object  
     313                          (depthDif > 5e-3f)))//MIN_DEPTH_DIFF))) 
    314314                          ) // and there is a depth discontinuity 
    315315        {        
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r3360 r3362  
    8383 
    8484        // account for alpha blending 
    85         if (texColor.w < 0.5f) discard; 
     85        if (texColor.w < .5f) discard; 
    8686 
    8787        pixel pix; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3361 r3362  
    205205                //-- (affects performance for some reason!) 
    206206 
    207                 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
     207                if (!USE_OPTIMIZATION || 
     208                        (convergence < SSAO_CONVERGENCE_THRESHOLD)) 
    208209                { 
    209210                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
     
    355356                //-- (affects performance for some reason!) 
    356357 
    357                 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
     358                if (!USE_OPTIMIZATION || 
     359                        (convergence < SSAO_CONVERGENCE_THRESHOLD)) 
    358360                { 
    359361                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
     
    493495                //-- (affects performance for some reason!) 
    494496 
    495                 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
     497                if (!USE_OPTIMIZATION || 
     498                        (convergence < SSAO_CONVERGENCE_THRESHOLD)) 
    496499                { 
    497500                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
     
    539542 
    540543 
    541 #ifdef PERFORMANCE_TEST 
     544//#ifdef PERFORMANCE_TEST 
     545#if 1 
    542546                // check if the samples have been valid in the last frame 
    543547                // only mark sample as invalid if in the last / current frame 
    544548                // they possibly have any influence on the ao 
    545549 
    546                 //const float pixelValid = sampleColor.x; 
    547                 //const float pixelValid = length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f; 
    548                 //float pixelValid = max(sampleColor.x, length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f); 
    549                 float pixelValid = sampleColor.x; 
    550  
    551                 if (pixelValid < 1) 
    552                 { 
    553                         const float3 sampleDiffVec = tex2Dlod(attribsTex, float4(texcoord, .0f, .0f)).xyz; 
    554                         pixelValid = length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f; 
    555                 } 
    556  
    557                 // hack: 
    558                 // we check if the sample could have been near enough to the current pixel  
    559                 // or if the angle is small enough 
    560                 // to have any influence in the current or last frame 
    561  
    562 #if 1 
    563                 const float changeFactor = sampleColor.y; 
    564                 const float partlyResetThres = 1.0f; 
    565  
    566                 if (0)//pixelValid <= partlyResetThres) 
    567                 { 
    568                         const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 
    569                         validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-0.1f, cosAngle)); 
    570                 } 
    571                 else 
    572                 { 
    573                         validSamples = max(validSamples, pixelValid); 
    574                 } 
    575 #endif 
    576  
     550                if (cosAngle > 0) 
     551                { 
     552                        float pixelValid = sampleColor.x; 
     553 
     554                        if (1)//pixelValid < 0.5f) 
     555                        { 
     556                                const float3 sampleDiffVec = tex2Dlod(attribsTex, float4(texcoord, .0f, .0f)).xyz; 
     557                                pixelValid = max(pixelValid, length(sampleDiffVec - diffVec) < 5e-3f ? .0f : 10.0f); 
     558                                //pixelValid = length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f; 
     559                        } 
     560 
     561                        // hack: 
     562                        // we check if the sample could have been near enough to the current pixel  
     563                        // or if the angle is small enough 
     564                        // to have any influence in the current or last frame 
     565 
     566                        const float changeFactor = sampleColor.y; 
     567                        const float partlyResetThres = 1.0f; 
     568 
     569                        if (0)//pixelValid <= partlyResetThres) 
     570                        { 
     571                                const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 
     572                                validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-0.1f, cosAngle)); 
     573                        } 
     574                        else 
     575                        { 
     576                                validSamples = max(validSamples, pixelValid); 
     577                        } 
     578                } 
    577579#ifdef USE_GTX 
    578580                // we can bail out early and use a minimal #samples) 
     
    657659         
    658660#ifdef PERFORMANCE_TEST  
     661 
    659662        float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
    660663 
     
    750753                { 
    751754                        const float factor = 4.0f; 
     755                        //if (oldIdx >= factor * newWeight) oldIdx = 0; 
    752756                        oldWeight = min(oldWeight, factor * newWeight); 
    753                         //oldWeight = .0f;  
    754                         //oldIdx    = .0f; 
     757                        oldWeight = oldIdx = .0f;  
    755758                } 
    756759        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/vienna.env

    r3353 r3362  
    2020# the filename for the statistics 
    2121statsFilename=mystats 
    22 walkThroughSuffix=walkthrough_vienna 
     22walkThroughSuffix=walkthrough_vienna2 
    2323 
    2424# use potentially visible sets? 
Note: See TracChangeset for help on using the changeset viewer.