Ignore:
Timestamp:
04/29/09 18:56:18 (15 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r3365 r3366  
    474474                        bool isMovingObject, 
    475475                        float oldIdx, 
    476                         sampler2D attribsTex 
     476                        sampler2D attribsTex, 
     477                        float3 oldPos 
    477478                        ) 
    478479{ 
     
    481482        float numSamples = .0f; 
    482483 
    483         float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
     484        //float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
    484485 
    485486        for (int i = 0; i < NUM_SAMPLES; ++ i)  
     
    513514 
    514515                const float4 sampleColor = tex2Dlod(colors, float4(texcoord, .0f, .0f)); 
     516                const float3 oldSamplePos = sampleColor.xyz; 
    515517                const float3 samplePos = ReconstructSamplePos(sampleColor.w, texcoord, bl, br, tl, tr); 
    516518                 
     
    549551                if (cosAngle >= 0) 
    550552                { 
    551                         float pixelValid = 0;//sampleColor.x; 
    552  
    553                         if (1)//pixelValid < 0.5f) 
    554                         { 
    555                                 const float3 sampleDiffVec = tex2Dlod(attribsTex, float4(texcoord, .0f, .0f)).xyz; 
    556                                 //pixelValid = max(pixelValid, length(sampleDiffVec - diffVec) < 5e-3f ? .0f : 100.0f); 
    557                                 pixelValid = max(pixelValid, length(sampleDiffVec - diffVec) < 5e-3f ? .0f : 4.0f); 
    558                                 //pixelValid = length(sampleDiffVec - diffVec) < 1e-3f ? .0f : 10.0f; 
    559                         } 
    560  
    561                         // hack: 
    562                         // we check if the sample could have been near enough to the current pixel  
    563                         // or if the angle is small enough 
    564                         // to have any influence in the current or last frame 
    565  
    566                         const float changeFactor = sampleColor.y; 
    567                         const float partlyResetThres = 1.0f; 
    568  
    569                         if (0)//pixelValid <= partlyResetThres) 
    570                         { 
    571                                 const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 
    572                                 validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-0.1f, cosAngle)); 
    573                         } 
    574                         else 
    575                         { 
    576                                 validSamples = max(validSamples, pixelValid); 
    577                         } 
     553                        const float oldDistance = length(oldSamplePos - oldPos); 
     554                        const float distanceDiff = abs(oldDistance - lengthToSample); 
     555 
     556                        float pixelValid = (distanceDiff > 1e-3f) ? 100.0f : 0; 
     557 
     558                        validSamples = max(validSamples, pixelValid); 
    578559                } 
    579560#ifdef USE_GTX 
     
    643624        // reconstruct position from the eye space depth 
    644625        const float3 viewDir = IN.view; 
    645         const float eyeSpaceDepth = tex2Dlod(colors, float4(IN.texCoord, 0, 0)).w; 
     626        const float4 mycolor = tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 
     627        const float eyeSpaceDepth = mycolor.w; 
    646628        const float4 eyeSpacePos = float4(-viewDir * eyeSpaceDepth, 1.0f); 
    647629 
     
    712694                                          br, tl, tr, normalize(viewDir),  
    713695                                          oldWeight, sampleIntensity, isMovingObject, oldIdx, 
    714                                           attribsTex); 
     696                                          attribsTex, mycolor.xyz); 
    715697#endif                             
    716698                } 
Note: See TracChangeset for help on using the changeset viewer.