Changeset 3156


Ignore:
Timestamp:
11/24/08 17:33:53 (16 years ago)
Author:
mattausch
Message:

pixel check working better now

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

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3155 r3156  
    445445         
    446446        string prepareSsaoParams[] =  
    447                 {"colorsTex", "oldTex", "modelViewProj", "oldModelViewProj", "oldEyePos",  
     447                {"colorsTex", "oldTex", "oldEyePos", "modelViewProj", "oldModelViewProj", 
    448448                 "oldbl", "oldbr", "oldtl", "oldtr", "diffVals"}; 
    449449 
     
    968968        //sCgSsaoProgram->SetTexture(i ++, normalsTex); 
    969969        sCgPrepareSsaoProgram->SetTexture(i ++, oldTex); 
    970          
    971         sCgPrepareSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 
    972         sCgPrepareSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 
    973  
    974         for (int j = 0; j < 4; ++ j, ++ i) 
    975                 sCgPrepareSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 
    976970 
    977971        Vector3 de; 
     
    981975 
    982976        sCgPrepareSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z); 
     977 
     978        sCgPrepareSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 
     979        sCgPrepareSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 
     980 
     981        for (int j = 0; j < 4; ++ j, ++ i) 
     982                sCgPrepareSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 
    983983 
    984984        sCgPrepareSsaoProgram->SetTexture(i ++, diffVals); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3155 r3156  
    106106                const float scale =     adaptFactor * scaleFactor * ao.z  / (adaptFactor + ao.y); 
    107107 
    108                 //ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, filterWeights, scale); 
     108                ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, filterWeights, scale); 
    109109        } 
    110110 
    111111        OUT.illum_col.xyz = col.xyz * ao.x; 
    112          
    113         OUT.illum_col.xyz = float3(0, ao.x, 0); 
    114  
     112        //OUT.illum_col.xyz = float3(0, ao.x, 0); 
    115113        //OUT.illum_col.xyz = float3(0, clamp(1.0f - ao.y * 1e-2f, 0, 1), 1); 
    116114        OUT.illum_col.w = col.w; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3155 r3156  
    251251 
    252252        // compute position from old frame for dynamic objects + translational portion 
    253         //const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz; 
    254         const float3 translatedPos = worldPos.xyz; 
     253        const float3 translatedPos = diffVec - oldEyePos + worldPos.xyz; 
    255254 
    256255 
     
    259258 
    260259        // note: the old model view matrix only holds the view orientation part 
    261         //float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f)); 
    262         float4 backProjPos = mul(modelViewProj, float4(translatedPos, 1.0f)); 
     260        float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f)); 
    263261        backProjPos /= backProjPos.w; 
    264262         
    265263        // fit from unit cube into 0 .. 1 
    266         //const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f; 
    267         const float2 oldTexCoords = texCoord; 
     264        const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f; 
     265        //const float2 oldTexCoords = texCoord; 
    268266        // retrieve the sample from the last frame 
    269267        const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f)); 
     
    273271 
    274272        // vector from eye pos to old sample  
    275         const float3 oldViewDir = viewDir;//Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 
     273        const float3 oldViewDir = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 
    276274        const float invLen = 1.0f / length(oldViewDir); 
    277275        const float projectedEyeSpaceDepth = invLen * length(translatedPos); 
     
    280278 
    281279        const float squaredLen = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z; 
    282  
    283280        //if (squaredLen < 1e-8f) // object not dynamic 
    284281        //{} 
     
    289286                && (oldTexCoords.x >= 0.0f) && (oldTexCoords.x < 1.0f) 
    290287                && (oldTexCoords.y >= 0.0f) && (oldTexCoords.y < 1.0f) 
    291                 //&& (depthDif <= MIN_DEPTH_DIFF)  
    292                 && (depthDif <= 9e-1f)  
     288                && (depthDif <= MIN_DEPTH_DIFF)  
     289                //&& (depthDif <= 9e-1f)  
    293290                ) 
    294291        { 
     
    297294        else 
    298295        {        
    299                 validPixel = 1.5f; 
     296                validPixel = 10.5f; 
    300297        } 
    301298 
    302         return depthDif; 
    303         //return validPixel; 
     299        //return depthDif; 
     300        return validPixel; 
    304301} 
    305302 
     
    310307                                   uniform float4x4 modelViewProj, 
    311308                                   uniform float4x4 oldModelViewProj, 
    312                                    uniform float3 oldEyePos, 
    313309                                   uniform float3 oldbl, 
    314310                                   uniform float3 oldbr, 
    315311                                   uniform float3 oldtl, 
    316312                                   uniform float3 oldtr, 
     313                                   uniform float3 oldEyePos, 
    317314                                   uniform sampler2D diffVals 
    318315                                   ): COLOR 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3155 r3156  
    183183#endif 
    184184 
    185         //float pixelValid = 0.5f; 
    186         float overallDepth = 0; 
    187  
    188 #if 0 
    189185        const float squaredLen = diffVec.x * diffVec.x + diffVec.y * diffVec.y + diffVec.z * diffVec.z; 
    190  
    191         if (squaredLen < 1e-8f) // object not dynamic 
    192         { 
    193                 for (int i = 0; i < NUM_SAMPLES; ++ i)  
    194                 { 
    195                         float sampleDif = ComputeDifference(samples[i], 
    196                                                                                                 oldTex, 
    197                                                                                                 oldModelViewProj, 
    198                                                                                                 colors, 
    199                                                                                                 noiseTex, 
    200                                                                                                 scaleFactor, 
    201                                                                                                 bl, br, tl, tr,  
    202                                                                                                 texcoord0, 
    203                                                                                                 oldEyePos, 
    204                                                                                                 oldbl, oldbr, oldtl, oldtr, 
    205                                                                                                 eyeSpaceDepth 
    206                                                                                                 ); 
    207                         //overallDepth += sampleDif; 
    208                         if (sampleDif >= MIN_DEPTH_DIFF) ++ notValid; 
    209                 } 
    210         } 
    211 #endif 
    212186 
    213187        const float oldWeight = clamp(oldPixel.y, .0f, temporalCoherence); 
     
    227201                // increase the weight for convergence 
    228202                newWeight = oldWeight + 1.0f; 
    229                 if (pixelValid > 1.0f) newWeight = 4.0f; 
     203                if ((pixelValid > 1.0f) && (squaredLen < 1e-8f)) newWeight = 4.0f; 
    230204                //if (pixelValid > 1.0f) newWeight = max(15.0f - notValid * 2.0f, 1.0f); 
    231205        } 
     
    461435        } 
    462436 
     437 
    463438        ///////////////// 
    464439        //-- compute temporal reprojection 
     
    482457 
    483458 
    484         OUT.illum_col.x = ao.y;//(ao.x + oldSsao * (newWeight - 1.0f)) / newWeight; 
     459        OUT.illum_col.x = (ao.x + oldSsao * (newWeight - 1.0f)) / newWeight; 
    485460        OUT.illum_col.y = newWeight; 
    486461        OUT.illum_col.z = invw; 
Note: See TracChangeset for help on using the changeset viewer.