Changeset 3225


Ignore:
Timestamp:
12/19/08 01:56:47 (16 years ago)
Author:
mattausch
Message:

versio for paper submission

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

Legend:

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

    r3221 r3225  
    112112                                EnableFiberSafeOptimizations="true" 
    113113                                AdditionalIncludeDirectories="libs;libs/GL;libs/Devil/include;src;libs/Zlib/include;"$(CG_INC_PATH)"" 
    114                                 PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SET" 
     114                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_SET;NOT_USE_GTX" 
    115115                                StringPooling="true" 
    116116                                RuntimeLibrary="2" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3223 r3225  
    8888 
    8989# use full resolution ssao (vs. half resoltion) 
    90 ssaoUseFullResolution=0 
     90ssaoUseFullResolution=1 
    9191# ssao kernel radius 
    9292ssaoKernelRadius=8e-1f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3224 r3225  
    131131StatsWriter *statsWriter = NULL; 
    132132 
     133bool makeSnapShot = false; 
     134 
    133135 
    134136/// the technique used for rendering 
     
    10381040        //-- update animations 
    10391041 
    1040         Matrix4x4 rotMatrix = RotationZMatrix(M_PI * 1e-3f); 
     1042        //const float rotAngle = M_PI * 1e-3f; 
     1043        const float rotAngle = 1.0f * M_PI / 180.0f; 
     1044 
     1045        Matrix4x4 rotMatrix = RotationZMatrix(rotAngle); 
    10411046        dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 
    10421047 
    10431048        motionPath->Move(0.01f); 
    1044  
    10451049 
    10461050 
     
    12631267                } 
    12641268 
     1269                static int snapShotIdx = 0; 
     1270 
    12651271                deferredShader->SetSunVisiblePixels(sunVisiblePixels); 
    12661272                deferredShader->SetShadingMethod(shadingMethod); 
     
    12711277                deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 
    12721278                deferredShader->SetSortSamples(sortSamples); 
    1273                 deferredShader->SetSaveFrame(recordedFramesSuffix, (recordFrames && replayPath) ? currentReplayFrame : -1); 
     1279 
     1280                if (recordFrames && replayPath) 
     1281                        deferredShader->SetSaveFrame(recordedFramesSuffix, currentReplayFrame); 
     1282                else if (makeSnapShot) 
     1283                        deferredShader->SetSaveFrame("snap", snapShotIdx ++);            
     1284                else 
     1285                        deferredShader->SetSaveFrame("", -1);            
     1286 
     1287                if (makeSnapShot) makeSnapShot = false; 
    12741288 
    12751289                ShadowMap *sm = showShadowMap ? shadowMap : NULL; 
     
    15031517                // move light source instead of camera tilt 
    15041518                moveLight = !moveLight; 
     1519                break; 
     1520        case '#': 
     1521                // make a snapshot of the current frame 
     1522                makeSnapShot = true; 
    15051523                break; 
    15061524        default: 
     
    23792397        cout << "\nloading model " << filename << endl; 
    23802398        if (resourceManager->Load(filename, entities)) 
     2399        { 
    23812400                cout << "model " << filename << " successfully loaded" << endl; 
     2401        } 
    23822402        else 
    23832403        { 
    23842404                cerr << "loading model " << filename << " failed" << endl; 
     2405 
    23852406                CleanUp(); 
    23862407                exit(0); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3221 r3225  
    66//-- ssao + gi parameters 
    77 
    8 #define NUM_SAMPLES 8 
     8//#define NUM_SAMPLES 8 
    99//#define NUM_SAMPLES 16 
    10 //#define NUM_SAMPLES 24 
     10#define NUM_SAMPLES 24 
    1111//#define NUM_SAMPLES 48 
    1212 
     
    5858#define DYNAMIC_OBJECTS_THRESHOLD 1e-8f 
    5959 
    60 #define USE_GTX 
    6160 
    6261#endif // __SHADERENV_H 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3216 r3225  
    138138        const float minConvergence = min(m1, m2); 
    139139 
    140         const float convergence = minConvergence; 
     140        //const float convergence = minConvergence; 
    141141        //const float convergence = 0; 
    142         //const float convergence = ao.y; 
     142        const float convergence = ao.y; 
    143143 
    144144        // filter reaches size 1 pixel when sample size reaches threshold  
     
    159159        } 
    160160 
     161        // just apply ssao if we are not in the sky 
    161162        if (col.w < 1e10f) 
    162163                OUT.illum_col.xyz = col.xyz * max(1e-1f, 1.0f - ao.x); 
     
    164165                OUT.illum_col.xyz = col.xyz; 
    165166 
     167 
     168        //OUT.illum_col.xyz = float3(abs(ao.y * 1e2f), abs(ao.z * 1e2f), abs(ao.w * 1e2f)); 
     169 
     170        //if (convergence < (1.0f + NUM_SAMPLES * 10)) 
     171        //      OUT.illum_col.xyz = float3(1 - convergence / (NUM_SAMPLES * 10), convergence / (NUM_SAMPLES * 10), 0); 
     172         
     173        //OUT.illum_col.xyz = float3(ao.z * 1e4f, ao.z * 1e4f, ao.z * 1e4f); 
     174 
    166175        //OUT.illum_col.xyz = float3(ao.x, ao.x, step(thres, convergence)); 
    167         //OUT.illum_col.xyz = float3(0, convergence, 0); 
    168176        //OUT.illum_col.xyz = float3(abs(center.x - IN.texCoord.x) * 16.0f, abs(center.y - IN.texCoord.y) * 12.0f, 0); 
    169          
    170         //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-3f, 0, 1), 1); 
    171177        //OUT.illum_col.xyz = float3(0, 1.0f - step(0.5f + NUM_SAMPLES, convergence), 1); 
     178 
    172179        OUT.illum_col.w = col.w; 
    173180 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3221 r3225  
    119119        const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 
    120120 
    121         const float xOffs = 1.0f / 1024.0f; 
    122         const float yOffs = 1.0f / 768.0f; 
    123         const float eps = 1e-6f; 
    124  
    125         // the weight of the old value 
     121        //const float xOffs = 1.0f / 1024.0f; const float yOffs = 1.0f / 768.0f; const float eps = 1e-6f; 
     122 
     123        // the weight of the accumulated samples from the previous frames 
    126124        float w; 
    127125 
     
    130128 
    131129        if (1 
    132                 && (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= 1.0f - xOffs + eps) 
    133                 && (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= 1.0f - yOffs + eps) 
     130        //      && (oldTexCoords.x + eps >= xOffs) && (oldTexCoords.x <= 1.0f - xOffs + eps) 
     131        //      && (oldTexCoords.y + eps >= yOffs) && (oldTexCoords.y <= 1.0f - yOffs + eps) 
     132                && (oldTexCoords.x > 0) && (oldTexCoords.x < 1.0f) 
     133                && (oldTexCoords.y > 0) && (oldTexCoords.y < 1.0f) 
    134134                && (depthDif <= MIN_DEPTH_DIFF)  
    135135                ) 
     
    215215                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
    216216 
    217 #if 1 
    218                 // if surface normal perpenticular to view dir, approx. half of the samples will not count 
    219                 // => compensate for this (on the other hand, projected sampling area could be larger!) 
    220  
    221                 const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f); 
    222                 total_ao += cosAngle * aoContrib * viewCorrection; 
    223 #else 
    224217                total_ao += cosAngle * aoContrib; 
    225 #endif 
     218 
    226219                // check if the samples have been valid in the last frame 
    227220                validSamples += (1.0f - step(1.0f, lengthToSample)) * sampleColor.x; 
     
    231224 
    232225        total_ao /= numSamples; 
     226 
     227#if 1 
     228        // if surface normal perpenticular to view dir, approx. half of the samples will not count 
     229        // => compensate for this (on the other hand, projected sampling area could be larger!) 
     230        const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f); 
     231        total_ao += cosAngle * aoContrib * viewCorrection; 
     232 
     233#endif 
    233234 
    234235        return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
     
    302303                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
    303304 
    304 #if 1 
    305                 // if surface normal perpenticular to view dir, approx. half of the samples will not count 
    306                 // => compensate for this (on the other hand, projected sampling area could be larger!) 
    307  
    308                 const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f); 
    309                 total_ao += cosAngle * aoContrib * viewCorrection; 
    310 #else 
    311305                total_ao += cosAngle * aoContrib; 
    312 #endif 
    313306 
    314307                ++ numSamples; 
     
    325318                validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid); 
    326319 
    327 #ifdef QWQ//USE_GTX 
     320#ifdef USE_GTX 
    328321                // we can bail out early and use a minimal #samples) 
    329322                // if some conditions are met as long as the hardware supports it 
     
    337330                } 
    338331#endif 
    339  
    340         } 
    341  
    342         // scale ao contribution 
     332        } 
     333 
     334        // "normalize" ao contribution 
    343335        total_ao /= numSamples; 
     336 
     337#if 1 
     338        // if surface normal perpenticular to view dir, approx. half of the samples will not count 
     339        // => compensate for this (on the other hand, projected sampling area could be larger!) 
     340        const float viewCorrection = 1.0f + VIEW_CORRECTION_SCALE * max(dot(viewDir, normal), 0.0f); 
     341        total_ao *= viewCorrection; 
     342#endif 
    344343 
    345344        return float3(total_ao, validSamples, numSamples); 
     
    434433        const float newWeight = ao.z; 
    435434 
     435        // completely reset the ao in this pixel 
    436436        const float completelyResetThres = 4.0f; 
     437        // don't fully reset the ao in this pixel, but give low weight to old solution 
    437438        const float partlyResetThres = 1.0f; 
    438439         
     
    440441        { 
    441442                if (ao.y > completelyResetThres)  
     443                { 
    442444                        oldWeight = .0f;  
     445                } 
    443446                else if (ao.y > partlyResetThres) 
    444                         oldWeight = min(oldWeight, 4.0f * newWeight); 
     447                { 
     448                        //oldWeight = min(oldWeight, 4.0f * newWeight); 
     449                        oldWeight = .0f;  
     450                } 
    445451        } 
    446452 
     
    448454        const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
    449455 
     456 
    450457        ////////// 
    451458        //-- blend ao between old and new samples (and avoid division by zero) 
     459 
    452460        OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight) / max(1e-6f, newWeight + oldWeight); 
    453461 
     462        OUT.illum_col.y = combinedWeight; 
     463        // can be used to check if this pixel belongs to a moving object 
    454464        OUT.illum_col.z = SqrLen(diffVec); 
    455         OUT.illum_col.y = combinedWeight; 
    456465        OUT.illum_col.w = eyeSpaceDepth; 
    457466 
     467        //OUT.illum_col.yzw = diffVec; 
     468 
    458469        return OUT; 
    459470} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt

    r3219 r3225  
    146146scenequery 
    147147 
    148 fix walk speed 
     148fix walk speed for deferred shading 
     149 
     150fix color bleeding 
     151fix ao2 
     152fix full resolution mode 
     153 
     154for the paper: make ao more efficient, for example we do not need to downsample normal texture for ao version 1 
     155also for full resolution mode: test what happens if we do not use downsampling, look why currently so slow with full resolution (was previously > 80 frame or so!!) 
Note: See TracChangeset for help on using the changeset viewer.