Ignore:
Timestamp:
12/07/08 23:26:00 (16 years ago)
Author:
mattausch
Message:

made ssao parameters more flexible
started to implement lense flare

File:
1 edited

Legend:

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

    r3206 r3212  
    7676static float ssaoFilterWeights[NUM_SSAO_FILTER_SAMPLES]; 
    7777 
     78static GLuint sBurstTex; 
     79static GLuint sHaloTex[4]; 
    7880 
    7981int DeferredRenderer::colorBufferIdx = 0; 
     82 
     83 
     84static void PrepareLenseFlare() 
     85{ 
     86        sBurstTex = new Texture("burst.jpg"); 
     87 
     88        Texture(const std::string &filename); 
     89 
     90        glEnable(GL_TEXTURE_2D); 
     91        glGenTextures(1, &sBurstTex); 
     92        glBindTexture(GL_TEXTURE_2D, sBurstTex); 
     93                 
     94        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
     95        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
     96        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); 
     97        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
     98 
     99        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, randomNormals); 
     100 
     101        glBindTexture(GL_TEXTURE_2D, 0); 
     102        glDisable(GL_TEXTURE_2D); 
     103 
     104        delete [] randomNormals; 
     105 
     106        cout << "prepared lense flare textures" << endl; 
     107 
     108        PrintGLerror("prepare lense flare"); 
     109} 
    80110 
    81111 
     
    300330mShadingMethod(DEFAULT), 
    301331mIllumFboIndex(0), 
    302 mSortSamples(true) 
     332mSortSamples(true), 
     333mKernelRadius(1e-8f), 
     334mSampleIntensity(0.2f) 
    303335{ 
    304336        /////////// 
    305337        //-- the flip-flop fbos 
    306338 
    307         const int dsw = w / 2; const int dsh = h / 2; 
    308         //const int dsw = w; const int dsh = h; 
     339        //const int dsw = w / 2; const int dsh = h / 2; 
     340        const int dsw = w; const int dsh = h; 
    309341 
    310342        mIllumFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
     
    321353 
    322354        /////////////// 
    323         //-- the downsampled ssao + color bleeding textures: as GI is mostly low frequency, we can use lower resolution toimprove performance 
     355        //-- the downsampled ssao + color bleeding textures:  
     356        //-- as GI is mostly low frequency, we can use lower resolution toimprove performance 
    324357 
    325358        mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
     
    327360        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    328361        // downsample buffer for the normal texture 
    329         mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
     362        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     363 
    330364 
    331365        for (int i = 0; i < 2; ++ i) 
     
    395429                 "samples", "bl", "br", "tl", "tr",  
    396430                 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr",  
    397                  "oldtl", "oldtr", "attribsTex"}; 
    398         sCgSsaoProgram->AddParameters(ssaoParams, 0, 18); 
     431                 "oldtl", "oldtr", "attribsTex", "kernelRadius", "sampleIntensity"}; 
     432        sCgSsaoProgram->AddParameters(ssaoParams, 0, 20); 
    399433         
    400434        string giParams[] =  
     
    702736 
    703737        for (int j = 0; j < 4; ++ j, ++ i) 
     738        { 
    704739                sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 
     740        } 
    705741 
    706742        sCgSsaoProgram->SetTexture(i ++, attribsTex); 
     743        sCgSsaoProgram->SetValue1f(i ++, mKernelRadius); 
     744        sCgSsaoProgram->SetValue1f(i ++, mSampleIntensity); 
    707745 
    708746 
     
    957995 
    958996 
     997#if TODO 
     998 
     999void DeferredRenderer::SetNumSamples(int numSamples) 
     1000{ 
     1001        mNumSamples = numSamples; 
     1002} 
     1003 
     1004#endif 
     1005 
     1006 
     1007void DeferredRenderer::SetSampleIntensity(float sampleIntensity) 
     1008{ 
     1009        mSampleIntensity = sampleIntensity; 
     1010} 
     1011 
     1012 
     1013void DeferredRenderer::SetKernelRadius(float kernelRadius) 
     1014{ 
     1015        mKernelRadius = kernelRadius; 
     1016} 
     1017 
     1018 
    9591019void DeferredRenderer::ComputeToneParameters(FrameBufferObject *fbo,  
    9601020                                                                                         DirectionalLight *light, 
     
    10581118        mDownSampleFbo->Bind(); 
    10591119 
    1060 // prepare downsampled color and normal texture for ssao 
     1120        // prepare downsampled depth and normal texture for ssao 
    10611121        glDrawBuffers(2, mrt); 
    10621122 
     
    10661126        PrintGLerror("prepareSsao"); 
    10671127} 
    1068  
    10691128 
    10701129 
     
    11971256} 
    11981257 
     1258 
     1259void DeferredRenderer::LenseFlare(FrameBufferObject *fbo) 
     1260{ 
     1261        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     1262 
     1263        FlipFbos(fbo); 
     1264 
     1265        sCgLenseFlareProgram->SetTexture(0, colorsTex); 
     1266        sCgLenseFlareProgram->SetTexture(1, sBurstTex); 
     1267        sCgLenseFlareProgram->SetTexture(2, sHaloTex[0]); 
     1268        sCgLenseFlareProgram->SetTexture(3, sHaloTex[1]); 
     1269        sCgLenseFlareProgram->SetValue1f(4, sHaloTex[2]); 
     1270        sCgLenseFlareProgram->SetValue1f(5, sHaloTex[3]); 
     1271 
     1272        DrawQuad(sCgLenseFlareProgram); 
     1273 
     1274        PrintGLerror("LenseFlare"); 
     1275} 
     1276 
     1277 
    11991278} // namespace 
Note: See TracChangeset for help on using the changeset viewer.