Changeset 3310 for GTP


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

debug version

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env

    r3309 r3310  
    106106ssaoSampleIntensity=0.8f 
    107107# ssao temporal coherence factor 
    108 tempCohFactor=150.0f 
     108tempCohFactor=100.0f 
    109109# ssao filter radius 
    110110ssaoFilterRadius=12.0f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3309 r3310  
    208208        case DeferredRenderer::SAMPLING_QUADRATIC: 
    209209                { 
    210                         static QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 
     210                        QuadraticDiscSampleGenerator2D g(NUM_PRECOMPUTED_SAMPLES, 1.0f); 
    211211                        //static QuadraticDiscSampleGenerator2D g(NUM_SAMPLES, 1.0f); 
    212212                        g.Generate((float *)samples2); 
     
    741741        sCgSsaoProgram->SetTexture(i ++, noiseTex2D); 
    742742 
    743         sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
     743        sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : .0f); 
    744744         
    745745        if (/*mUseTemporalCoherence || */mRegenerateSamples) 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg

    r3306 r3310  
    114114} 
    115115 
     116 
     117/** In between step that only filters in one direction 
     118*/ 
     119pixel FilterSsaoHalfRes(fragment IN,  
     120                                                uniform sampler2D colorsTex, 
     121                                                uniform sampler2D ssaoTex, 
     122                                                uniform float3 bl, 
     123                                                uniform float3 br, 
     124                                                uniform float3 tl, 
     125                                                uniform float3 tr, 
     126                                                uniform float2 res 
     127                                                 ) 
     128{ 
     129        pixel OUT; 
     130 
     131        const float depth = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)).w; 
     132 
     133        OUT.illum_col = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
     134        // compute minimal convergence for savetly reasons, write it out 
     135        const float convergence = ComputeConvergenceHalfRes(ssaoTex, IN.texCoord, res * 0.5f); 
     136        OUT.illum_col.y = convergence; 
     137 
     138        const float2 xyStep = float2(1.0f / res.x, 0); 
     139 
     140        // filter reaches size 1 pixel when sample size reaches threshold  
     141        // afterwards we do not use the filter anymore 
     142 
     143        // filter up to a certain convergance value and leave out background (sky) by checking depth 
     144        if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
     145        { 
     146                // the filtered ssao value 
     147                //OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence); 
     148        } 
     149 
     150        return OUT; 
     151} 
     152 
     153 
    116154/** In between step that only filters in one direction 
    117155*/ 
     
    137175        // afterwards we do not use the filter anymore 
    138176 
    139         float2 xyStep = float2(1.0f / res.x, 0); 
     177        const float2 xyStep = float2(1.0f / res.x, 0); 
    140178 
    141179        // filter up to a certain convergance value and leave out background (sky) by checking depth 
     
    149187} 
    150188 
    151 /** In between step that only filters in one direction 
    152 */ 
    153 pixel FilterSsaoHalfRes(fragment IN,  
    154                                                 uniform sampler2D colorsTex, 
    155                                                 uniform sampler2D ssaoTex, 
    156                                                 uniform float3 bl, 
    157                                                 uniform float3 br, 
    158                                                 uniform float3 tl, 
    159                                                 uniform float3 tr, 
    160                                                 uniform float2 res 
    161                                                  ) 
    162 { 
    163         pixel OUT; 
    164  
    165         const float depth = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)).w; 
    166  
    167         OUT.illum_col = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    168         // compute minimal convergence for savetly reasons, write it out 
    169         const float convergence = ComputeConvergenceHalfRes(ssaoTex, IN.texCoord, res * 0.5f); 
    170         OUT.illum_col.y = convergence; 
    171  
    172         const float2 xyStep = float2(1.0f / res.x, 0); 
    173  
    174         // filter reaches size 1 pixel when sample size reaches threshold  
    175         // afterwards we do not use the filter anymore 
    176  
    177         // filter up to a certain convergance value and leave out background (sky) by checking depth 
    178         if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (depth < DEPTH_THRESHOLD)) 
    179         { 
    180                 // the filtered ssao value 
    181                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence); 
    182         } 
    183  
    184         return OUT; 
    185 } 
    186189 
    187190/** Function combining image and indirect illumination buffer using a  
  • 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.