Changeset 3296 for GTP


Ignore:
Timestamp:
02/10/09 17:43:43 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
6 edited

Legend:

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

    r3284 r3296  
    824824                        </File> 
    825825                        <File 
     826                                RelativePath=".\src\shaders\combineSsaoSep.cg" 
     827                                > 
     828                        </File> 
     829                        <File 
    826830                                RelativePath=".\src\shaders\common.h" 
    827831                                > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/sibenik.env

    r3295 r3296  
    6262## window options 
    6363 
    64 winWidth=800 
    65 winHeight=600 
     64#winWidth=800 
     65#winHeight=600 
    6666 
    67 #winWidth=1024 
    68 #winHeight=768 
     67winWidth=1024 
     68winHeight=768 
    6969 
    7070useFullScreen=0 
     
    113113defaultAmbient=0.4 0.4 0.4 
    114114defaultDiffuse=1.4 1.4 1.4 
    115  
    116 fix normals: read bavoil!! 
  • 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()); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3242 r3296  
    168168        void DepthOfField(FrameBufferObject *fbo); 
    169169 
     170        void CombineSsao2(FrameBufferObject *fbo); 
    170171 
    171172 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3285 r3296  
    115115        float4 ao =  tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    116116 
    117 #if 0 // for half resolution 
    118  
    119117        // the following has to be done for half resolution ssao: 
    120118        // get the minimum convergence by exactly sampling the 4 surrounding 
     
    141139        const float convergence = minConvergence; 
    142140 
    143 #else 
    144          
    145         // just take unfiltered convergence in current pixel 
    146         const float convergence = ao.y; 
    147  
    148 #endif 
    149141         
    150142        // filter reaches size 1 pixel when sample size reaches threshold  
     
    188180        return OUT; 
    189181} 
     182 
     183 
     184/** Function combining image and indirect illumination buffer using a  
     185        depth and normal aware discontinuity filter. We assume that  
     186        we are using half resolution ssao for this version of the combineSsao 
     187*/ 
     188pixel CombineSsaoFullRes(fragment IN,  
     189                                                 uniform sampler2D colorsTex, 
     190                                                 uniform sampler2D ssaoTex, 
     191                                                 uniform sampler2D normalsTex, 
     192                                                 uniform float2 filterOffs[NUM_SSAO_FILTER_SAMPLES], 
     193                                                 uniform float filterWeights[NUM_SSAO_FILTER_SAMPLES], 
     194                                                 uniform float ssaoFilterRadius, 
     195                                                 uniform float4x4 modelViewProj, 
     196                                                 uniform float3 bl, 
     197                                                 uniform float3 br, 
     198                                                 uniform float3 tl, 
     199                                                 uniform float3 tr, 
     200                                                 uniform float w, 
     201                                                 uniform float h 
     202                                                 ) 
     203{ 
     204        pixel OUT; 
     205 
     206        float4 col = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)); 
     207        float4 ao =  tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
     208 
     209        // just take unfiltered convergence in current pixel 
     210        const float convergence = ao.y; 
     211         
     212        // filter reaches size 1 pixel when sample size reaches threshold  
     213        // afterwards we do not use the filter anymore 
     214 
     215        // filter up to a certain convergance value and leave out background (sky) by checking depth 
     216        if ((convergence < SSAO_CONVERGENCE_THRESHOLD) && (col.w < 1e10f)) 
     217        { 
     218                const float distanceScale = 1.0f; 
     219 
     220                // descend to zero filter size after reaching thres pixels 
     221                const float convergenceWeight = SSAO_CONVERGENCE_THRESHOLD / (ssaoFilterRadius - 1.0f); 
     222                const float convergenceScale = convergenceWeight / (convergence + convergenceWeight); 
     223                const float scale = ssaoFilterRadius * convergenceScale * distanceScale; 
     224 
     225                // the filtered ssao value 
     226                ao.x = DiscontinuityFilter(IN.texCoord, ao, col, ssaoTex, normalsTex, colorsTex, filterOffs, scale, bl, br, tl, tr); 
     227        } 
     228 
     229        // just apply ssao if we are not in the sky 
     230        if (col.w < 1e10f) 
     231                OUT.illum_col.xyz = col.xyz * max(2e-2f, 1.0f - ao.x); 
     232                //OUT.illum_col.xyz = col.xyz * ao.x; 
     233        else 
     234                OUT.illum_col.xyz = col.xyz; 
     235 
     236        OUT.illum_col.w = col.w; 
     237 
     238        return OUT; 
     239} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/toto.txt

    r3295 r3296  
    203203 
    204204sibenik: textures dissappear!! 
     205 
     206optimize!! 
     207full resolution, sky test (stencil??), shadows 
     208smaller textures?? 
     209test normal ssao with simpler shader! 
     210 
     211fix normals!! 
Note: See TracChangeset for help on using the changeset viewer.