Changeset 3212


Ignore:
Timestamp:
12/07/08 23:26:00 (15 years ago)
Author:
mattausch
Message:

made ssao parameters more flexible
started to implement lense flare

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
1 added
13 edited

Legend:

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

    r3207 r3212  
    1414EndProject 
    1515Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IrradianceMapping", "IrradianceMapping.vcproj", "{91680C49-A358-48AE-A02C-66CB884B7D7F}" 
     16        ProjectSection(ProjectDependencies) = postProject 
     17                {03661866-4093-4B02-B26A-028EA91AF023} = {03661866-4093-4B02-B26A-028EA91AF023} 
     18        EndProjectSection 
    1619EndProject 
    1720Global 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r3202 r3212  
    772772                        </File> 
    773773                        <File 
     774                                RelativePath=".\src\shaders\lenseFlare.cg" 
     775                                > 
     776                        </File> 
     777                        <File 
    774778                                RelativePath=".\src\shaders\mrt.cg" 
    775779                                > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3202 r3212  
    5757# window options 
    5858 
     59//winWidth=800 
     60//winHeight=600 
     61 
    5962winWidth=1024 
    6063winHeight=768 
     
    8992//camPosition=465.626 248.788 184.978 
    9093//camDirection=0.0592959 0.998021 0.0209425 
     94 
     95ssaoKernelRadius=8e-1f 
     96 
     97ssaoSampleIntensity=0.2f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3206 r3212  
    7676static float ssaoFilterWeights[NUM_SSAO_FILTER_SAMPLES]; 
    7777 
     78static GLuint sBurstTex; 
     79static GLuint sHaloTex[4]; 
    7880 
    7981int DeferredRenderer::colorBufferIdx = 0; 
     82 
     83 
     84static void PrepareLenseFlare() 
     85{ 
     86        sBurstTex = new Texture("burst.jpg"); 
     87 
     88        Texture(const std::string &filename); 
     89 
     90        glEnable(GL_TEXTURE_2D); 
     91        glGenTextures(1, &sBurstTex); 
     92        glBindTexture(GL_TEXTURE_2D, sBurstTex); 
     93                 
     94        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
     95        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
     96        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 
     97        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
     98 
     99        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, randomNormals); 
     100 
     101        glBindTexture(GL_TEXTURE_2D, 0); 
     102        glDisable(GL_TEXTURE_2D); 
     103 
     104        delete [] randomNormals; 
     105 
     106        cout << "prepared lense flare textures" << endl; 
     107 
     108        PrintGLerror("prepare lense flare"); 
     109} 
    80110 
    81111 
     
    300330mShadingMethod(DEFAULT), 
    301331mIllumFboIndex(0), 
    302 mSortSamples(true) 
     332mSortSamples(true), 
     333mKernelRadius(1e-8f), 
     334mSampleIntensity(0.2f) 
    303335{ 
    304336        /////////// 
    305337        //-- the flip-flop fbos 
    306338 
    307         const int dsw = w / 2; const int dsh = h / 2; 
    308         //const int dsw = w; const int dsh = h; 
     339        //const int dsw = w / 2; const int dsh = h / 2; 
     340        const int dsw = w; const int dsh = h; 
    309341 
    310342        mIllumFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
     
    321353 
    322354        /////////////// 
    323         //-- the downsampled ssao + color bleeding textures: as GI is mostly low frequency, we can use lower resolution toimprove performance 
     355        //-- the downsampled ssao + color bleeding textures:  
     356        //-- as GI is mostly low frequency, we can use lower resolution toimprove performance 
    324357 
    325358        mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
     
    327360        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    328361        // downsample buffer for the normal texture 
    329         mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
     362        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     363 
    330364 
    331365        for (int i = 0; i < 2; ++ i) 
     
    395429                 "samples", "bl", "br", "tl", "tr",  
    396430                 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr",  
    397                  "oldtl", "oldtr", "attribsTex"}; 
    398         sCgSsaoProgram->AddParameters(ssaoParams, 0, 18); 
     431                 "oldtl", "oldtr", "attribsTex", "kernelRadius", "sampleIntensity"}; 
     432        sCgSsaoProgram->AddParameters(ssaoParams, 0, 20); 
    399433         
    400434        string giParams[] =  
     
    702736 
    703737        for (int j = 0; j < 4; ++ j, ++ i) 
     738        { 
    704739                sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 
     740        } 
    705741 
    706742        sCgSsaoProgram->SetTexture(i ++, attribsTex); 
     743        sCgSsaoProgram->SetValue1f(i ++, mKernelRadius); 
     744        sCgSsaoProgram->SetValue1f(i ++, mSampleIntensity); 
    707745 
    708746 
     
    957995 
    958996 
     997#if TODO 
     998 
     999void DeferredRenderer::SetNumSamples(int numSamples) 
     1000{ 
     1001        mNumSamples = numSamples; 
     1002} 
     1003 
     1004#endif 
     1005 
     1006 
     1007void DeferredRenderer::SetSampleIntensity(float sampleIntensity) 
     1008{ 
     1009        mSampleIntensity = sampleIntensity; 
     1010} 
     1011 
     1012 
     1013void DeferredRenderer::SetKernelRadius(float kernelRadius) 
     1014{ 
     1015        mKernelRadius = kernelRadius; 
     1016} 
     1017 
     1018 
    9591019void DeferredRenderer::ComputeToneParameters(FrameBufferObject *fbo,  
    9601020                                                                                         DirectionalLight *light, 
     
    10581118        mDownSampleFbo->Bind(); 
    10591119 
    1060 // prepare downsampled color and normal texture for ssao 
     1120        // prepare downsampled depth and normal texture for ssao 
    10611121        glDrawBuffers(2, mrt); 
    10621122 
     
    10661126        PrintGLerror("prepareSsao"); 
    10671127} 
    1068  
    10691128 
    10701129 
     
    11971256} 
    11981257 
     1258 
     1259void DeferredRenderer::LenseFlare(FrameBufferObject *fbo) 
     1260{ 
     1261        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     1262 
     1263        FlipFbos(fbo); 
     1264 
     1265        sCgLenseFlareProgram->SetTexture(0, colorsTex); 
     1266        sCgLenseFlareProgram->SetTexture(1, sBurstTex); 
     1267        sCgLenseFlareProgram->SetTexture(2, sHaloTex[0]); 
     1268        sCgLenseFlareProgram->SetTexture(3, sHaloTex[1]); 
     1269        sCgLenseFlareProgram->SetValue1f(4, sHaloTex[2]); 
     1270        sCgLenseFlareProgram->SetValue1f(5, sHaloTex[3]); 
     1271 
     1272        DrawQuad(sCgLenseFlareProgram); 
     1273 
     1274        PrintGLerror("LenseFlare"); 
     1275} 
     1276 
     1277 
    11991278} // namespace 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3189 r3212  
    5858 
    5959        void SetSortSamples(bool sortSamples) { mSortSamples = sortSamples; } 
     60 
     61        void SetSampleIntensity(float sampleIntensity); 
     62 
     63        void SetKernelRadius(float kernelRadius); 
     64 
    6065 
    6166        // hack: store the color buffer idx for the currently used flip flop-MRT here 
     
    150155 
    151156        bool mSortSamples; 
     157 
     158        float mKernelRadius; 
     159        float mSampleIntensity; 
    152160}; 
    153161 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Texture.h

    r3147 r3212  
    1616public: 
    1717         
     18        // available texture formats 
    1819        enum {FORMAT_INVALID, FORMAT_RGB, FORMAT_RGBA}; 
    19          
     20        // texture uv modes 
    2021        enum {CLAMP, REPEAT}; 
    2122 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3203 r3212  
    147147float turbitity = 5.0f; 
    148148 
     149// ssao parameters 
     150float ssaoKernelRadius = 1e-8f; 
     151float ssaoSampleIntensity = 0.2f; 
     152float ssaoTempCohFactor = 255.0; 
     153bool sortSamples = true; 
     154 
    149155int shadowSize = 2048; 
     156 
    150157/// the hud font 
    151158glfont::GLFont myfont; 
    152159 
    153160// rendertexture 
    154 static int texWidth = 1024; 
    155 static int texHeight = 768; 
     161int texWidth = 1024; 
     162int texHeight = 768; 
    156163 
    157164int renderedObjects = 0; 
     
    211218 
    212219PerfTimer frameTimer, algTimer; 
    213 /// the performance window 
     220/// the performance graph window 
    214221PerformanceGraph *perfGraph = NULL; 
    215222 
    216 float ssaoTempCohFactor = 255.0; 
    217 bool sortSamples = true; 
    218223int sCurrentMrtSet = 0; 
    219224 
     
    384389                env.GetIntParam(string("renderMethod"), renderMethod); 
    385390 
     391                env.GetFloatParam(string("ssaoKernelRadius"), ssaoKernelRadius); 
     392                env.GetFloatParam(string("ssaoSampleIntensity"), ssaoSampleIntensity); 
     393 
    386394                //env.GetStringParam(string("modelPath"), model_path); 
    387395                //env.GetIntParam(string("numSssaoSamples"), numSsaoSamples); 
     396 
     397                texWidth = winWidth; 
     398                texHeight = winHeight; 
    388399 
    389400                cout << "assumedVisibleFrames: " << assumedVisibleFrames << endl;  
     
    398409                cout << "useLODs: " << useLODs << endl; 
    399410                cout << "camPosition: " << camPos << endl; 
    400                 cout << "temporal coherence: " << ssaoTempCohFactor << endl; 
    401411                cout << "shadow size: " << shadowSize << endl; 
    402412                cout << "render method: " << renderMethod << endl; 
     
    404414                cout << "use advanced shading: " << useAdvancedShading << endl; 
    405415                cout << "turbitity: " << turbitity << endl; 
     416                cout << "temporal coherence: " << ssaoTempCohFactor << endl; 
     417                cout << "sample intensity: " << ssaoSampleIntensity << endl; 
     418                cout << "kernel radius: " << ssaoKernelRadius << endl; 
    406419 
    407420                //cout << "model path: " << model_path << endl; 
     
    11511164                deferredShader->SetShadingMethod(shadingMethod); 
    11521165                deferredShader->SetSamplingMethod(samplingMethod); 
     1166                deferredShader->SetKernelRadius(ssaoKernelRadius); 
     1167                deferredShader->SetSampleIntensity(ssaoSampleIntensity); 
    11531168                deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 
    11541169                deferredShader->SetSortSamples(sortSamples); 
     
    12031218        { 
    12041219        case 27: 
     1220                // write out current position on exit 
    12051221                Debug << "camPosition=" << camera->GetPosition().x << " " << camera->GetPosition().y << " " << camera->GetPosition().z << endl; 
    12061222                Debug << "camDirection=" << camera->GetDirection().x << " " << camera->GetDirection().y << " " << camera->GetDirection().z << endl; 
     
    12471263                break; 
    12481264        case '3': 
    1249                 if (trianglesPerVirtualLeaf >= 100) 
    1250                         trianglesPerVirtualLeaf -= 100; 
     1265                if (trianglesPerVirtualLeaf >= 100) trianglesPerVirtualLeaf -= 100; 
    12511266                bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 
    12521267                break; 
     
    12691284        case '8': 
    12701285                ssaoTempCohFactor *= 2.0f; 
    1271                 //if (ssaoTempCohFactor > 1.0f) ssaoExpFactor = 1.0f; 
     1286                break; 
     1287        case '9': 
     1288                ssaoKernelRadius *= 0.8f; 
     1289                break; 
     1290        case '0': 
     1291                ssaoKernelRadius *= 1.2f; 
     1292                break; 
     1293        case 'n': 
     1294                ssaoSampleIntensity *= 0.9f; 
     1295                break; 
     1296        case 'N': 
     1297                ssaoSampleIntensity *= 1.1f; 
    12721298                break; 
    12731299        case 'l': 
     
    13441370                useAntiAliasing = !useAntiAliasing; 
    13451371                break; 
    1346         case '9': 
     1372        /*case '?': 
    13471373                sortSamples = !sortSamples; 
    13481374                break; 
     1375        */ 
    13491376        default: 
    13501377                return; 
     
    20032030         
    20042031        preetham->RenderSkyDome(-light->GetDirection(), camera, &renderState, !useToneMapping); 
    2005         /// once again reset the renderState 
     2032 
     2033        /// once again reset the renderState just to make sure 
    20062034        renderState.Reset(); 
    20072035} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3209 r3212  
    77 
    88//#define NUM_SAMPLES 8 
    9 //#define NUM_SAMPLES 16 
     9#define NUM_SAMPLES 16 
    1010//#define NUM_SAMPLES 24 
    11 #define NUM_SAMPLES 48 
     11//#define NUM_SAMPLES 96 
    1212 
    13 #define SAMPLE_INTENSITY 0.15f 
    14 //#define SAMPLE_INTENSITY 2.0f 
    15  
    16 #define SAMPLE_RADIUS 8e-1f 
    17 //#define SAMPLE_RADIUS 15e-1f 
    18  
    19 //#define DISTANCE_SCALE 1e-1f 
    2013#define DISTANCE_SCALE 1e-2f 
    2114 
    2215//#define ILLUM_INTENSITY 8e-2f 
    2316#define ILLUM_INTENSITY 5e-3f 
    24  
     17/// scale factor that takes angle of sample normal into account  
    2518#define VIEW_CORRECTION_SCALE 1.0f 
    2619 
    27 //#define NUM_SSAO_FILTERSAMPLES 80 
    2820#define NUM_SSAO_FILTER_SAMPLES 16 
    2921 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3209 r3212  
    125125 
    126126                aoSample = tex2Dlod(ssaoTex, sampleTexCoord); 
    127                 //sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 
    128  
     127                 
    129128                // check spatial discontinuity 
    130129                // note: using the depth from the color texture is not 100% correct as depth was 
     
    136135                spatialFactor = 1.0f / max(len, 1e-3f); 
    137136 
     137                convergenceFactor = aoSample.y + 1.0f; 
     138 
     139                //sampleNorm = tex2Dlod(normalsTex, sampleTexCoord).xyz; 
    138140                //normalFactor = max(step(.2f, dot(sampleNorm, centerNormal)), 1e-2f); 
    139                 convergenceFactor = aoSample.y + 1.0f; 
    140                  
     141 
    141142                // combine the weights 
    142143                w = convergenceFactor * convergenceFactor * spatialFactor;// * normalFactor; 
     
    232233        return OUT; 
    233234} 
    234  
    235  
    236 /** Function combining image and indirect illumination buffer using a  
    237         depth and normal aware discontinuity filter. 
    238 */ 
    239 pixel SmoothSsao(fragment IN,  
    240                                  uniform sampler2D ssaoTex) 
    241 { 
    242         pixel OUT; 
    243  
    244         float4 ao = tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    245  
    246         float4 dummy; 
    247         const float xoffs = .5f / 1024.0f; const float yoffs = .5f / 768.0f; 
    248  
    249         // get positions exactly between old texel centers 
    250         dummy.x = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(xoffs, 0), 0, 0)).y; 
    251         dummy.y = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, -yoffs), 0, 0)).y; 
    252         dummy.z = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(-xoffs, 0), 0, 0)).y; 
    253         dummy.w = tex2Dlod(ssaoTex, float4(IN.texCoord + float2(0, yoffs), 0, 0)).y; 
    254  
    255         const float m1 = min(dummy.x, dummy.y); 
    256         const float m2 = min(dummy.z, dummy.w); 
    257  
    258         ao.y = min(ao.y, min(m1, m2)); 
    259  
    260         return OUT; 
    261 } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3210 r3212  
    261261        const bool oldDynamic = (squaredLen > DYNAMIC_OBJECTS_THRESHOLD); 
    262262        const bool newDynamic = (oldPixel.z > DYNAMIC_OBJECTS_THRESHOLD); 
    263  
    264         //const float xOffs = 1.0f / 1024.0f;   const float yOffs = 1.0f / 768.0f; 
    265         //const float eps = 1e-6f; 
    266263 
    267264        // actually 0 means pixel is valid 
     
    334331        pix.color = color; 
    335332        pix.color.xy = pValid.xy; 
     333        pix.color.z = color.w; 
     334 
    336335        pix.normal = normal; 
    337336 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/globillum.cg

    r3168 r3212  
    6565                                   uniform float3 br, 
    6666                                   uniform float3 tl, 
    67                                    uniform float3 tr 
    68                                    , uniform float3 viewDir 
     67                                   uniform float3 tr,  
     68                                   float3 viewDir, 
     69                                   float sampleIntensity 
    6970                                   ) 
    7071{ 
     
    125126                const float denom = (DISTANCE_SCALE + magSample * magSample); 
    126127 
    127                 float2 intensity = float2(SAMPLE_INTENSITY, ILLUM_INTENSITY); 
     128                float2 intensity = float2(sampleIntensity, ILLUM_INTENSITY); 
    128129                intensity /= denom; 
    129130 
     
    161162                   uniform float3 br, 
    162163                   uniform float3 tl, 
    163                    uniform float3 tr 
     164                   uniform float3 tr, 
     165                   uniform float kernelRadius, 
     166                   uniform float sampleIntensity 
    164167                   ) 
    165168{ 
    166169        pixel2 OUT; 
    167170 
    168         const float3 normal = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)); 
     171        const float3 normal = tex2Dlod(normals, float4(IN.texCoord, 0 ,0)).xyz; 
    169172 
    170173         
     
    180183        float4 currentPos = mul(modelViewProj, eyeSpacePos); 
    181184 
    182         const float w = SAMPLE_RADIUS / currentPos.w; 
     185        const float w = kernelRadius / currentPos.w; 
    183186        currentPos /= currentPos.w; 
    184187         
     
    188191        //-- compute color bleeding + ao 
    189192 
    190         GiStruct gi = globIllum(IN, colors, noiseTex, samples, normal, eyeSpacePos, w, bl, br, tl, tr, normalize(IN.view)); 
     193        GiStruct gi = globIllum(IN, colors, noiseTex, samples, normal, eyeSpacePos, w, bl, br, tl, tr, normalize(IN.view), sampleIntensity); 
    191194         
    192195 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3209 r3212  
    108108        const float ssao = oldPixel.x; 
    109109 
    110 #if USE_EYESPACE_DEPTH 
    111  
    112110        // calculate eye space position of sample in old frame 
    113111        const float oldEyeSpaceDepth = oldPixel.w; 
     
    120118         
    121119        const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 
    122  
    123 #else 
    124  
    125         // calculate eye space position of sample in old frame 
    126         const float oldDepth = oldPixel.w; 
    127         // the depth projected into the old frame 
    128         const float projectedDepth = projPos.z; 
    129         // calculate depth difference  
    130         const float depthDif = abs(projectedDepth - oldDepth); 
    131  
    132 #endif 
    133120 
    134121        const float xOffs = 1.0f / 1024.0f; 
     
    176163                         float3 tr,  
    177164                         float3 viewDir, 
    178                          sampler2D normalTex 
     165                         sampler2D normalTex, 
     166                         float sampleIntensity 
    179167                         ) 
    180168{ 
     
    224212                cosAngle *= step(0.0f, dot(dirSample, normal)); 
    225213         
    226                 const float aoContrib = SAMPLE_INTENSITY / sqrLen; 
     214                const float aoContrib = sampleIntensity / sqrLen; 
    227215                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
    228216 
     
    270258                        float3 viewDir, 
    271259                        float newWeight, 
    272                         bool isMovingObject 
     260                        float sampleIntensity 
    273261                        ) 
    274262{ 
     
    310298                // angle between current normal and direction to sample controls AO intensity. 
    311299                const float cosAngle = max(dot(dirSample, normal), .0f); 
    312                 const float aoContrib = SAMPLE_INTENSITY / sqrLen; 
     300                const float aoContrib = sampleIntensity / sqrLen; 
    313301                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
    314302 
     
    338326 
    339327                //if ((validSamples < 1.0f) && (newWeight > 200) && (numSamples >= 8)) break; 
    340                 if ((validSamples < 1.0f) && (numSamples >= 8) && !isMovingObject  
    341                         || (newWeight > NUM_SAMPLES * 5) && (numSamples >= 8) && isMovingObject 
    342                         ) 
    343                 { 
    344                         break; 
    345                 } 
     328                //if ((validSamples < 1.0f) && (numSamples >= 8)) break; 
    346329        } 
    347330 
    348331        total_ao /= numSamples; 
    349332 
    350         //return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
    351         return float3(total_ao, validSamples, numSamples); 
     333        return float3(max(0.0f, 1.0f - total_ao), validSamples, numSamples); 
    352334} 
    353335 
     
    374356                   uniform float3 oldtl, 
    375357                   uniform float3 oldtr, 
    376                    uniform sampler2D attribsTex 
     358                   uniform sampler2D attribsTex, 
     359                   uniform float kernelRadius, 
     360                   uniform float sampleIntensity 
    377361                   ) 
    378362{ 
     
    396380        const float invw = 1.0f / projPos.w; 
    397381        projPos *= invw; 
    398         float scaleFactor = SAMPLE_RADIUS * invw; 
    399  
    400         const float sqrMoveSpeed = SqrLen(diffVec); 
    401         const bool isMovingObject = (sqrMoveSpeed > DYNAMIC_OBJECTS_THRESHOLD); 
     382        float scaleFactor = kernelRadius * invw; 
    402383 
    403384         
     
    422403        if (eyeSpaceDepth < 1e10f) 
    423404        { 
    424                 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, isMovingObject); 
    425                 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
     405                ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight, sampleIntensity); 
     406                //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals, sampleIntensity); 
    426407        } 
    427408        else 
     
    430411        } 
    431412 
    432         // equals the number of sampled shot in this pass 
    433         const float newWeight = ao.z; 
     413        const float squaredLen = SqrLen(diffVec); 
    434414 
    435415        // check if we have to reset pixel because one of the sample points was invalid 
    436         if (!isMovingObject) 
    437     //if (sqrMoveSpeed <= DYNAMIC_OBJECTS_THRESHOLD) 
     416        if (squaredLen < DYNAMIC_OBJECTS_THRESHOLD) 
    438417        { 
    439418                if (ao.y > 4.0f)  
    440419                        oldWeight = 0;  
    441420                else if (ao.y > 1.0f) 
    442                         oldWeight = min(oldWeight, 4.0f * newWeight); 
    443         } 
    444  
     421                        oldWeight = min(oldWeight, 4.0f * NUM_SAMPLES); 
     422        } 
     423 
     424        const float newWeight = ao.z; 
    445425        const float combinedWeight = clamp(newWeight + oldWeight, .0f, temporalCoherence); 
    446426 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt

    r3203 r3212  
    4545 
    46463) normal mapping 
     47 
     48working but already done! 
    4749 
    4850 
     
    120122   q: is it good to choose new weight as we do? (approx 4 frames) 
    121123   or shouldn't we just completely reset sample? 
     124 
     125 
     126 
     127shading todo: 
     128 
     129bloom 
     130dof 
     131lense flar 
     132god rays 
     133sun disc 
     134environment lighting 
Note: See TracChangeset for help on using the changeset viewer.