Changeset 3216


Ignore:
Timestamp:
12/09/08 01:11:40 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
9 edited

Legend:

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

    r3215 r3216  
    6161# shader options for deferred rendering 
    6262 
    63 # ssao temporal coherence factor 
    64 tempCohFactor=1000.0f 
    65  
    6663# tone mapping 
    6764useHDR=0 
    6865 
    6966# use antialiasing 
    70 useAA=1 
     67useAA=0 
    7168 
    7269# show lense flare 
     
    7976turbitity=3.0f 
    8077 
     78 
     79############### 
     80## ssao options 
     81 
     82# use full resolution ssao (vs. half resoltion) 
     83ssaoUseFullResolution=0 
     84 
     85# ssao kernel radius 
    8186ssaoKernelRadius=8e-1f 
    82  
     87# ssao sample intensity 
    8388ssaoSampleIntensity=0.2f 
     89# ssao temporal coherence factor 
     90tempCohFactor=1000.0f 
     91# ssao filter radius 
     92ssaoFilterRadius=12.0f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3215 r3216  
    318318 
    319319 
    320 DeferredRenderer::DeferredRenderer(int w, int h, PerspectiveCamera *cam): 
     320DeferredRenderer::DeferredRenderer(int w, int h,  
     321                                                                   PerspectiveCamera *cam, 
     322                                                                   bool ssaoUseFullResolution): 
    321323mWidth(w), mHeight(h),  
    322324mCamera(cam), 
     
    328330mSortSamples(true), 
    329331mKernelRadius(1e-8f), 
     332mSsaoFilterRadius(12.0f), 
    330333mSampleIntensity(0.2f), 
    331334mSunVisiblePixels(0) 
     
    334337        //-- the flip-flop fbos 
    335338 
    336         //const int dsw = w / 2; const int dsh = h / 2; 
     339        int downSampledWidth, downSampledHeight; 
     340 
     341        if (ssaoUseFullResolution) 
     342        { 
     343                downSampledWidth = w; downSampledHeight = h; 
     344                cout << "using full resolution ssao" << endl; 
     345        } 
     346        else 
     347        { 
     348                downSampledWidth = w / 2; downSampledHeight = h / 2; 
     349                cout << "using half resolution ssao" << endl; 
     350        } 
     351 
    337352        const int dsw = w; const int dsh = h; 
    338353 
    339         mIllumFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
     354        mIllumFbo = new FrameBufferObject(downSampledWidth, downSampledHeight, FrameBufferObject::DEPTH_NONE); 
    340355        //mIllumFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    341356 
     
    400415        ShaderManager *sm = ShaderManager::GetSingleton(); 
    401416 
    402         sCgDeferredProgram = sm->CreateFragmentProgram("deferred", "main", "deferredFrag"); 
    403         sCgDeferredShadowProgram = sm->CreateFragmentProgram("deferred", "main_shadow", "deferredFragShader"); 
    404         sCgSsaoProgram = sm->CreateFragmentProgram("ssao", "main", "ssaoFrag"); 
    405         sCgGiProgram = sm->CreateFragmentProgram("globillum", "main", "giFrag"); 
    406         sCgCombineIllumProgram = sm->CreateFragmentProgram("globillum", "combine", "combineGi"); 
    407         sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "combine", "combineSsao"); 
    408         sCgAntiAliasingProgram = sm->CreateFragmentProgram("antialiasing", "main", "antiAliasing"); 
    409         sCgToneProgram = sm->CreateFragmentProgram("tonemap", "ToneMap", "toneMap"); 
     417        sCgDeferredProgram = sm->CreateFragmentProgram("deferred", "main", "DeferredFrag"); 
     418        sCgDeferredShadowProgram = sm->CreateFragmentProgram("deferred", "main_shadow", "DeferredFragShadow"); 
     419        sCgSsaoProgram = sm->CreateFragmentProgram("ssao", "main", "SsaoFrag"); 
     420        sCgGiProgram = sm->CreateFragmentProgram("globillum", "main", "GiFrag"); 
     421        sCgCombineIllumProgram = sm->CreateFragmentProgram("globillum", "combine", "CombineGi"); 
     422        sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "CombineSsaoHalfRes", "CombineSsao"); 
     423        sCgAntiAliasingProgram = sm->CreateFragmentProgram("antialiasing", "main", "AntiAliasing"); 
     424        sCgToneProgram = sm->CreateFragmentProgram("tonemap", "ToneMap", "ToneMap"); 
    410425        sCgDownSampleProgram = sm->CreateFragmentProgram("deferred", "Output", "Output"); 
    411426        sCgScaleDepthProgram = sm->CreateFragmentProgram("deferred", "ScaleDepth", "ScaleDepth"); 
    412         sCgLogLumProgram = sm->CreateFragmentProgram("tonemap", "CalcAvgLogLum", "avgLogLum"); 
     427        sCgLogLumProgram = sm->CreateFragmentProgram("tonemap", "CalcAvgLogLum", "AvgLogLum"); 
    413428        sCgPrepareSsaoProgram = sm->CreateFragmentProgram("deferred", "PrepareSsao", "PrepareSsao"); 
    414429        sCgLenseFlareProgram = sm->CreateFragmentProgram("lenseFlare", "LenseFlare", "LenseFlare"); 
     
    451466 
    452467        string combineSsaoParams[] =  
    453                 {"colorsTex", "normalsTex", "ssaoTex", "filterOffs",  
    454                  "filterWeights", "modelViewProj", "bl", "br", "tl", "tr", "w", "h"}; 
    455         sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 12); 
     468                {"colorsTex", "normalsTex", "ssaoTex", "filterOffs", "filterWeights",  
     469                "ssaoFilterRadius", "modelViewProj", "bl", "br", "tl",  
     470                "tr", "w", "h"}; 
     471        sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13); 
    456472 
    457473        ////////////// 
     
    503519        //-- prepare filters for ssao 
    504520 
    505  
    506         const float filterWidth = 1.0f; 
    507  
    508         PoissonDiscSampleGenerator2 poisson(NUM_SSAO_FILTER_SAMPLES, 1.0f); 
    509         poisson.Generate((float *)ssaoFilterOffsets); 
    510  
    511         const float xoffs = (float)filterWidth / mWidth; 
    512         const float yoffs = (float)filterWidth / mHeight; 
    513  
    514         for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i) 
    515         { 
    516                 float x = ssaoFilterOffsets[2 * i + 0]; 
    517                 float y = ssaoFilterOffsets[2 * i + 1]; 
    518  
    519                 ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 
    520                 //ssaoFilterWeights[i] = 1.0f; 
    521  
    522                 ssaoFilterOffsets[2 * i + 0] *= xoffs; 
    523                 ssaoFilterOffsets[2 * i + 1] *= yoffs; 
    524         } 
     521        PrepareSsaoFilter(); 
    525522 
    526523 
     
    615612 
    616613 
     614void DeferredRenderer::PrepareSsaoFilter() 
     615{ 
     616        const float filterWidth = 1.0f; 
     617 
     618        PoissonDiscSampleGenerator2 poisson(NUM_SSAO_FILTER_SAMPLES, 1.0f); 
     619        poisson.Generate((float *)ssaoFilterOffsets); 
     620 
     621        const float xoffs = (float)filterWidth / mWidth; 
     622        const float yoffs = (float)filterWidth / mHeight; 
     623 
     624        for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i) 
     625        { 
     626                float x = ssaoFilterOffsets[2 * i + 0]; 
     627                float y = ssaoFilterOffsets[2 * i + 1]; 
     628 
     629                ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 
     630                //ssaoFilterWeights[i] = 1.0f; 
     631 
     632                ssaoFilterOffsets[2 * i + 0] *= xoffs; 
     633                ssaoFilterOffsets[2 * i + 1] *= yoffs; 
     634        } 
     635} 
     636 
    617637 
    618638static inline float SqrMag(const Sample2 &s) 
     
    934954        sCgCombineSsaoProgram->SetArray2f(i ++, (float *)ssaoFilterOffsets, NUM_SSAO_FILTER_SAMPLES); 
    935955        sCgCombineSsaoProgram->SetArray1f(i ++, (float *)ssaoFilterWeights, NUM_SSAO_FILTER_SAMPLES); 
    936          
     956        sCgCombineSsaoProgram->SetValue1f(i ++, mSsaoFilterRadius); 
     957 
    937958        sCgCombineSsaoProgram->SetMatrix(i++, mProjViewMatrix); 
    938959 
     
    13201341 
    13211342 
     1343void DeferredRenderer::SetSsaoFilterRadius(float ssaoFilterRadius) 
     1344{ 
     1345        mSsaoFilterRadius = ssaoFilterRadius; 
     1346} 
     1347 
     1348 
    13221349void DeferredRenderer::SetSortSamples(bool sortSamples)  
    13231350{ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3215 r3216  
    2626public: 
    2727        /** Constructor for a deferred shader taking the requested output image size, 
    28                 the current camera; 
     28                the current camera, and if the ssao should be full or half resolution 
    2929        */ 
    30         DeferredRenderer(int w, int h, PerspectiveCamera *cam); 
    31         /** The algorithm renders the scene given an fbo consists of 1 color buffer,  
    32                 1 position buffer, and 1 normal buffer. 
    33                 We also need the  projection view matrix of the last frame for reprojection, and 
    34                 a smoothing factor for temporal coherence 
     30        DeferredRenderer(int w, int h, PerspectiveCamera *cam, bool ssaoUsefulResolution); 
     31        /** Destructor 
    3532        */ 
     33        ~DeferredRenderer(); 
     34        /** The main render function 
     35            Currently our fbo consists of one combined color + depth buffer, a normal buffer,  
     36                and a buffer holding the difference of the pixel positions from the last frame. 
    3637 
    37         ~DeferredRenderer(); 
     38                Set useToneMapping to true if tone mapping should be applied 
     39                Set useAntiAliasing true if some basic edge antialiasing should be performed 
     40                If a shadowMap is specified that is not NULL, the shadow mapped shading algorithm is applied. 
    3841 
     42                The temporal coherence factor is the maximal number of ssao samples that are accumulated 
     43                without losing any prior sample information. 
     44                Set this number too low and flickering can be seen, too 
     45                high and the adaption to some changes in the ssao might be too slow. Usually from about 
     46                1000 samples a flickering cannot be seen. 
     47        */ 
    3948        void Render(FrameBufferObject *fbo,  
    4049                                float tempCohFactor,  
     
    4655 
    4756         
    48         void SetUseTemporalCoherence(bool temporal); 
    49  
    5057        enum SAMPLING_METHOD {SAMPLING_POISSON, SAMPLING_QUADRATIC, SAMPLING_DEFAULT}; 
    51          
     58        /** Use ssao or ssao + color bleeding 
     59        */ 
    5260        enum SHADING_METHOD {DEFAULT, SSAO, GI}; 
    53  
    5461        /** Set the samplig method for the indirect illumination 
    5562        */ 
     
    5865        */ 
    5966        void SetShadingMethod(SHADING_METHOD s); 
    60  
     67        /** Sort the samples so texture access is faster 
     68        */ 
    6169        void SetSortSamples(bool sortSamples); 
    62  
     70        /** Sets ssao sample intensity. 
     71        */ 
    6372        void SetSampleIntensity(float sampleIntensity); 
    64  
     73        /** Sets ssao kernel radius. 
     74        */ 
    6575        void SetKernelRadius(float kernelRadius); 
     76        /** Sets ssao filter radius. 
     77        */ 
     78        void SetSsaoFilterRadius(float radius); 
    6679        /** Sets the number of visible pixels of the sun 
    6780        */ 
    6881        void SetSunVisiblePixels(int visiblePixels); 
     82        /** If true tem poral coherence is used for ssao 
     83        */ 
     84        void SetUseTemporalCoherence(bool temporal); 
    6985 
    7086 
     
    126142        void LenseFlare(FrameBufferObject *fbo, DirectionalLight *light); 
    127143  
     144        void PrepareSsaoFilter(); 
     145 
    128146 
    129147        //////////// 
     
    133151        /// deferred shading output image height 
    134152        int mHeight; 
     153 
     154        ////////////////// 
     155 
    135156 
    136157        PerspectiveCamera *mCamera; 
     
    152173        FBOContainer mFBOs; 
    153174 
    154         static ShaderContainer sShaders; 
    155  
    156175        Matrix4x4 mProjViewMatrix; 
    157176        Matrix4x4 mOldProjViewMatrix; 
     
    166185 
    167186        float mKernelRadius; 
     187        float mSsaoFilterRadius; 
    168188        float mSampleIntensity; 
    169189 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.h

    r3215 r3216  
    6363        bool mUseNormalMapping; 
    6464 
     65 
    6566protected: 
    6667         
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntityConverter.h

    r2953 r3216  
    2323        */ 
    2424        SceneEntityConverter() {}; 
    25          
    26         //~SceneEntityConverter(); 
    27  
    2825        /** Converts this box to a scene entity 
    2926        */ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3215 r3216  
    110110int maxDepthForTestingChildren = 3; 
    111111 
     112bool ssaoUseFullResolution = false; 
     113 
    112114 
    113115/// the technique used for rendering 
     
    151153float ssaoKernelRadius = 1e-8f; 
    152154float ssaoSampleIntensity = 0.2f; 
     155float ssaoFilterRadius = 12.0f; 
    153156float ssaoTempCohFactor = 255.0; 
    154157bool sortSamples = true; 
     
    400403                env.GetFloatParam(string("ssaoSampleIntensity"), ssaoSampleIntensity); 
    401404 
     405                env.GetBoolParam(string("ssaoUseFullResolution"), ssaoUseFullResolution); 
     406 
    402407                //env.GetStringParam(string("modelPath"), model_path); 
    403408                //env.GetIntParam(string("numSssaoSamples"), numSsaoSamples); 
     
    426431                cout << "sample intensity: " << ssaoSampleIntensity << endl; 
    427432                cout << "kernel radius: " << ssaoKernelRadius << endl; 
     433                cout << "ssao full resolution: " << ssaoUseFullResolution << endl; 
    428434 
    429435                //cout << "model path: " << model_path << endl; 
     
    11861192 
    11871193                if (!deferredShader) deferredShader =  
    1188                         new DeferredRenderer(texWidth, texHeight, camera); 
     1194                        new DeferredRenderer(texWidth, texHeight, camera, ssaoUseFullResolution); 
    11891195                 
    11901196                DeferredRenderer::SHADING_METHOD shadingMethod; 
     
    11981204                } 
    11991205                else 
     1206                { 
    12001207                        shadingMethod = DeferredRenderer::DEFAULT; 
     1208                } 
    12011209 
    12021210                deferredShader->SetSunVisiblePixels(sunVisiblePixels); 
     
    12051213                deferredShader->SetKernelRadius(ssaoKernelRadius); 
    12061214                deferredShader->SetSampleIntensity(ssaoSampleIntensity); 
     1215                deferredShader->SetSsaoFilterRadius(ssaoFilterRadius); 
    12071216                deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 
    12081217                deferredShader->SetSortSamples(sortSamples); 
     
    13201329        case '7': 
    13211330                ssaoTempCohFactor *= 0.5f; 
     1331                cout << "new temporal coherence factor: " << ssaoTempCohFactor << endl; 
    13221332                break; 
    13231333        case '8': 
    13241334                ssaoTempCohFactor *= 2.0f; 
     1335                cout << "new temporal coherence factor: " << ssaoTempCohFactor << endl; 
    13251336                break; 
    13261337        case '9': 
    13271338                ssaoKernelRadius *= 0.8f; 
     1339                cout << "new ssao kernel radius: " << ssaoKernelRadius << endl; 
    13281340                break; 
    13291341        case '0': 
    13301342                ssaoKernelRadius *= 1.2f; 
     1343                cout << "new ssao kernel radius: " << ssaoKernelRadius << endl; 
    13311344                break; 
    13321345        case 'n': 
    13331346                ssaoSampleIntensity *= 0.9f; 
     1347                cout << "new ssao sample intensity: " << ssaoSampleIntensity << endl; 
    13341348                break; 
    13351349        case 'N': 
    13361350                ssaoSampleIntensity *= 1.1f; 
     1351                cout << "new ssao sample intensity: " << ssaoSampleIntensity << endl; 
     1352                break; 
     1353        case 'o': 
     1354                ssaoFilterRadius *= 0.9f; 
     1355                cout << "new ssao filter radius: " << ssaoFilterRadius << endl; 
     1356                break; 
     1357        case 'O': 
     1358                ssaoFilterRadius *= 1.1f; 
     1359                cout << "new ssao filter radius: " << ssaoFilterRadius << endl; 
    13371360                break; 
    13381361        case 'l': 
     
    13401363                useLODs = !useLODs; 
    13411364                SceneEntity::SetUseLODs(useLODs); 
     1365                cout << "using LODs: " << useLODs << endl; 
    13421366                break; 
    13431367        case 'P': 
     
    13581382                useTemporalCoherence = !useTemporalCoherence; 
    13591383                break; 
    1360         case 'o': 
     1384/*      case 'o': 
    13611385        case 'O': 
    13621386                useOptimization = !useOptimization; 
     1387                // chc optimization of using the objects instead of  
     1388                // the bounding boxes for querying previously visible nodes 
    13631389                traverser->SetUseOptimization(useOptimization); 
    1364                 break; 
     1390                break;*/ 
    13651391        case 'a': 
    13661392        case 'A': 
     
    14131439                useLenseFlare = !useLenseFlare; 
    14141440                break; 
     1441         
    14151442        default: 
    14161443                return; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/irradiance.cpp

    r3213 r3216  
    11351135 
    11361136                if (!deferredShader) deferredShader =  
    1137                         new DeferredRenderer(texWidth, texHeight, camera); 
     1137                        new DeferredRenderer(texWidth, texHeight, camera, 0); 
    11381138                 
    11391139                DeferredRenderer::SHADING_METHOD shadingMethod; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3214 r3216  
    1919 
    2020#define NUM_SSAO_FILTER_SAMPLES 16 
    21  
    22 #define SSAO_FILTER_WIDTH 12.0f 
    23 //#define SSAO_FILTER_WIDTH 6.0f 
    2421 
    2522#define SSAO_CONVERGENCE_THRESHOLD 700.0f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3212 r3216  
    2121 
    2222 
    23 /** Filter taking into account depth and normal differences,  
    24     and convergence of a sample   
     23/** Filter taking into account depth, normal discontinuities  
     24   and ssao convergence of a sample (the higher the more reliably 
     25   has the sample a correct ssao value) 
    2526*/ 
    2627float DiscontinuityFilter(float2 texCoord, 
     
    3132                                                  uniform sampler2D colorsTex, 
    3233                                                  uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 
    33                                                   uniform float filterWeights[NUM_SSAO_FILTER_SAMPLES], 
    34                                                   float scale 
    35                                                   ) 
    36 { 
    37         float average = .0f; 
    38         float total_w = .0f; 
    39  
    40         const float eyeSpaceDepth = color.w; 
    41  
    42         const float3 centerNormal = tex2Dlod(normalsTex, float4(texCoord, 0, 0)).xyz; 
    43  
    44         float4 aoSample; 
    45         float3 sampleNorm; 
    46         float3 samplePos; 
    47         float w; 
    48         float4 sampleTexCoord; 
    49         float depthFactor; 
    50         float normalFactor; 
    51         float convergenceFactor; 
    52         float sampleDepth; 
    53  
    54         for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i) 
    55         { 
    56                 sampleTexCoord = float4(texCoord + filterOffs[i] * scale, 0, 0); 
    57  
    58                 aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 
    59                 sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 
    60  
    61                 // check depth discontinuity 
    62                 sampleDepth = tex2Dlod(colorsTex, sampleTexCoord).w; 
    63                 //sampleDepth = aoSample.w; 
    64                  
    65                 //depthFactor = 1.0f / max(abs(eyeSpaceDepth - sampleDepth), 1e-2f); 
    66                 depthFactor = 1.0f - step(1e-2f, abs(1.0f - eyeSpaceDepth / sampleDepth)); 
    67                 //normalFactor = max(step(0.6f, dot(sampleNorm, centerNormal)), 1e-3f); 
    68                 normalFactor = max(dot(sampleNorm, centerNormal), 1e-3f); 
    69                 //convergenceFactor = min(100.0f, aoSample.y); 
    70                 convergenceFactor = aoSample.y + 1.0f; 
    71  
    72                 // combine the weights 
    73                 w = filterWeights[i] * convergenceFactor * depthFactor * normalFactor; 
    74                 //w = normalFactor * convergenceFactor; 
    75  
    76                 average += aoSample.x * w; 
    77                 total_w += w; 
    78         } 
    79  
    80         average /= max(total_w, 1e-6f); 
    81  
    82         return saturate(average); 
    83 } 
    84  
    85  
    86  
    87 /** Filter taking into account depth and normal differences,  
    88    and convergence of a sample   
    89 */ 
    90 float DiscontinuityFilter2(float2 texCoord, 
    91                                                    float4 ao, 
    92                                                    float4 color, 
    93                                                    uniform sampler2D ssaoTex, 
    94                                                    uniform sampler2D normalsTex, 
    95                                                    uniform sampler2D colorsTex, 
    96                                                    uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 
    97                                                    float scale, 
    98                                                    float3 bl, 
    99                                                    float3 br, 
    100                                                    float3 tl, 
    101                                                    float3 tr) 
     34                                                  float scale, 
     35                                                  float3 bl, 
     36                                                  float3 br, 
     37                                                  float3 tl, 
     38                                                  float3 tr) 
    10239{ 
    10340        float average = .0f; 
     
    15491 
    15592/** Function combining image and indirect illumination buffer using a  
    156         depth and normal aware discontinuity filter. 
     93        depth and normal aware discontinuity filter. We assume that  
     94        we are using half resolution ssao for this version of the combineSsao 
    15795*/ 
    158 pixel combine(fragment IN,  
    159                           uniform sampler2D colorsTex, 
    160                           uniform sampler2D ssaoTex, 
    161                           uniform sampler2D normalsTex, 
    162                           uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 
    163                           uniform float filterWeights[NUM_SSAO_FILTER_SAMPLES], 
    164                           uniform float4x4 modelViewProj, 
    165                           uniform float3 bl, 
    166                           uniform float3 br, 
    167                           uniform float3 tl, 
    168                           uniform float3 tr, 
    169                           uniform float w, 
    170                           uniform float h 
    171                           ) 
     96pixel CombineSsaoHalfRes(fragment IN,  
     97                                                 uniform sampler2D colorsTex, 
     98                                                 uniform sampler2D ssaoTex, 
     99                                                 uniform sampler2D normalsTex, 
     100                                                 uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 
     101                                                 uniform float filterWeights[NUM_SSAO_FILTER_SAMPLES], 
     102                                                 uniform float ssaoFilterRadius, 
     103                                                 uniform float4x4 modelViewProj, 
     104                                                 uniform float3 bl, 
     105                                                 uniform float3 br, 
     106                                                 uniform float3 tl, 
     107                                                 uniform float3 tr, 
     108                                                 uniform float w, 
     109                                                 uniform float h 
     110                                                 ) 
    172111{ 
    173112        pixel OUT; 
     
    176115        float4 ao =  tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    177116 
     117        // the following has to be done for half resolution ssao: 
    178118        // get the minimum convergence by exactly sampling the 4 surrounding 
    179119        // texels in the old texture, otherwise flickering because convergence 
    180120        // will be interpolated when upsampling and filter size does not match! 
     121 
    181122        float4 texelCenterConv; 
    182123        const float xoffs = .5f / w; const float yoffs = .5f / h; 
     
    210151 
    211152                // descend to zero filter size after reaching thres pixels 
    212                 const float convergenceWeight = SSAO_CONVERGENCE_THRESHOLD / (SSAO_FILTER_WIDTH - 1.0f); 
     153                const float convergenceWeight = SSAO_CONVERGENCE_THRESHOLD / (ssaoFilterRadius - 1.0f); 
    213154                const float convergenceScale = convergenceWeight / (convergence + convergenceWeight); 
    214                 const float scale = SSAO_FILTER_WIDTH * convergenceScale * distanceScale; 
     155                const float scale = ssaoFilterRadius * convergenceScale * distanceScale; 
    215156 
    216157                // the filtered ssao value 
    217                 ao.x = DiscontinuityFilter2(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr); 
     158                ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr); 
    218159        } 
    219160 
Note: See TracChangeset for help on using the changeset viewer.