Changeset 3208


Ignore:
Timestamp:
12/03/08 12:25:46 (16 years ago)
Author:
mattausch
Message:

working quite well with adaptive sampling

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3206 r3208  
    88//#define NUM_SAMPLES 8 
    99//#define NUM_SAMPLES 16 
    10 #define NUM_SAMPLES 24 
    11 //#define NUM_SAMPLES 96 
     10//#define NUM_SAMPLES 24 
     11#define NUM_SAMPLES 96 
    1212 
    1313#define SAMPLE_INTENSITY 0.2f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3206 r3208  
    269269                        float3 tr,  
    270270                        float3 viewDir, 
    271                         float newWeight 
     271                        float newWeight, 
     272                        bool isMovingObject 
    272273                        ) 
    273274{ 
     
    337338 
    338339                //if ((validSamples < 1.0f) && (newWeight > 200) && (numSamples >= 8)) break; 
    339                 //if ((validSamples < 1.0f) && (numSamples >= 8)) break; 
     340                if ((validSamples < 1.0f) && (numSamples >= 8) && !isMovingObject  
     341                        || (newWeight > NUM_SAMPLES * 5) && (numSamples >= 8) && isMovingObject 
     342                        ) 
     343                { 
     344                        break; 
     345                } 
    340346        } 
    341347 
     
    391397        float scaleFactor = SAMPLE_RADIUS * invw; 
    392398 
     399        const float sqrMoveSpeed = SqrLen(diffVec); 
     400        const bool isMovingObject = (sqrMoveSpeed > DYNAMIC_OBJECTS_THRESHOLD); 
     401 
    393402         
    394403        ///////////////// 
     
    412421        if (eyeSpaceDepth < 1e10f) 
    413422        { 
    414                 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight); 
     423                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, isMovingObject); 
    415424                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
    416425        } 
     
    420429        } 
    421430 
    422         const float squaredLen = SqrLen(diffVec); 
     431        // equals the number of sampled shot in this pass 
     432        const float newWeight = ao.z; 
    423433 
    424434        // check if we have to reset pixel because one of the sample points was invalid 
    425         if (squaredLen < DYNAMIC_OBJECTS_THRESHOLD) 
     435        if (!isMovingObject) 
     436    //if (sqrMoveSpeed <= DYNAMIC_OBJECTS_THRESHOLD) 
    426437        { 
    427438                if (ao.y > 4.0f)  
    428439                        oldWeight = 0;  
    429440                else if (ao.y > 1.0f) 
    430                         oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); 
    431         } 
    432  
    433         const float newWeight = ao.z; 
     441                        oldWeight = min(oldWeight, 4.0f * newWeight); 
     442        } 
     443 
    434444        const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
    435445 
Note: See TracChangeset for help on using the changeset viewer.