Ignore:
Timestamp:
02/12/09 14:38:14 (15 years ago)
Author:
mattausch
Message:

removed filter radius

File:
1 edited

Legend:

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

    r3301 r3305  
    248248        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
    249249        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
    250  
    251250        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
    252251        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); 
     
    300299mSortSamples(true), 
    301300mKernelRadius(1e-8f), 
    302 mSsaoFilterRadius(12.0f), 
    303301mSampleIntensity(0.2f), 
    304302mSunVisiblePixels(0), 
     
    309307mUseToneMapping(false), 
    310308mUseAntiAliasing(false), 
    311 mUseDepthOfField(false) 
     309mUseDepthOfField(false), 
     310mSsaoUseFullResolution(ssaoUseFullResolution) 
    312311{ 
    313312        /////////// 
     
    316315        int downSampledWidth, downSampledHeight; 
    317316 
    318         if (ssaoUseFullResolution) 
     317        if (mSsaoUseFullResolution) 
    319318        { 
    320319                downSampledWidth = w; downSampledHeight = h; 
     
    327326        } 
    328327 
    329         /////// 
     328 
     329        ///////// 
    330330        //-- the illumination fbo is either half size or full size 
    331331 
    332332        mIllumFbo = new FrameBufferObject(downSampledWidth, downSampledHeight, FrameBufferObject::DEPTH_NONE); 
    333  
    334333        mFBOs.push_back(mIllumFbo); 
    335334 
     
    343342        /////////////// 
    344343        //-- the downsampled ssao + color bleeding textures:  
    345         //-- as GI is mostly low frequency, we can use lower resolution toimprove performance 
     344        //-- as GI is mostly low frequency, we can use lower resolution to improve performance 
    346345 
    347346        mDownSampleFbo = new FrameBufferObject(downSampledWidth, downSampledHeight, FrameBufferObject::DEPTH_NONE); 
     
    358357 
    359358        mFBOs.push_back(mDownSampleFbo); 
     359 
     360 
     361        ///////// 
     362        //-- temporal buffer 
     363 
     364        mTempFbo = new FrameBufferObject(mWidth, mHeight, FrameBufferObject::DEPTH_NONE); 
     365        mFBOs.push_back(mTempFbo); 
     366 
     367        mTempFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     368        FrameBufferObject::InitBuffer(mTempFbo, 0); 
     369         
    360370 
    361371        // create noise texture for ssao 
     
    397407        sCgGiProgram = sm->CreateFragmentProgram("globillum", "main", "GiFrag"); 
    398408        sCgCombineIllumProgram = sm->CreateFragmentProgram("globillum", "combine", "CombineGi"); 
    399         //sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "CombineSsaoHalfRes", "CombineSsao"); 
    400         sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsaoSep", "CombineSsaoFullRes", "CombineSsao"); 
    401         sCgFilterSsaoProgram = sm->CreateFragmentProgram("combineSsaoSep", "FilterSsaoFullRes", "FilterSsao"); 
     409 
     410        if (mSsaoUseFullResolution) 
     411        { 
     412                sCgFilterSsaoProgram = sm->CreateFragmentProgram("combineSsaoSep", "FilterSsaoFullRes", "FilterSsao"); 
     413        } 
     414        else 
     415        { 
     416                sCgFilterSsaoProgram = sm->CreateFragmentProgram("combineSsaoSep", "FilterSsaoHalfRes", "FilterSsao"); 
     417        } 
     418         
     419        sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsaoSep", "CombineSsao", "CombineSsao"); 
    402420        sCgAntiAliasingProgram = sm->CreateFragmentProgram("antialiasing", "main", "AntiAliasing"); 
    403421        sCgToneProgram = sm->CreateFragmentProgram("tonemap", "ToneMap", "ToneMap"); 
     
    446464        //////////////// 
    447465 
    448         /*string combineSsaoParams[] =  
    449                 {"colorsTex", "normalsTex", "ssaoTex", "filterOffs", "filterWeights",  
    450                 "ssaoFilterRadius", "modelViewProj", "bl", "br", "tl",  
    451                 "tr", "w", "h"}; 
    452         */ 
    453466        string combineSsaoParams[] =  
    454                 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "xyStep"}; 
     467        {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res"}; 
    455468 
    456469        //sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13); 
     
    461474 
    462475        string filterSsaoParams[] =  
    463                 {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "xyStep"}; 
     476                {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "res"}; 
    464477 
    465478        sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 7); 
     
    515528 
    516529        sCgDOFProgram->AddParameters(dofParams, 0, 4); 
    517  
    518  
    519         //////////////// 
    520         //-- prepare filter for ssao 
    521  
    522         PrepareSsaoFilter(); 
    523530 
    524531 
     
    642649} 
    643650 
    644 #if 0 
    645  
    646 void DeferredRenderer::PrepareSsaoFilter() 
    647 { 
    648         const float filterWidth = 1.0f; 
    649  
    650         PoissonDiscSampleGenerator2D poisson(NUM_SSAO_FILTER_SAMPLES, 1.0f); 
    651         poisson.Generate((float *)ssaoFilterOffsets); 
    652  
    653         const float xoffs = (float)filterWidth / mWidth; 
    654         const float yoffs = (float)filterWidth / mHeight; 
    655  
    656         for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i) 
    657         { 
    658                 float x = ssaoFilterOffsets[2 * i + 0]; 
    659                 float y = ssaoFilterOffsets[2 * i + 1]; 
    660  
    661                 ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 
    662                 //ssaoFilterWeights[i] = 1.0f; 
    663  
    664                 ssaoFilterOffsets[2 * i + 0] *= xoffs; 
    665                 ssaoFilterOffsets[2 * i + 1] *= yoffs; 
    666         } 
    667 } 
    668  
    669 #else 
    670  
    671 /** star filter 
    672 */ 
    673 void DeferredRenderer::PrepareSsaoFilter() 
    674 { 
    675         const float filterWidth = 1.0f; 
    676  
    677         PoissonDiscSampleGenerator2D poisson(NUM_SSAO_FILTER_SAMPLES, 1.0f); 
    678         poisson.Generate((float *)ssaoFilterOffsets); 
    679  
    680         const float xoffs = (float)filterWidth / mWidth; 
    681         const float yoffs = (float)filterWidth / mHeight; 
    682  
    683         const int n = NUM_SSAO_FILTER_SAMPLES / 2 + 1; 
    684  
    685         for (int i = 0; i < n; ++ i) 
    686         { 
    687                 const int idx = i - NUM_SSAO_FILTER_SAMPLES / 4; 
    688  
    689                 const float x = xoffs * (float)idx; 
    690                 const float y = 0; 
    691  
    692                 ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 
    693                  
    694                 ssaoFilterOffsets[2 * i + 0] = x; 
    695                 ssaoFilterOffsets[2 * i + 1] = y; 
    696         } 
    697  
    698         int j = 2 * n; 
    699  
    700         for (int i = 0; i < n; ++ i) 
    701         {  
    702                 const int idx = i - NUM_SSAO_FILTER_SAMPLES / 4; 
    703  
    704                 if (idx) 
    705                 { 
    706                         const float x = 0; 
    707                         const float y = yoffs * (float)idx; 
    708  
    709                         ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 
    710                         //ssaoFilterWeights[i] = 1.0f; 
    711                          
    712                         ssaoFilterOffsets[j + 0] = x; 
    713                         ssaoFilterOffsets[j + 1] = y; 
    714  
    715                         j += 2; 
    716                 } 
    717         } 
    718  
    719         for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES; ++ i) 
    720         { 
    721                 cout << "samples " << i << ": " << ssaoFilterOffsets[i * 2] << " " << ssaoFilterOffsets[i * 2 + 1] << endl; 
    722         } 
    723 } 
    724  
    725 #endif 
    726  
    727651 
    728652static inline float SqrMag(const Sample2 &s) 
     
    1045969        GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetTexture(); 
    1046970         
    1047         mIllumFbo->Bind(); 
    1048         glDrawBuffers(1, mrt + mIllumFboIndex + 1); 
    1049          
    1050  
     971        //mIllumFbo->Bind(); 
     972        //glDrawBuffers(1, mrt + mIllumFboIndex + 1); 
     973        mTempFbo->Bind(); 
     974        glDrawBuffers(1, mrt); 
     975         
    1051976        int i = 0; 
    1052977 
     
    1059984        } 
    1060985 
    1061         sCgFilterSsaoProgram->SetValue2f(i ++, 1.0f / (float)mWidth, 0); 
     986        sCgFilterSsaoProgram->SetValue2f(i ++, (float)mWidth, (float)mHeight); 
    1062987 
    1063988        DrawQuad(sCgFilterSsaoProgram); 
    1064          
    1065989        PrintGLerror("combine ssao"); 
    1066990} 
     
    1071995        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    1072996        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    1073         GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex + 1)->GetTexture(); 
     997        //GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex + 1)->GetTexture(); 
     998        GLuint ssaoTex = mTempFbo->GetColorBuffer(0)->GetTexture(); 
    1074999         
    10751000        FlipFbos(fbo); 
     
    10801005        sCgCombineSsaoProgram->SetTexture(i ++, ssaoTex); 
    10811006 
    1082         //sCgCombineSsaoProgram->SetArray2f(i ++, (float *)ssaoFilterOffsets, NUM_SSAO_FILTER_SAMPLES); 
    1083         //sCgCombineSsaoProgram->SetArray1f(i ++, (float *)ssaoFilterWeights, NUM_SSAO_FILTER_SAMPLES); 
    1084         //sCgCombineSsaoProgram->SetValue1f(i ++, mSsaoFilterRadius); 
    1085         //sCgCombineSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 
    1086  
    10871007        for (int j = 0; j < 4; ++ j, ++ i) 
    10881008        { 
     
    10901010        } 
    10911011 
    1092         //float xOffs, yOffs; 
    1093  
    1094         //sCgCombineSsaoProgram->SetValue2f(i ++, 1.0f / (float)mWidth, 1.0f / (float)mHeight); 
    1095         sCgCombineSsaoProgram->SetValue2f(i ++, 0, 1.0f / (float)mHeight); 
     1012        sCgCombineSsaoProgram->SetValue2f(i ++, mWidth, mHeight); 
    10961013 
    10971014        DrawQuad(sCgCombineSsaoProgram); 
     
    15451462 
    15461463 
    1547 void DeferredRenderer::SetSsaoFilterRadius(float ssaoFilterRadius) 
    1548 { 
    1549         mSsaoFilterRadius = ssaoFilterRadius; 
    1550         mRegenerateSamples = true; 
    1551 } 
    1552  
    1553  
    15541464/*void DeferredRenderer::SetSortSamples(bool sortSamples)  
    15551465{ 
Note: See TracChangeset for help on using the changeset viewer.