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/src/shaders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • 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} 
Note: See TracChangeset for help on using the changeset viewer.