Ignore:
Timestamp:
02/11/09 17:40:23 (15 years ago)
Author:
mattausch
Message:

working on separable filter but not working yet

File:
1 edited

Legend:

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

    r3300 r3301  
    5757 
    5858static ShaderProgram *sCgCombineSsaoProgram = NULL; 
     59static ShaderProgram *sCgFilterSsaoProgram = NULL; 
    5960static ShaderProgram *sCgCombineIllumProgram = NULL; 
    6061static ShaderProgram *sCgLogLumProgram = NULL; 
     
    326327        } 
    327328 
     329        /////// 
     330        //-- the illumination fbo is either half size or full size 
     331 
    328332        mIllumFbo = new FrameBufferObject(downSampledWidth, downSampledHeight, FrameBufferObject::DEPTH_NONE); 
    329         //mIllumFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
    330333 
    331334        mFBOs.push_back(mIllumFbo); 
     
    359362        // for performance reasons we use a smaller texture and repeat it over the screen 
    360363        CreateNoiseTex2D(mIllumFbo->GetWidth() / 4, mIllumFbo->GetWidth() / 4); 
    361         //CreateNoiseTex2D(mIllumFbo->GetWidth(), mIllumFbo->GetWidth()); 
    362          
     364                 
    363365        mProjViewMatrix = IdentityMatrix(); 
    364366        mOldProjViewMatrix = IdentityMatrix(); 
     
    397399        //sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "CombineSsaoHalfRes", "CombineSsao"); 
    398400        sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsaoSep", "CombineSsaoFullRes", "CombineSsao"); 
     401        sCgFilterSsaoProgram = sm->CreateFragmentProgram("combineSsaoSep", "FilterSsaoFullRes", "FilterSsao"); 
    399402        sCgAntiAliasingProgram = sm->CreateFragmentProgram("antialiasing", "main", "AntiAliasing"); 
    400403        sCgToneProgram = sm->CreateFragmentProgram("tonemap", "ToneMap", "ToneMap"); 
     
    454457        sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 7); 
    455458 
     459         
     460        //////////////// 
     461 
     462        string filterSsaoParams[] =  
     463                {"colorsTex", "ssaoTex", "bl", "br", "tl", "tr", "xyStep"}; 
     464 
     465        sCgFilterSsaoProgram->AddParameters(filterSsaoParams, 0, 7); 
     466 
    456467 
    457468        ////////////// 
     
    572583        case SSAO: 
    573584                ComputeSsao(fbo, mTempCohFactor); 
     585                FilterSsao(fbo); 
    574586                CombineSsao(fbo); 
    575587                break; 
     
    10271039 
    10281040 
    1029 void DeferredRenderer::CombineSsao(FrameBufferObject *fbo) 
     1041void DeferredRenderer::FilterSsao(FrameBufferObject *fbo) 
    10301042{ 
    10311043        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    10321044        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    10331045        GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetTexture(); 
     1046         
     1047        mIllumFbo->Bind(); 
     1048        glDrawBuffers(1, mrt + mIllumFboIndex + 1); 
     1049         
     1050 
     1051        int i = 0; 
     1052 
     1053        sCgFilterSsaoProgram->SetTexture(i ++, colorsTex); 
     1054        sCgFilterSsaoProgram->SetTexture(i ++, ssaoTex); 
     1055 
     1056        for (int j = 0; j < 4; ++ j, ++ i) 
     1057        { 
     1058                sCgFilterSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 
     1059        } 
     1060 
     1061        sCgFilterSsaoProgram->SetValue2f(i ++, 1.0f / (float)mWidth, 0); 
     1062 
     1063        DrawQuad(sCgFilterSsaoProgram); 
     1064         
     1065        PrintGLerror("combine ssao"); 
     1066} 
     1067 
     1068 
     1069void DeferredRenderer::CombineSsao(FrameBufferObject *fbo) 
     1070{ 
     1071        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     1072        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     1073        GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex + 1)->GetTexture(); 
    10341074         
    10351075        FlipFbos(fbo); 
     
    10531093 
    10541094        //sCgCombineSsaoProgram->SetValue2f(i ++, 1.0f / (float)mWidth, 1.0f / (float)mHeight); 
    1055         sCgCombineSsaoProgram->SetValue2f(i ++, 1.0f / (float)mWidth, 0); 
    1056  
    1057         DrawQuad(sCgCombineSsaoProgram); 
    1058          
    1059         PrintGLerror("combine ssao"); 
    1060 } 
    1061  
    1062  
    1063 void DeferredRenderer::CombineSsao2(FrameBufferObject *fbo) 
    1064 { 
    1065         GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    1066         GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    1067         GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetTexture(); 
    1068          
    1069         FlipFbos(fbo); 
    1070  
    1071         int i = 0; 
    1072  
    1073         sCgCombineSsaoProgram->SetTexture(i ++, colorsTex); 
    1074         sCgCombineSsaoProgram->SetTexture(i ++, normalsTex); 
    1075         sCgCombineSsaoProgram->SetTexture(i ++, ssaoTex); 
    1076  
    1077         sCgCombineSsaoProgram->SetArray2f(i ++, (float *)ssaoFilterOffsets, NUM_SSAO_FILTER_SAMPLES); 
    1078         sCgCombineSsaoProgram->SetArray1f(i ++, (float *)ssaoFilterWeights, NUM_SSAO_FILTER_SAMPLES); 
    1079         sCgCombineSsaoProgram->SetValue1f(i ++, mSsaoFilterRadius); 
    1080  
    1081         sCgCombineSsaoProgram->SetMatrix(i++, mProjViewMatrix); 
    1082  
    1083         for (int j = 0; j < 4; ++ j, ++ i) 
    1084         { 
    1085                 sCgCombineSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 
    1086         } 
    1087  
    1088         sCgCombineSsaoProgram->SetValue1f(i ++, mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetWidth()); 
    1089         sCgCombineSsaoProgram->SetValue1f(i ++, mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetHeight()); 
     1095        sCgCombineSsaoProgram->SetValue2f(i ++, 0, 1.0f / (float)mHeight); 
    10901096 
    10911097        DrawQuad(sCgCombineSsaoProgram); 
Note: See TracChangeset for help on using the changeset viewer.