Ignore:
Timestamp:
03/05/09 16:06:46 (15 years ago)
Author:
mattausch
Message:

performance testing

File:
1 edited

Legend:

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

    r3330 r3331  
    182182                         float3 normal, 
    183183                         float3 centerPosition, 
    184                          float scaleFactor, 
     184                         float radius, 
    185185                         float3 bl, 
    186186                         float3 br, 
     
    223223                 
    224224                // weight with projected coordinate to reach similar kernel size for near and far 
    225                 const float2 texcoord = IN.texCoord.xy + offset * scaleFactor; 
     225                const float2 texcoord = IN.texCoord.xy + offset * radius; 
    226226 
    227227                const float4 sampleColor = tex2Dlod(colors, float4(texcoord, .0f, .0f)); 
     
    235235 
    236236                const float minDist = 1e-6f; 
    237                 const float scaleFactor = 1e-3f; 
     237                const float delta = 1e-3f; 
    238238 
    239239                const float lengthToSample = length(dirSample); 
    240                 const float sampleWeight = 1.0f / (lengthToSample + scaleFactor); 
     240                const float sampleWeight = 1.0f / (lengthToSample + delta); 
    241241 
    242242                dirSample /= max(lengthToSample, minDist); // normalize 
     
    329329                        float3 normal, 
    330330                        float3 centerPosition, 
    331                         float scaleFactor, 
     331                        float radius, 
    332332                        float3 bl, 
    333333                        float3 br, 
     
    370370 
    371371                // weight with projected coordinate to reach similar kernel size for near and far 
    372                 const float2 texcoord = IN.texCoord.xy + offset * scaleFactor; 
     372                const float2 texcoord = IN.texCoord.xy + offset * radius; 
    373373 
    374374                const float4 sampleColor = tex2Dlod(colors, float4(texcoord, .0f, .0f)); 
     
    382382 
    383383                const float minDist = 1e-6f; 
    384                 const float scaleFactor = 1e-3f; 
     384                const float delta = 1e-3f; 
    385385 
    386386                const float lengthToSample = length(dirSample); 
    387                 const float sampleWeight = 1.0f / (lengthToSample + scaleFactor); 
     387                const float sampleWeight = 1.0f / (lengthToSample + delta); 
    388388 
    389389                dirSample /= max(length(dirSample), minDist); // normalize 
     
    399399 
    400400                ++ numSamples; 
    401  
     401#ifdef PERFORMANCE_TEST 
    402402                // check if the samples have been valid in the last frame 
    403403                // only mark sample as invalid if in the last / current frame 
     
    411411                // or if the angle is small enough 
    412412                // to have any influence in the current or last frame 
     413 
    413414#if 1 
    414415                const float partlyResetThres = 1.0f; 
     
    435436                } 
    436437#endif 
     438 
     439#endif // PERFORMANCE_TEST 
     440 
    437441        } 
    438442 
     
    488492        const float4 eyeSpacePos = float4(-viewDir * eyeSpaceDepth, 1.0f); 
    489493 
    490         float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
    491          
    492  
    493494        //////////////// 
    494495        //-- calculcate the current projected posiion (also used for next frame) 
     
    497498        const float invw = 1.0f / projPos.w; 
    498499        projPos *= invw; 
    499         float scaleFactor = kernelRadius * invw; 
     500         
     501        //const float radiusMult = kernelRadius; 
     502        const float radiusMult = 3e-2; 
     503        //const float radiusMult = kernelRadius * invw; 
     504         
     505#ifdef PERFORMANCE_TEST  
     506 
     507        float3 diffVec = tex2Dlod(attribsTex, float4(IN.texCoord, 0, 0)).xyz; 
    500508 
    501509        const float sqrMoveSpeed = SqrLen(diffVec); 
     
    514522                                                                        diffVec 
    515523                                                                        ); 
    516  
     524         
    517525        const float oldSsao = temporalVals.x; 
    518526         
     
    520528        float oldIdx = temporalCoherence > 1 ? temporalVals.z : 0; 
    521529         
     530#else 
     531 
     532        const bool isMovingObject = false; 
     533        const float oldSsao = 0; 
     534         
     535        float oldWeight = 0; 
     536        float oldIdx = 0; 
     537         
     538#endif 
     539 
    522540        float3 ao; 
    523541 
     
    528546                { 
    529547                        ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz,  
    530                                       scaleFactor, bl, br, tl, tr, normalize(viewDir), 
     548                                      radiusMult, bl, br, tl, tr, normalize(viewDir), 
    531549                                          oldWeight, sampleIntensity, isMovingObject, oldIdx); 
    532550                } 
    533551                else 
    534552                { 
    535                         ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor,  
     553                        ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, radiusMult,  
    536554                                   bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity,  
    537555                                           isMovingObject, normals, oldIdx); 
     
    543561        } 
    544562 
    545          
     563#ifdef PERFORMANCE_TEST 
     564 
    546565        /////////// 
    547566        //-- check if we have to reset pixel because one of the sample points was invalid 
     
    592611        //OUT.illum_col.z = SqrLen(diffVec); 
    593612 
     613#else 
     614 
     615        OUT.illum_col.x = ao.x; 
     616        OUT.illum_col.w = eyeSpaceDepth; 
     617         
     618#endif 
     619 
    594620        return OUT; 
    595621} 
Note: See TracChangeset for help on using the changeset viewer.