Ignore:
Timestamp:
02/12/09 18:45:14 (16 years ago)
Author:
mattausch
Message:

working on sampling

File:
1 edited

Legend:

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

    r3306 r3307  
    250250                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
    251251                        //offset = myreflect(samples[i], mynoise); 
    252                         offset = myrotate(samples[i], mynoise.x); 
     252                        offset = myrotate(samples[i + (int)convergence], mynoise.x); 
    253253                } 
    254254                else 
     
    294294                // we check if the sample could have been near enough to the current pixel  
    295295                // to have any influence in the current or last frame 
    296                 const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 
     296                //const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 
    297297                //validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid * step(-0.1f, cosAngle)); 
    298298                validSamples = max(validSamples, pixelValid); 
     
    303303                if (numSamples >= MIN_SAMPLES) 
    304304                { 
    305                         //break; 
    306305                        // if the pixel belongs to a static object and all the samples stay valid in the current frame 
    307306                        if (!isMovingObject && (validSamples < 1.0f)) break; 
     
    393392        const float oldSsao = temporalVals.x; 
    394393        float oldWeight = temporalVals.y; 
    395          
     394 
     395        float usedWeight = min(temporalCoherence, abs(oldWeight)); 
     396 
    396397        float3 ao; 
    397398 
     
    399400        if (eyeSpaceDepth < DEPTH_THRESHOLD) 
    400401        { 
    401                 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject); 
     402                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), usedWeight, sampleIntensity, isMovingObject); 
    402403                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 
    403404        } 
     
    420421        const float partlyResetThres = 1.0f; 
    421422         
    422         if (1)//!isMovingObject) 
     423        // hack: just update static geometry 
     424        if (!isMovingObject) 
    423425        { 
    424426                if (ao.y > completelyResetThres)  
     
    436438        //-- blend ao between old and new samples (and avoid division by zero) 
    437439 
    438         OUT.illum_col.x = (ao.x * newWeight + oldSsao * oldWeight);// / (newWeight + oldWeight);//max(1e-6f, newWeight + oldWeight); 
    439  
    440         OUT.illum_col.x /= (newWeight + oldWeight); 
     440        OUT.illum_col.x = ao.x * newWeight + oldSsao * usedWeight; 
     441        OUT.illum_col.x /= (newWeight + usedWeight); 
    441442 
    442443        // the new weight for the next frame 
    443         const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
     444        //const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
     445        const float combinedWeight = newWeight + oldWeight; 
    444446 
    445447        OUT.illum_col.y = combinedWeight; 
Note: See TracChangeset for help on using the changeset viewer.