Ignore:
Timestamp:
02/20/09 19:26:13 (15 years ago)
Author:
mattausch
Message:

indexing working not so bad

File:
1 edited

Legend:

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

    r3322 r3324  
    7777        weight of the pixel in the new frame. 
    7878*/ 
    79 inline float2 Reproject(float4 worldPos, 
    80                                                                 float eyeSpaceDepth, 
    81                                                                 float2 texcoord0, 
    82                                                                 float3 oldEyePos, 
    83                                                                 sampler2D oldTex, 
    84                                                                 float4x4 oldModelViewProj, 
    85                                                                 sampler2D colors, 
    86                                                                 float3 projPos, 
    87                                                                 float invW, 
    88                                                                 float3 oldbl, 
    89                                                                 float3 oldbr, 
    90                                                                 float3 oldtl, 
    91                                                                 float3 oldtr, 
    92                                                                 float3 diffVec 
    93                                                                 ) 
     79inline float3 Reproject(float4 worldPos, 
     80                                                float eyeSpaceDepth, 
     81                                                float2 texcoord0, 
     82                                                float3 oldEyePos, 
     83                                                sampler2D oldTex, 
     84                                                float4x4 oldModelViewProj, 
     85                                                sampler2D colors, 
     86                                                float3 projPos, 
     87                                                float invW, 
     88                                                float3 oldbl, 
     89                                                float3 oldbr, 
     90                                                float3 oldtl, 
     91                                                float3 oldtr, 
     92                                                float3 diffVec 
     93                                                ) 
    9494{ 
    9595        // compute position from old frame for dynamic objects + translational portion 
     
    125125        // the weight of the accumulated samples from the previous frames 
    126126        float w; 
     127 
     128        float idx = oldPixel.z; 
    127129 
    128130        ////////////// 
     
    151153        } 
    152154 
    153         return float2(ssao, w); 
     155        return float3(ssao, w, idx); 
    154156} 
    155157 
     
    167169                         sampler2D colors, 
    168170                         sampler2D noiseTex, 
    169                          float2 samples[NUM_SAMPLES], 
     171                         sampler2D samples, 
    170172                         float3 normal, 
    171173                         float3 centerPosition, 
     
    179181                         float sampleIntensity, 
    180182                         bool isMovingObject, 
    181                          sampler2D normalTex 
     183                         sampler2D normalTex, 
     184                         int idx 
    182185                         ) 
    183186{ 
     
    190193                float2 offset; 
    191194 
     195                const float2 ssaoOffset = tex2Dlod(samples, float4((0.5f + i + idx) / NUM_PRECOMPUTED_SAMPLES, 0.5f, .0f, .0f)).xy; 
     196 
     197 
    192198                //////////////////// 
    193199                //-- add random noise: reflect around random normal vector  
    194200                //-- (affects performance for some reason!) 
    195201 
    196                 if (1)//convergence < SSAO_CONVERGENCE_THRESHOLD) 
     202                if (convergence < SSAO_CONVERGENCE_THRESHOLD) 
    197203                { 
    198204                        float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
    199205                        //offset = myreflect(samples[i], mynoise); 
    200                         offset = myrotate(samples[i], mynoise.x); 
     206                        //offset = myrotate(samples[i], mynoise.x); 
     207                        offset = myrotate(ssaoOffset, mynoise.x); 
    201208                } 
    202209                else 
    203210                { 
    204                         offset = samples[i]; 
     211                        offset = ssaoOffset; 
    205212                } 
    206213                 
     
    441448                   uniform sampler2D normals, 
    442449                   uniform sampler2D noiseTex, 
    443                    uniform float2 samples[NUM_SAMPLES], 
     450                   uniform sampler2D samples, 
    444451                   uniform sampler2D oldTex, 
    445452                   uniform float4x4 modelViewProj, 
     
    488495        //-- compute temporal reprojection 
    489496 
    490         float2 temporalVals = Reproject(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 
     497        float3 temporalVals = Reproject(eyeSpacePos, eyeSpaceDepth, IN.texCoord, oldEyePos, 
    491498                                        oldTex, oldModelViewProj,  
    492499                                                                        colors,  
     
    499506        const float oldSsao = temporalVals.x; 
    500507        float oldWeight = temporalVals.y; 
    501          
     508        float oldIdx = temporalVals.z; 
     509 
    502510        float3 ao; 
    503511 
     
    506514        { 
    507515                //ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject); 
    508                 ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject, normals); 
     516                ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity, isMovingObject, normals, oldIdx); 
    509517                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 
    510518        } 
     
    552560        OUT.illum_col.y = combinedWeight; 
    553561        // can be used to check if this pixel belongs to a moving object 
    554         OUT.illum_col.z = SqrLen(diffVec); 
     562        //OUT.illum_col.z = SqrLen(diffVec); 
     563        OUT.illum_col.z = oldIdx + newWeight; 
    555564        OUT.illum_col.w = eyeSpaceDepth; 
    556565 
Note: See TracChangeset for help on using the changeset viewer.