Changeset 3100


Ignore:
Timestamp:
11/05/08 14:25:24 (16 years ago)
Author:
mattausch
Message:

added per sample test

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

Legend:

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

    r3099 r3100  
    4242#define MAX_LOD_LEVEL 10 
    4343 
    44 #define MIN_DEPTH_DIFF 1e-3f 
     44#define MIN_DEPTH_DIFF 1e-2f 
    4545//#define MIN_DEPTH_DIFF 5e-1f 
    4646#define PRECISION_SCALE 1e-1f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3099 r3100  
    7979                                                           uniform float3 oldtl, 
    8080                                                           uniform float3 oldtr, 
    81                                                            float3 worldPos 
     81                                                           float eyeSpaceDepth 
    8282                                                           ) 
    8383{ 
     
    8787        float2 texCoord = texcoord0 + offsetTransformed * scaleFactor; 
    8888         
    89         const float3 samplePos = ReconstructSamplePos(colors, texCoord, bl, br, tl, tr); 
    90  
     89        const float sampleEyeSpaceDepth = tex2Dlod(colors, float4(texCoord, 0, 0)).w; 
     90        //float3 viewVec = normalize(Interpol(texcoord, bl, br, tl, tr)); 
     91        const float3 viewVec = Interpol(texCoord, bl, br, tl, tr); 
     92        const float3 samplePos = -viewVec * sampleEyeSpaceDepth; 
     93 
     94        const float3 translatedPos = samplePos - oldEyePos; 
    9195        // reproject into old frame and calculate projected depth 
    92         float4 projPos = mul(oldModelViewProj, float4(samplePos, 1.0f)); 
     96        float4 projPos = mul(oldModelViewProj, float4(translatedPos, 1.0f)); 
    9397        projPos /= projPos.w; 
    9498 
     
    99103 
    100104        const float oldEyeSpaceDepth = oldPixel.w; 
    101         const float3 viewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 
    102  
    103         const float3 oldSamplePos = oldEyePos - viewVec * oldEyeSpaceDepth; 
     105        const float3 oldViewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 
     106 
     107        const float invlen = 1.0f / length(oldViewVec); 
     108        const float projectedEyeSpaceDepth = length(translatedPos) * invlen; 
    104109         
    105         float dDiff = length(oldSamplePos - samplePos.xyz); 
    106         if (length(worldPos.xyz - samplePos.xyz) > 5.0f) dDiff = .0f; 
    107  
    108         return dDiff; 
     110        float depthDif = (abs(eyeSpaceDepth - sampleEyeSpaceDepth) > 5.0f) ? 0 : abs(oldEyeSpaceDepth - projectedEyeSpaceDepth); 
     111 
     112        return depthDif; 
    109113} 
    110114 
     
    180184        float notValid = 0.5f; 
    181185 
    182         /*for (int i = 0; i < NUM_SAMPLES; ++ i)  
     186        for (int i = 0; i < NUM_SAMPLES; ++ i)  
    183187        { 
    184188                float sampleDif = ComputeDifference(samples[i], 
     
    192196                                                          oldEyePos, 
    193197                                                          oldbl, oldbr, oldtl, oldtr, 
    194                                                           eyePos.xyz); 
    195  
    196                 if (sampleDif >= 1e-1f) ++ notValid; 
    197         }*/ 
     198                                                          eyeSpaceDepth); 
     199 
     200                if (sampleDif >= 5e-2f) ++ notValid; 
     201        } 
    198202 
    199203        // the number of valid samples in this frame 
     
    210214                // if visibility changed in the surrounding area we have to recompute 
    211215                //&& (oldNumSamples > 0.8f * newNumSamples) 
    212                 //&& (notValid < 1.0f) 
     216                && (notValid < 1.0f) 
    213217                ) 
    214218        { 
     
    393397        float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    394398 
    395         //if (ao.y < 10.0f) ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); 
     399        if (ao.y < 10.0f) ao.x = Filter(IN.texCoord, ssaoTex, filterOffs, filterWeights); 
    396400 
    397401        OUT.illum_col = col * ao.x; 
Note: See TracChangeset for help on using the changeset viewer.