Ignore:
Timestamp:
02/10/09 17:43:43 (15 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r3287 r3296  
    395395        sCgGiProgram = sm->CreateFragmentProgram("globillum", "main", "GiFrag"); 
    396396        sCgCombineIllumProgram = sm->CreateFragmentProgram("globillum", "combine", "CombineGi"); 
    397         sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "CombineSsaoHalfRes", "CombineSsao"); 
     397        //sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "CombineSsaoHalfRes", "CombineSsao"); 
     398        sCgCombineSsaoProgram = sm->CreateFragmentProgram("combineSsao", "CombineSsaoFullRes", "CombineSsao"); 
    398399        sCgAntiAliasingProgram = sm->CreateFragmentProgram("antialiasing", "main", "AntiAliasing"); 
    399400        sCgToneProgram = sm->CreateFragmentProgram("tonemap", "ToneMap", "ToneMap"); 
     
    624625} 
    625626 
     627#if 0 
    626628 
    627629void DeferredRenderer::PrepareSsaoFilter() 
     
    647649        } 
    648650} 
     651 
     652#else 
     653 
     654void DeferredRenderer::PrepareSsaoFilter() 
     655{ 
     656        const float filterWidth = 1.0f; 
     657 
     658        PoissonDiscSampleGenerator2D poisson(NUM_SSAO_FILTER_SAMPLES, 1.0f); 
     659        poisson.Generate((float *)ssaoFilterOffsets); 
     660 
     661        const float xoffs = (float)filterWidth / mWidth; 
     662        const float yoffs = (float)filterWidth / mHeight; 
     663 
     664        for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES / 2; ++ i) 
     665        { 
     666                float x = xoffs * (i - NUM_SSAO_FILTER_SAMPLES / 4); 
     667                float y = 0; 
     668 
     669                ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 
     670                 
     671                ssaoFilterOffsets[2 * i + 0] = xoffs; 
     672                ssaoFilterOffsets[2 * i + 1] = yoffs; 
     673        } 
     674 
     675        for (int i = 0; i < NUM_SSAO_FILTER_SAMPLES / 2; ++ i) 
     676        { 
     677                float x = 0; 
     678                float y = yoffs * (i - NUM_SSAO_FILTER_SAMPLES / 4); 
     679 
     680                ssaoFilterWeights[i] = GaussianDistribution(x, y, 1.0f); 
     681                //ssaoFilterWeights[i] = 1.0f; 
     682 
     683                ssaoFilterOffsets[2 * (NUM_SSAO_FILTER_SAMPLES / 2 + i) + 0] *= xoffs; 
     684                ssaoFilterOffsets[2 * (NUM_SSAO_FILTER_SAMPLES / 2 + i) + 1] *= yoffs; 
     685        } 
     686} 
     687 
     688#endif 
    649689 
    650690 
     
    9831023 
    9841024        for (int j = 0; j < 4; ++ j, ++ i) 
     1025        { 
    9851026                sCgCombineSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 
     1027        } 
     1028 
     1029        sCgCombineSsaoProgram->SetValue1f(i ++, mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetWidth()); 
     1030        sCgCombineSsaoProgram->SetValue1f(i ++, mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetHeight()); 
     1031 
     1032        DrawQuad(sCgCombineSsaoProgram); 
     1033         
     1034        PrintGLerror("combine ssao"); 
     1035} 
     1036 
     1037 
     1038void DeferredRenderer::CombineSsao2(FrameBufferObject *fbo) 
     1039{ 
     1040        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     1041        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     1042        GLuint ssaoTex = mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetTexture(); 
     1043         
     1044        FlipFbos(fbo); 
     1045 
     1046        int i = 0; 
     1047 
     1048        sCgCombineSsaoProgram->SetTexture(i ++, colorsTex); 
     1049        sCgCombineSsaoProgram->SetTexture(i ++, normalsTex); 
     1050        sCgCombineSsaoProgram->SetTexture(i ++, ssaoTex); 
     1051 
     1052        sCgCombineSsaoProgram->SetArray2f(i ++, (float *)ssaoFilterOffsets, NUM_SSAO_FILTER_SAMPLES); 
     1053        sCgCombineSsaoProgram->SetArray1f(i ++, (float *)ssaoFilterWeights, NUM_SSAO_FILTER_SAMPLES); 
     1054        sCgCombineSsaoProgram->SetValue1f(i ++, mSsaoFilterRadius); 
     1055 
     1056        sCgCombineSsaoProgram->SetMatrix(i++, mProjViewMatrix); 
     1057 
     1058        for (int j = 0; j < 4; ++ j, ++ i) 
     1059        { 
     1060                sCgCombineSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 
     1061        } 
    9861062 
    9871063        sCgCombineSsaoProgram->SetValue1f(i ++, mIllumFbo->GetColorBuffer(mIllumFboIndex)->GetWidth()); 
Note: See TracChangeset for help on using the changeset viewer.