Ignore:
Timestamp:
02/13/09 15:59:33 (15 years ago)
Author:
mattausch
Message:

debug version

File:
1 edited

Legend:

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

    r3309 r3310  
    4848        weight of the pixel in the new frame. 
    4949*/ 
    50 inline float2 temporalSmoothing(float4 worldPos, 
     50inline float3 temporalSmoothing(float4 worldPos, 
    5151                                                                float eyeSpaceDepth, 
    5252                                                                float2 texcoord0, 
     
    9696        // the weight of the accumulated samples from the previous frames 
    9797        float w; 
     98        float idx; 
    9899 
    99100        ////////////// 
     
    108109                // pixel valid => retrieve the convergence weight 
    109110                w = oldPixel.y; 
     111                idx = oldPixel.z; 
    110112        } 
    111113        else 
    112114        {        
    113                 w = 0.0f; 
    114         } 
    115  
    116         return float2(ssao, w); 
     115                w = .0f; 
     116                idx = .0f; 
     117        } 
     118 
     119        return float3(ssao, w, idx); 
    117120} 
    118121 
     
    141144        float numSamples = .0f; 
    142145        float validSamples = .0f; 
     146 
    143147 
    144148        for (int i = 0; i < NUM_PRECOMPUTED_SAMPLES; ++ i)  
     
    247251                //-- (affects performance for some reason!) 
    248252 
    249                 if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
     253                if (1)//convergence < SSAO_CONVERGENCE_THRESHOLD) 
    250254                { 
    251255                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
    252256                        //offset = myreflect(samples[i], mynoise); 
    253                         offset = myrotate(samples[i + idx], mynoise.x); 
     257                        offset = myrotate(samples[i], mynoise.x); 
     258                        //offset = myrotate(samples[i + idx], mynoise.x); 
    254259                } 
    255260                else 
    256261                { 
    257                         offset = samples[i + idx]; 
     262                        //offset = samples[i + idx]; 
     263                        offset = samples[i]; 
    258264                } 
    259265                 
     
    382388        //-- compute temporal reprojection 
    383389 
    384         float2 temporalVals = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 
     390        float3 temporalVals = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 
    385391                                                oldTex, oldModelViewProj,  
    386392                                                                                        colors,  
     
    394400        float oldWeight = temporalVals.y; 
    395401 
    396         float usedWeight = min(temporalCoherence, abs(oldWeight)); 
    397         int idx = (int)oldWeight % (int)temporalCoherence; 
     402        int idx = (int)temporalVals.z; 
     403                //min(0, (int)oldWeight % max((int)temporalCoherence, 1)); 
    398404 
    399405        float3 ao; 
     
    402408        if (eyeSpaceDepth < DEPTH_THRESHOLD) 
    403409        { 
    404                 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), usedWeight, sampleIntensity, isMovingObject, idx); 
     410                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz,  
     411                              scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight,  
     412                                  sampleIntensity, isMovingObject, idx); 
    405413                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 
    406414        } 
     
    428436                if (ao.y > completelyResetThres)  
    429437                { 
    430                         oldWeight = .0f;  
     438                        oldWeight = .0f; 
     439                        idx = .0f; 
    431440                } 
    432441                else if (ao.y > partlyResetThres) 
    433442                { 
    434443                        oldWeight = min(oldWeight, 4.0f * newWeight); 
    435                         //oldWeight = .0f;  
     444                        idx = oldWeight; 
    436445                } 
    437446        } 
     447 
     448        float usedWeight = min(temporalCoherence, oldWeight); 
     449 
    438450 
    439451        ////////// 
    440452        //-- blend ao between old and new samples (and avoid division by zero) 
    441453 
    442         OUT.illum_col.x = ao.x * newWeight + oldSsao * usedWeight; 
    443         OUT.illum_col.x /= (newWeight + usedWeight); 
     454        OUT.illum_col.x = ao.x * newWeight;// + oldSsao * usedWeight; 
     455        OUT.illum_col.x /= max(newWeight + usedWeight, 1); 
     456 
     457        //if (oldWeight >= 10000) oldWeight = 1000; 
    444458 
    445459        // the new weight for the next frame 
    446460        //const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
    447         const float combinedWeight = newWeight + oldWeight; 
     461        float combinedWeight = newWeight + oldWeight; 
     462 
     463        clamp(combinedWeight, 0, 1000); 
    448464 
    449465        OUT.illum_col.y = combinedWeight; 
Note: See TracChangeset for help on using the changeset viewer.