Ignore:
Timestamp:
04/13/09 22:01:56 (15 years ago)
Author:
mattausch
Message:

changed back to old version

File:
1 edited

Legend:

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

    r3348 r3349  
    2020{ 
    2121        float4 illum_col: COLOR0; 
    22         //float4 col: COLOR1; 
     22        float4 col: COLOR1; 
    2323}; 
    2424 
     
    117117        const float oldEyeSpaceDepth = oldPixel.w; 
    118118 
    119         // vector from eye pos to old sample 
     119        // vector from eye pos to old sample  
    120120        const float3 viewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 
    121121        const float invLen = 1.0f / length(viewVec); 
     
    148148                 
    149149                //w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f)); 
    150                 //w = floor(oldPixel.y); 
    151                 //w = oldPixel.y; 
    152                 idx = floor(oldPixel.y); 
     150                w = oldPixel.y; 
     151                idx = floor(oldPixel.z); 
     152 
    153153        } 
    154154        else 
    155155        {        
    156                 w   = .0f; 
     156                w = 0.0f; 
    157157                idx = .0f; 
    158158        } 
    159159 
    160         return float3(ssao, idx, w); 
     160        return float3(ssao, w, idx); 
    161161} 
    162162 
     
    201201                        tex2Dlod(samples, float4((0.5f + i + idx) / NUM_PRECOMPUTED_SAMPLES, 0.5f, .0f, .0f)).xy; 
    202202 
    203  
    204203                //////////////////// 
    205204                //-- add random noise: reflect around random normal vector  
     
    208207                if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
    209208                { 
    210                         float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, .0f, .0f)).xy; 
     209                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
    211210                        //offset = myreflect(samples[i], mynoise); 
    212211                        //offset = myrotate(samples[i], mynoise.x); 
     
    502501#ifdef PERFORMANCE_TEST  
    503502 
    504         float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, .0f, .0f)).xyz; 
     503        float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
    505504 
    506505        const float sqrMoveSpeed = SqrLen(diffVec); 
     
    522521        const float oldSsao = temporalVals.x; 
    523522         
    524         //float oldIdx = temporalCoherence > 1 ? temporalVals.y : .0f; 
    525         float oldIdx = temporalVals.y; 
    526         //float oldWeight = temporalVals.y; 
    527         float oldWeight = clamp(oldIdx, 0, temporalCoherence); 
    528  
     523        float oldWeight = temporalVals.y; 
     524        float oldIdx = temporalCoherence > 1 ? temporalVals.z : 0; 
     525         
    529526#else 
    530527 
    531528        const bool isMovingObject = false; 
    532         const float oldSsao = .0f; 
    533          
    534         float oldWeight = .0f; 
    535         float oldIdx = .0f; 
     529        const float oldSsao = 0; 
     530         
     531        float oldWeight = 0; 
     532        float oldIdx = 0; 
    536533         
    537534#endif 
     
    585582                else if (ao.y > partlyResetThres) 
    586583                { 
    587                         //if (oldIdx > 4.0f * NUM_SAMPLES) oldIdx = 0; 
    588                         oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); oldIdx = oldWeight; 
    589                         //oldWeight = oldIdx;//.0f; oldIdx = .0f; 
     584                        oldWeight = min(oldWeight, 4.0f * newWeight); 
     585                        //oldWeight = .0f;  
     586                        //oldIdx = .0f; 
    590587                } 
    591588        } 
     
    599596 
    600597        // the new weight for the next frame 
    601         const float newIdx = newWeight + oldIdx; 
    602         //const float combinedWeight = clamp(newIdx, .0f, temporalCoherence); 
    603         const float combinedWeight = clamp(newIdx, .0f, min(newWeight + oldWeight, temporalCoherence)); 
    604  
    605         //OUT.illum_col.y = combinedWeight; 
    606         OUT.illum_col.y = newIdx; // the new index 
     598        const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
     599 
     600        OUT.illum_col.y = combinedWeight; 
     601        OUT.illum_col.z = oldIdx + newWeight; // the new index 
    607602        OUT.illum_col.w = eyeSpaceDepth; 
    608603 
     
    610605 
    611606        // this value can be used to check if this pixel belongs to a moving object 
    612         //OUT.col.x = SqrLen(diffVec); 
    613         OUT.illum_col.z = SqrLen(diffVec); 
     607        OUT.col.x = SqrLen(diffVec); 
     608        //OUT.illum_col.z = SqrLen(diffVec); 
    614609 
    615610#else 
Note: See TracChangeset for help on using the changeset viewer.