Changeset 3002


Ignore:
Timestamp:
10/03/08 17:16:48 (16 years ago)
Author:
mattausch
Message:

started using downsampling

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
3 edited

Legend:

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

    r3001 r3002  
    3636static CGparameter sColorsTexLogLumParam; 
    3737 
     38static CGparameter sDownSampleOffsetParam; 
    3839 
    3940 
     
    276277        mFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    277278        mFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    278 } 
     279 
     280        mDownSampleFbo = new FrameBufferObject(w / 2, h / 2, FrameBufferObject::DEPTH_NONE); 
     281        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     282        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     283        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     284        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     285} 
     286 
    279287 
    280288 
     
    535543                                                                "src/shaders/tonemap.cg",  
    536544                                                                RenderState::sCgFragmentProfile, 
    537                                                                 "GreyScaleDownSample", 
     545                                                                "DownSample", 
    538546                                                                NULL); 
    539547 
     
    543551 
    544552                // we need size of texture for scaling 
    545                 sColorsTexDownSampleParam = cgGetNamedParameter(sCgDownSampleProgram, "colors");   
     553                sColorsTexDownSampleParam = cgGetNamedParameter(sCgDownSampleProgram, "colors");  
     554                sDownSampleOffsetParam = cgGetNamedParameter(sCgDownSampleProgram, "downSampleOffs"); 
     555                 
     556                float downSampleOffsets[8]; 
     557 
     558                float w = 1028; 
     559                float h = 768; 
     560 
     561                float xoffs = 1 / w; 
     562                float yoffs = 1 / h; 
     563 
     564                downSampleOffsets[0] =  xoffs; downSampleOffsets[1] =  yoffs; 
     565                downSampleOffsets[2] =  xoffs; downSampleOffsets[3] = -yoffs; 
     566                downSampleOffsets[4] = -xoffs; downSampleOffsets[5] = -yoffs; 
     567                downSampleOffsets[6] = -xoffs; downSampleOffsets[7] =  yoffs; 
     568 
     569                cgGLSetParameterArray2f(sDownSampleOffsetParam, 0, 4, (const float *)downSampleOffsets); 
    546570        } 
    547571        else 
     
    602626                break; 
    603627        case GI: 
     628                DownSample(fbo); 
    604629                ComputeGlobIllum(fbo, tempCohFactor, oldProjViewMatrix); 
    605630                CombineIllum(fbo); 
     
    12441269void DeferredRenderer::DownSample(FrameBufferObject *fbo) 
    12451270{ 
     1271        glPushAttrib(GL_VIEWPORT_BIT); 
     1272        glViewport(0, 0, mWidth, mHeight); 
     1273 
    12461274        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
    12471275        GLuint colorsTex = colorBuffer->GetTexture(); 
     
    12771305        FrameBufferObject::Release(); 
    12781306 
    1279         PrintGLerror("ToneMapParams"); 
     1307        glPopAttrib(); 
     1308        PrintGLerror("downsample"); 
    12801309} 
    12811310 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3001 r3002  
    668668        fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST); 
    669669        // the positions buffer 
    670         fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST); 
     670        fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
    671671        //fbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST); 
    672672        // the normals buffer 
    673         fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST); 
     673        fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
    674674        // another color buffer 
    675675        fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST, ColorBufferObject::FILTER_NEAREST); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/tonemap.cg

    r2999 r3002  
    2222float4 DownSample(frag IN, 
    2323                                  uniform sampler2D colors, 
    24                                   float2 downSampleOffs[16]) : COLOR 
     24                                  float2 downSampleOffs[4]) : COLOR 
    2525{     
    2626    float4 average = .0f; 
    2727 
    28     for(int i = 0; i < 16; ++ i) 
     28    for(int i = 0; i < 4; ++ i) 
    2929    { 
    3030        average += tex2D(colors, IN.texCoord + downSampleOffs[i]); 
    3131    } 
    3232         
    33     average *= 1.0f / 16.0f; 
     33    average *= 1.0f / 4.0f; 
    3434 
    3535    return average; 
Note: See TracChangeset for help on using the changeset viewer.