Changeset 3319 for GTP


Ignore:
Timestamp:
02/18/09 18:34:49 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp

    r3305 r3319  
    107107 
    108108 
    109                         if (!normals.empty()) 
     109                        if (0)//!normals.empty()) 
    110110                        { 
    111111                                faceNormals.push_back(normals[nIndices[idx1]]); 
     
    358358                str.write(reinterpret_cast<char *>(geom->mTexcoords), sizeof(float) * texCoordCount * 2); 
    359359         
    360  
     360/* 
     361        ////////////// 
     362        //-- hack: a default material 
    361363        /////// 
    362364        //-- texture 
    363 /* 
     365 
    364366#ifdef USE_TEXTURE 
    365367        int texId = 0; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env

    r3313 r3319  
    101101ssaoUseFullResolution=1 
    102102# ssao kernel radius 
    103 ssaoKernelRadius=2.5f 
     103#ssaoKernelRadius=2.5f 
     104ssaoKernelRadius=1.28f 
    104105# ssao sample intensity 
    105106#ssaoSampleIntensity=0.2f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3316 r3319  
    309309mUseDepthOfField(false), 
    310310mSsaoUseFullResolution(ssaoUseFullResolution), 
    311 mMaxConvergence(2000.0f) 
     311mMaxConvergence(2000.0f), 
     312mSpatialWeight(.0f) 
    312313{ 
    313314        /////////// 
     
    465466 
    466467        string combineSsaoParams[] =  
    467                 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 
     468                //{"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 
     469                {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence", "spatialWeight"}; 
    468470 
    469471        //sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13); 
    470         sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 8); 
     472        sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 9); 
    471473 
    472474         
     
    474476 
    475477        string filterSsaoParams[] =  
    476                 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence"}; 
    477  
    478         sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 8); 
     478                {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res", "maxConvergence", "spatialWeight"}; 
     479 
     480        sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 9); 
    479481 
    480482 
     
    985987 
    986988        sCgFilterSsaoProgram->SetValue2f(i ++, (float)mWidth, (float)mHeight); 
    987         sCgFilterSsaoProgram->SetValue1f(i ++, (float)mMaxConvergence); 
     989        sCgFilterSsaoProgram->SetValue1f(i ++, mMaxConvergence); 
     990        sCgFilterSsaoProgram->SetValue1f(i ++, mSpatialWeight); 
    988991 
    989992        DrawQuad(sCgFilterSsaoProgram); 
     
    10121015 
    10131016        sCgCombineSsaoProgram->SetValue2f(i ++, mWidth, mHeight); 
    1014         sCgCombineSsaoProgram->SetValue1f(i ++, (float)mMaxConvergence); 
     1017        sCgCombineSsaoProgram->SetValue1f(i ++, mMaxConvergence); 
     1018        sCgCombineSsaoProgram->SetValue1f(i ++, mSpatialWeight); 
    10151019 
    10161020        DrawQuad(sCgCombineSsaoProgram); 
     
    15191523 
    15201524 
     1525void DeferredRenderer::SetSpatialWeight(float w) 
     1526{ 
     1527        mSpatialWeight = w; 
     1528} 
     1529 
     1530 
    15211531} // namespace 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3316 r3319  
    9999        void SetMaxConvergence(float c); 
    100100 
     101        void SetSpatialWeight(float w); 
    101102 
    102103        // hack: store the color buffer idx for the currently used flip flop-MRT here 
     
    228229 
    229230        float mMaxConvergence; 
     231        float mSpatialWeight; 
    230232}; 
    231233 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3318 r3319  
    287287 
    288288float maxConvergence = 2000.0f; 
    289  
     289float spatialWeight = 0.0001f; 
    290290 
    291291 
     
    635635#if 1 
    636636 
    637 #if 1 
     637#if 0 
    638638        // vienna positions 
    639639        VertexArray positions; 
     
    14311431                deferredShader->SetUseAntiAliasing(useAntiAliasing); 
    14321432                deferredShader->SetMaxConvergence(maxConvergence); 
     1433                deferredShader->SetSpatialWeight(spatialWeight); 
    14331434 
    14341435 
     
    16021603                break;*/ 
    16031604        case 'o': 
     1605                        spatialWeight /= 2.0f; 
     1606                        cout << "spatialWeight: " << spatialWeight << endl; 
     1607                        break; 
     1608        case 'O': 
     1609                        spatialWeight *= 2.0f; 
     1610                        cout << "spatialWeight: " << spatialWeight << endl; 
     1611                        break; 
     1612        /*case 'o': 
    16041613        case 'O': 
    16051614                if (maxConvergence > 100.0f) 
     
    16091618 
    16101619                cout << "max convergence: " << maxConvergence << endl; 
    1611  
     1620*/ 
    16121621                break; 
    16131622        case 'l': 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3318 r3319  
    88//#define NUM_SAMPLES 8 
    99//#define NUM_SAMPLES 16 
    10 #define NUM_SAMPLES 24 
    11 //#define NUM_SAMPLES 48 
     10//#define NUM_SAMPLES 24 
     11#define NUM_SAMPLES 48 
    1212 
    1313//#define MIN_SAMPLES 48 
     
    6161#define NUM_DOF_TABS 16 
    6262 
    63 //#define USE_GTX 
     63#define USE_GTX 
    6464 
    6565#define SSAO_FILTER_RADIUS 5 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsaoSep.cg

    r3318 r3319  
    5959                                        float3 tl, 
    6060                                        float3 tr, 
    61                                         float maxConvergence) 
     61                                        float maxConvergence, 
     62                                        float spatialWeight) 
    6263{ 
    6364        float2 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 
     
    7172        //float len = min(SqrLen(centerPos - samplePos), 1e2f); 
    7273        float len = distance(centerPos, samplePos); 
    73         float spatialFactor = 1.0f / max(len, 1e-3f); 
     74        //float spatialFactor = 1.0f / max(len, 1e-3f); 
     75        float spatialFactor = 1.0f / max(spatialWeight + len, 1e-3f); 
    7476 
    7577        float convergenceFactor = min(aoSample.y + 1.0f, maxConvergence); 
    76         convergenceFactor *= convergenceFactor; 
     78        //convergenceFactor *= convergenceFactor; 
    7779 
    7880        // combine the weights 
     81        //float w = convergenceFactor * exp(1.0f + spatialFactor); 
    7982        float w = convergenceFactor * spatialFactor; 
    8083        //float w = spatialFactor; 
     
    98101                           float2 xyStep, 
    99102                           float convergence, 
    100                            float maxConvergence 
     103                           float maxConvergence, 
     104                           float spatialWeight 
    101105                           ) 
    102106{ 
     
    105109        const float3 centerPos = ReconstructSamplePos(colorsTex, texCoord, bl, br, tl, tr); 
    106110 
    107         const float scale = saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
     111        const float scale = 1.0f;//saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
    108112        //const int radius = SSAO_FILTER_RADIUS * saturate((SSAO_CONVERGENCE_THRESHOLD - convergence) / SSAO_CONVERGENCE_THRESHOLD); 
    109113         
     
    112116        { 
    113117                float4 sampleTexCoord = float4(texCoord + i * xyStep * scale, .0f, .0f); 
    114                 result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence); 
     118                result += FilterSample(sampleTexCoord, ssaoTex, colorsTex, centerPos, bl, br, tl, tr, maxConvergence, spatialWeight); 
    115119        } 
    116120 
     
    151155        { 
    152156                // the filtered ssao value 
    153                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
     157                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
    154158        } 
    155159 
     
    167171                                                uniform float3 tr, 
    168172                                                uniform float2 res, 
    169                                                 uniform float maxConvergence 
     173                                                uniform float maxConvergence, 
     174                                                uniform float spatialWeight 
    170175                                                ) 
    171176{ 
     
    187192        { 
    188193                // the filtered ssao value 
    189                 OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
     194                OUT.illum_col.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
    190195        } 
    191196 
     
    205210                                  uniform float3 tr, 
    206211                                  uniform float2 res, 
    207                                   uniform float maxConvergence 
     212                                  uniform float maxConvergence, 
     213                                  uniform float spatialWeight 
    208214                                  ) 
    209215{ 
     
    226232        { 
    227233                // the filtered ssao value 
    228                 ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence); 
    229         } 
     234                ao.x = FilterXY(IN.texCoord, ssaoTex, colorsTex, bl, br, tl, tr, xyStep, convergence, maxConvergence, spatialWeight); 
     235        } 
     236 
     237        //const float minAO = 2e-2f; 
     238        const float minAO = 1e-3f; 
    230239 
    231240        // just apply ssao if we are not in the sky 
    232241        if (depth < DEPTH_THRESHOLD) 
    233242        { 
    234                 //OUT.illum_col.xyz = col.xyz * max(1e-3f, 1.0f - ao.x); 
    235                 OUT.illum_col.xyz = max(1e-3f, 1.0f - ao.x); 
     243                OUT.illum_col.xyz = col.xyz * max(minAO, 1.0f - ao.x); 
     244                //OUT.illum_col.xyz = max(minAO, 1.0f - ao.x); 
    236245        } 
    237246        else 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3318 r3319  
    5050 
    5151        float4 texelCenterConv; 
    52         const float2 offs(1.0f / res.x, 1.0f / res.y); 
     52        const float2 invRes = float2(1.0f / res.x, 1.0f / res.y); 
    5353 
    5454        // get position exactly between texel centers 
    55         float2 center = (floor(texCoord * res) + float2(.5f)) * offs; 
     55        float2 center = (floor(texCoord * res) + float2(.5f)) * texelCenterConv; 
    5656        //center.x = (floor(texCoord.x * res.x - .5f) + 1.0f) / res.x; 
    5757        //center.y = (floor(texCoord.y * res.y - .5f) + 1.0f) / res.y; 
     
    6868        const float convergence = min(m1, m2);*/ 
    6969 
    70         const float convergence = tex2Dlod(tex, float4(center, 0, 0)).y; 
     70        //const float convergence = tex2Dlod(tex, float4(center, 0, 0)).y; 
     71        const float convergence = tex2Dlod(tex, float4(texCoord, 0, 0)).y; 
    7172 
    7273        return convergence; 
     
    143144                w = min(min(w1, w2), min(w3, w4));*/ 
    144145                 
    145                 w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f)); 
    146                 //w = oldPixel.y; 
     146                //w = ComputeConvergence(oldTex, oldTexCoords, float2(1024.0f, 768.0f)); 
     147                w = oldPixel.y; 
    147148        } 
    148149        else 
     
    306307                float3 dirSample = samplePos - centerPosition; 
    307308 
    308                 //const float sqrLen = max(SqrLen(dirSample), 1e-2f); 
     309                //const float minDist = 9e-1f; 
     310                const float minDist = 1e-2f; 
     311 
     312                //const float sqrLen = max(SqrLen(dirSample), minDist); 
    309313                //const float lengthToSample = sqrt(sqrLen); 
    310                 const float lengthToSample =  max(length(dirSample), 1e-2f); 
     314                const float lengthToSample =  max(length(dirSample), minDist); 
    311315 
    312316                dirSample /= lengthToSample; // normalize 
     
    326330                // only mark sample as invalid if in the last / current frame 
    327331                // they possibly have any influence on the ao 
     332 
    328333                const float changeFactor = sampleColor.y; 
    329334                const float pixelValid = sampleColor.x; 
    330335 
     336                // hack: 
    331337                // we check if the sample could have been near enough to the current pixel  
     338                // or if the angle is small enough 
    332339                // to have any influence in the current or last frame 
    333 #if 0 
     340#if 1 
    334341                const float tooFarAway = step(0.5f, lengthToSample - changeFactor); 
    335                 validSamples = max(validSamples, (1.0f - tooFarAway) * pixelValid * step(-0.1f, cosAngle)); 
     342                if (pixelValid < 2.0f) 
     343                        validSamples = max(validSamples, pixelValid * (1.0f - tooFarAway) * step(-0.1f, cosAngle)); 
     344                else 
     345                        validSamples = max(validSamples, pixelValid); 
    336346#else 
    337347                validSamples = max(validSamples, pixelValid); 
     
    345355                        //break; 
    346356                        // if the pixel belongs to a static object and all the samples stay valid in the current frame 
    347                         if (!isMovingObject && (validSamples < 1.0f)) break; 
     357                        if (!isMovingObject && (validSamples < 1.0f) && (convergence > NUM_SAMPLES)) break; 
    348358                        // if the pixel belongs to a dynamic object but the #accumulated samples for this pixel is sufficiently high  
    349359                        // (=> there was no discontinuity recently) 
    350                         else if (isMovingObject && (convergence > NUM_SAMPLES * 5)) break; 
     360                        //else if (isMovingObject && (convergence > SSAO_CONVERGENCE_THRESHOLD)) break; 
     361                        //else if (isMovingObject && (convergence > NUM_SAMPLES * 5)) break; 
    351362                } 
    352363#endif 
Note: See TracChangeset for help on using the changeset viewer.