Changeset 3232


Ignore:
Timestamp:
12/23/08 17:39:27 (15 years ago)
Author:
mattausch
Message:

started dof implementation (not working yet!)

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

Legend:

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

    r3230 r3232  
    776776                        </File> 
    777777                        <File 
     778                                RelativePath=".\src\shaders\depthOfField.cg" 
     779                                > 
     780                        </File> 
     781                        <File 
    778782                                RelativePath=".\src\shaders\globillum.cg" 
    779783                                > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3231 r3232  
    6565static ShaderProgram *sCgLenseFlareProgram = NULL; 
    6666 
     67static ShaderProgram *sCgDOFProgram = NULL; 
     68 
    6769 
    6870static GLuint noiseTex2D = 0; 
     
    7476#define NUM_PRECOMPUTED_SAMPLES 240 
    7577static Sample2 samples2[NUM_PRECOMPUTED_SAMPLES]; 
    76 // number of pcf tabs 
     78// pcf samples 
    7779static Sample2 pcfSamples[NUM_PCF_TABS]; 
     80// dof samples 
     81static Sample2 dofSamples[NUM_DOF_TABS]; 
    7882 
    7983 
     
    392396        sCgPrepareSsaoProgram = sm->CreateFragmentProgram("deferred", "PrepareSsao", "PrepareSsao"); 
    393397        sCgLenseFlareProgram = sm->CreateFragmentProgram("lenseFlare", "LenseFlare", "LenseFlare"); 
     398        sCgDOFProgram = sm->CreateFragmentProgram("depthOfField", "DepthOfField", "DepthOfField"); 
    394399 
    395400 
     
    408413                 "temporalCoherence", "samples", "bl", "br", "tl",  
    409414                 "tr", "oldModelViewProj", "modelViewProj"}; 
     415 
    410416        sCgGiProgram->AddParameters(giParams, 0, 13); 
    411417 
     
    433439                "ssaoFilterRadius", "modelViewProj", "bl", "br", "tl",  
    434440                "tr", "w", "h"}; 
     441 
    435442        sCgCombineSsaoProgram->AddParameters(combineSsaoParams, 0, 13); 
    436443 
     
    471478 
    472479        //////////////// 
    473  
    474480         
    475481        string lenseFlareParams[] =  
     
    479485        sCgLenseFlareProgram->AddParameters(lenseFlareParams, 0, 9); 
    480486 
    481  
     487         
    482488        //////////////// 
    483         //-- prepare filters for ssao 
     489         
     490        string dofParams[] = {"colorsTex", "filterOffs", "sceneRange"}; 
     491 
     492        sCgDOFProgram->AddParameters(dofParams, 0, 3); 
     493 
     494 
     495        //////////////// 
     496        //-- prepare filter for ssao 
    484497 
    485498        PrepareSsaoFilter(); 
     
    500513        sCgDeferredShadowProgram->SetArray2f(8, (float *)pcfSamples, NUM_PCF_TABS); 
    501514        sCgDeferredShadowProgram->SetArray1f(9, (float *)filterWeights, NUM_PCF_TABS); 
     515 
     516 
     517        ///////// 
     518        //-- pcf tabs for depth of field 
     519 
     520        // todo matt: it is stupid to put num samples and width of kernel into constructor => change this!!! 
     521        PoissonDiscSampleGenerator2D poisson3(NUM_DOF_TABS, 1.0f); 
     522        poisson2.Generate((float *)dofSamples); 
     523 
     524        //float dofWeights[NUM_PCF_TABS]; 
     525        //sCgDOFProgram->SetArray1f(2, (float *)dofWeights, NUM_DOF_TABS); 
    502526 
    503527        PrintGLerror("init"); 
     
    551575        } 
    552576 
     577 
     578        /// do depth of field 
     579        DepthOfField(fbo); 
     580 
    553581        /// compute lense flare 
    554582        LenseFlare(fbo, light); 
     
    12771305 
    12781306 
     1307void DeferredRenderer::DepthOfField(FrameBufferObject *fbo) 
     1308{ 
     1309        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     1310        GLuint colorsTex = colorBuffer->GetTexture(); 
     1311         
     1312        FlipFbos(fbo); 
     1313 
     1314        float sceneRange = 1.0f; 
     1315 
     1316        int i = 0; 
     1317 
     1318        sCgDOFProgram->SetTexture(i ++, colorsTex); 
     1319        sCgDOFProgram->SetArray2f(i ++, (float *)dofSamples, NUM_DOF_TABS); 
     1320        sCgDOFProgram->SetValue1f(i ++, sceneRange); 
     1321 
     1322        DrawQuad(sCgDOFProgram); 
     1323 
     1324        PrintGLerror("LenseFlare"); 
     1325} 
     1326 
     1327 
    12791328void DeferredRenderer::SaveFrame(FrameBufferObject *fbo) 
    12801329{ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3220 r3232  
    155155        void SaveFrame(FrameBufferObject *fbo); 
    156156 
     157        void DepthOfField(FrameBufferObject *fbo); 
     158 
    157159 
    158160        //////////// 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SampleGenerator.cpp

    r3230 r3232  
    189189#else 
    190190 
    191         //static PoissonDiscSampleGenerator2D poisson(mNumSamples, 1.0f); 
    192         //poisson.Generate(samples); 
    193  
    194191        PoissonDiscSampleGenerator2D::Generate(samples); 
    195192 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3230 r3232  
    66//-- ssao + gi parameters 
    77 
    8 //#define NUM_SAMPLES 8 
     8#define NUM_SAMPLES 8 
    99//#define NUM_SAMPLES 16 
    1010//#define NUM_SAMPLES 24 
    11 #define NUM_SAMPLES 48 
     11//#define NUM_SAMPLES 48 
    1212 
    1313#define MIN_SAMPLES 8 
     
    6060#define NUM_DOWNSAMPLES 9 
    6161 
     62#define NUM_DOF_TABS 16 
    6263 
    6364 
     65//#define USE_GTX 
     66 
    6467#endif // __SHADERENV_H 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/combineSsao.cg

    r3226 r3232  
    115115        float4 ao =  tex2Dlod(ssaoTex, float4(IN.texCoord, 0, 0)); 
    116116 
     117#if 0 // use half size 
     118 
    117119        // the following has to be done for half resolution ssao: 
    118120        // get the minimum convergence by exactly sampling the 4 surrounding 
     
    124126 
    125127        // get position exactly between old texel centers 
    126         /*float2 center; 
     128        float2 center; 
    127129        center.x = (floor(IN.texCoord.x * w - .5f) + 1.0f) / w; 
    128130        center.y = (floor(IN.texCoord.y * h - .5f) + 1.0f) / h; 
     
    137139 
    138140        const float minConvergence = min(m1, m2); 
    139         const float convergence = minConvergence;*/ 
    140         //const float convergence = 0; 
     141        const float convergence = minConvergence; 
     142 
     143#else 
     144         
     145        // just take unfiltered convergence in current pixel 
    141146        const float convergence = ao.y; 
    142147 
     148#endif 
     149         
    143150        // filter reaches size 1 pixel when sample size reaches threshold  
    144151        // afterwards we do not use the filter anymore 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/common.h

    r3230 r3232  
    4747 
    4848 
    49  
    50  
    5149inline float2 myrotate(float2 pt, float angle) 
    5250{ 
     
    6058} 
    6159 
    62  
    63 #define USE_GTX 
Note: See TracChangeset for help on using the changeset viewer.