Changeset 3189


Ignore:
Timestamp:
11/27/08 02:14:31 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3175 r3189  
    287287mSamplingMethod(SAMPLING_POISSON), 
    288288mShadingMethod(DEFAULT), 
    289 mIllumFboIndex(0) 
     289mIllumFboIndex(0), 
     290mSortSamples(true) 
    290291{ 
    291292        /////////// 
    292293        //-- the flip-flop fbos 
    293294 
    294         const int dsw = w / 2; const int dsh = h / 2; 
    295         //const int dsw = w; const int dsh = h; 
     295        //const int dsw = w / 2; const int dsh = h / 2; 
     296        const int dsw = w; const int dsh = h; 
    296297 
    297298        mIllumFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
     
    515516        } 
    516517 
    517         // antialiasing of the color buffer 
    518         //AntiAliasing(fbo, light); 
     518        // multisampling is difficult / costly with deferred shading 
     519        // at least do some edge blurring  
     520        if (useAntiAliasing) AntiAliasing(fbo, light); 
    519521 
    520522        switch (mShadingMethod) 
     
    543545        // multisampling is difficult / costly with deferred shading 
    544546        // at least do some edge blurring  
    545  
    546         if (useAntiAliasing) 
    547                 AntiAliasing(fbo, light); 
    548         else 
    549                 Output(fbo); // just output the latest buffer 
     547        //if (useAntiAliasing) AntiAliasing(fbo, light); else  
     548        Output(fbo); // just output the latest buffer 
    550549 
    551550        glEnable(GL_LIGHTING); 
     
    590589void DeferredRenderer::SortSamples() 
    591590{ 
    592         //for (int i = 0; i < NUM_SAMPLES; ++ i)cout << SqrDist(samples2[i-1], samples2[i]) << "|"; 
    593         float dist = 0; 
    594         for (int i = 1; i < NUM_SAMPLES; ++ i) 
    595                 dist += SqrDist(samples2[i-1], samples2[i]); 
    596                 //cout << samples2[i].x << " " << samples2[i].y  
    597  
    598         //cout << "\nbefore: " << dist << endl; 
    599  
    600         //sort(samples2, samples2 + sizeof(samples2) / sizeof(Sample2), lt2); 
    601  
    602  
    603591        static Sample2 tempSamples[NUM_SAMPLES]; 
    604592        static bool checked[NUM_SAMPLES]; 
     
    636624        for (int i = 0; i < NUM_SAMPLES; ++ i) 
    637625                samples2[i] = tempSamples[i]; 
    638  
    639         dist = 0; 
    640         for (int i = 1; i < NUM_SAMPLES; ++ i) 
    641                 dist += SqrDist(samples2[i-1], samples2[i]); 
    642                 //cout << samples2[i].x << " " << samples2[i].y << " " << SqrDist(samples2[i-1], samples2[i]) << "|"; 
    643  
    644         //cout << "after:  " << dist << endl; 
    645626} 
    646627 
     
    693674                GenerateSamples(mSamplingMethod); 
    694675 
    695                 SortSamples(); 
     676                if (mSortSamples) { SortSamples(); } 
    696677                sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 
    697678        } 
     
    749730 
    750731        // read the second buffer, write to the first buffer 
    751         //FlipFbos(fbo); 
     732        FlipFbos(fbo); 
    752733        // end of the pipeline => just draw image to screen 
    753         FrameBufferObject::Release(); 
     734        //FrameBufferObject::Release(); 
    754735 
    755736        // the neighbouring texels 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3175 r3189  
    5656        */ 
    5757        void SetShadingMethod(SHADING_METHOD s); 
     58 
     59        void SetSortSamples(bool sortSamples) { mSortSamples = sortSamples; } 
    5860 
    5961        // hack: store the color buffer idx for the currently used flip flop-MRT here 
     
    146148        Vector3 mEyePos; 
    147149        Vector3 mOldEyePos; 
     150 
     151        bool mSortSamples; 
    148152}; 
    149153 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SkyPreetham.cpp

    r3123 r3189  
    293293        // downscale ambient color 
    294294        if (scaleToRange) 
    295                 ambient *= 5e-6f; 
     295                ambient *= 8e-6f; 
    296296        else 
    297297                ambient *= 1e-1f; 
     
    333333        // calculate final sun diffuse color. 
    334334        if (scaleToRange) 
    335                 diffuse = color * 1e-5f; 
     335                diffuse = color * 3e-5f; 
    336336        else 
    337337                diffuse = color * 3e-1f; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3175 r3189  
    106106 
    107107MotionPath *motionPath = NULL; 
    108  
     108/// max depth where candidates for tighter bounds are searched 
    109109int maxDepthForTestingChildren = 3; 
    110110 
     
    213213PerformanceGraph *perfGraph = NULL; 
    214214 
    215 static float ssaoTempCohFactor = 255.0; 
    216 static int sCurrentMrtSet = 0; 
     215float ssaoTempCohFactor = 255.0; 
     216bool sortSamples = true; 
     217int sCurrentMrtSet = 0; 
    217218 
    218219static Matrix4x4 invTrafo = IdentityMatrix(); 
     
    11381139                deferredShader->SetSamplingMethod(samplingMethod); 
    11391140                deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 
     1141                deferredShader->SetSortSamples(sortSamples); 
    11401142 
    11411143                ShadowMap *sm = showShadowMap ? shadowMap : NULL; 
     
    13111313                useRenderQueue = !useRenderQueue; 
    13121314                traverser->SetUseRenderQueue(useRenderQueue); 
    1313                  
    13141315                break; 
    13151316        case 'b': 
     
    13291330        case 'I': 
    13301331                useAntiAliasing = !useAntiAliasing; 
     1332                break; 
     1333        case '9': 
     1334                sortSamples = !sortSamples; 
    13311335                break; 
    13321336        default: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3167 r3189  
    66//-- ssao + gi parameters 
    77 
    8 #define NUM_SAMPLES 8 
     8//#define NUM_SAMPLES 8 
     9#define NUM_SAMPLES 16 
    910//#define NUM_SAMPLES 24 
    1011 
    1112// for quadratic falloff 
    1213//#define SAMPLE_INTENSITY 0.2f 
    13 #define SAMPLE_INTENSITY 0.07f 
    14 //#define SAMPLE_INTENSITY 0.01f 
     14//#define SAMPLE_INTENSITY 0.07f 
     15#define SAMPLE_INTENSITY 0.008f 
    1516 
    1617//#define SAMPLE_INTENSITY 0.075f 
    1718//#define SAMPLE_INTENSITY 0.2f 
    1819 
    19 #define SAMPLE_RADIUS 8e-1f 
     20//#define SAMPLE_RADIUS 8e-1f 
     21#define SAMPLE_RADIUS 4e-1f 
    2022 
    2123//#define DISTANCE_SCALE 1e-1f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/antialiasing.cg

    r3175 r3189  
    7676 
    7777        //const float de = saturate(dot(dd, weights.y)); 
    78         const float de = weights.y * dd.x + dd.y + dd.z + dd.w; 
     78        const float de = weights.y * dd.x * dd.y * dd.z * dd.w; 
    7979 
    8080 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3168 r3189  
    130130                spatialFactor = 1.0f / max(len, 1e-3f); 
    131131 
    132                 //normalFactor = max(step(0.6f, dot(sampleNorm, centerNormal)), 1e-3f); 
    133                 normalFactor = max(dot(sampleNorm, samplePos), 1e-3f); 
     132                normalFactor = max(step(.0f, dot(sampleNorm, centerNormal)), 1e-3f); 
     133                //normalFactor = max(dot(sampleNorm, samplePos), 1e-3f); 
    134134                //convergenceFactor = min(100.0f, aoSample.y); 
    135135                convergenceFactor = aoSample.y; 
     
    137137                // combine the weights 
    138138                w = convergenceFactor * spatialFactor * normalFactor; 
     139                //w = convergenceFactor * spatialFactor; 
    139140 
    140141                average += aoSample.x * w; 
     
    169170        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    170171 
    171         // reconstruct position from the eye space depth 
    172         /*const float4 worldPos = float4(-IN.view * eyeSpaceDepth, 1.0f); 
    173         // compute w factor from projection in order to control filter size 
    174         const float4 projPos = mul(modelViewProj, worldPos); 
    175         const float distanceScale = 1.0f / projPos.w; 
    176 */ 
    177  
    178172        // filter up to a certain convergance value and leave out background (sky) by checking depth 
    179173        if ((ao.y < 100.0f) && (col.w < 1e10f)) 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3168 r3189  
    290290        float validPixel; 
    291291 
    292         if ((((squaredLen <= DYNAMIC_OBJECTS_THRESHOLD) && (oldPixel.z <= DYNAMIC_OBJECTS_THRESHOLD)) ||  
    293                 (depthDif <= MIN_DEPTH_DIFF)) 
     292        const bool oldDynamic = (squaredLen <= DYNAMIC_OBJECTS_THRESHOLD); 
     293        const bool newDynamic = (oldPixel.z <= DYNAMIC_OBJECTS_THRESHOLD); 
     294 
     295        if (!(oldDynamic && !newDynamic) && !(!oldDynamic && newDynamic) && 
     296                !(oldDynamic && newDynamic && (depthDif > MIN_DEPTH_DIFF)) 
    294297                && (oldTexCoords.x >= 0.0f) && (oldTexCoords.x < 1.0f) 
    295298                && (oldTexCoords.y >= 0.0f) && (oldTexCoords.y < 1.0f) 
Note: See TracChangeset for help on using the changeset viewer.