Ignore:
Timestamp:
12/07/08 23:26:00 (16 years ago)
Author:
mattausch
Message:

made ssao parameters more flexible
started to implement lense flare

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3209 r3212  
    108108        const float ssao = oldPixel.x; 
    109109 
    110 #if USE_EYESPACE_DEPTH 
    111  
    112110        // calculate eye space position of sample in old frame 
    113111        const float oldEyeSpaceDepth = oldPixel.w; 
     
    120118         
    121119        const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 
    122  
    123 #else 
    124  
    125         // calculate eye space position of sample in old frame 
    126         const float oldDepth = oldPixel.w; 
    127         // the depth projected into the old frame 
    128         const float projectedDepth = projPos.z; 
    129         // calculate depth difference  
    130         const float depthDif = abs(projectedDepth - oldDepth); 
    131  
    132 #endif 
    133120 
    134121        const float xOffs = 1.0f / 1024.0f; 
     
    176163                         float3 tr,  
    177164                         float3 viewDir, 
    178                          sampler2D normalTex 
     165                         sampler2D normalTex, 
     166                         float sampleIntensity 
    179167                         ) 
    180168{ 
     
    224212                cosAngle *= step(0.0f, dot(dirSample, normal)); 
    225213         
    226                 const float aoContrib = SAMPLE_INTENSITY / sqrLen; 
     214                const float aoContrib = sampleIntensity / sqrLen; 
    227215                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
    228216 
     
    270258                        float3 viewDir, 
    271259                        float newWeight, 
    272                         bool isMovingObject 
     260                        float sampleIntensity 
    273261                        ) 
    274262{ 
     
    310298                // angle between current normal and direction to sample controls AO intensity. 
    311299                const float cosAngle = max(dot(dirSample, normal), .0f); 
    312                 const float aoContrib = SAMPLE_INTENSITY / sqrLen; 
     300                const float aoContrib = sampleIntensity / sqrLen; 
    313301                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
    314302 
     
    338326 
    339327                //if ((validSamples < 1.0f) && (newWeight > 200) && (numSamples >= 8)) break; 
    340                 if ((validSamples < 1.0f) && (numSamples >= 8) && !isMovingObject  
    341                         || (newWeight > NUM_SAMPLES * 5) && (numSamples >= 8) && isMovingObject 
    342                         ) 
    343                 { 
    344                         break; 
    345                 } 
     328                //if ((validSamples < 1.0f) && (numSamples >= 8)) break; 
    346329        } 
    347330 
    348331        total_ao /= numSamples; 
    349332 
    350         //return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
    351         return float3(total_ao, validSamples, numSamples); 
     333        return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
    352334} 
    353335 
     
    374356                   uniform float3 oldtl, 
    375357                   uniform float3 oldtr, 
    376                    uniform sampler2D attribsTex 
     358                   uniform sampler2D attribsTex, 
     359                   uniform float kernelRadius, 
     360                   uniform float sampleIntensity 
    377361                   ) 
    378362{ 
     
    396380        const float invw = 1.0f / projPos.w; 
    397381        projPos *= invw; 
    398         float scaleFactor = SAMPLE_RADIUS * invw; 
    399  
    400         const float sqrMoveSpeed = SqrLen(diffVec); 
    401         const bool isMovingObject = (sqrMoveSpeed > DYNAMIC_OBJECTS_THRESHOLD); 
     382        float scaleFactor = kernelRadius * invw; 
    402383 
    403384         
     
    422403        if (eyeSpaceDepth < 1e10f) 
    423404        { 
    424                 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, isMovingObject); 
    425                 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
     405                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity); 
     406                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 
    426407        } 
    427408        else 
     
    430411        } 
    431412 
    432         // equals the number of sampled shot in this pass 
    433         const float newWeight = ao.z; 
     413        const float squaredLen = SqrLen(diffVec); 
    434414 
    435415        // check if we have to reset pixel because one of the sample points was invalid 
    436         if (!isMovingObject) 
    437     //if (sqrMoveSpeed <= DYNAMIC_OBJECTS_THRESHOLD) 
     416        if (squaredLen < DYNAMIC_OBJECTS_THRESHOLD) 
    438417        { 
    439418                if (ao.y > 4.0f)  
    440419                        oldWeight = 0;  
    441420                else if (ao.y > 1.0f) 
    442                         oldWeight = min(oldWeight, 4.0f * newWeight); 
    443         } 
    444  
     421                        oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); 
     422        } 
     423 
     424        const float newWeight = ao.z; 
    445425        const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
    446426 
Note: See TracChangeset for help on using the changeset viewer.