Changeset 3199


Ignore:
Timestamp:
11/30/08 21:01:32 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
4 edited

Legend:

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

    r3198 r3199  
    326326        mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
    327327        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    328  
    329         FrameBufferObject::InitBuffer(mDownSampleFbo, 0); 
     328// downsample buffer for the normal texture 
     329mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
     330 
     331        for (int i = 0; i < 2; ++ i) 
     332        { 
     333                FrameBufferObject::InitBuffer(mDownSampleFbo, i); 
     334        } 
    330335 
    331336        mFBOs.push_back(mDownSampleFbo); 
     
    459464         
    460465        string prepareSsaoParams[] =  
    461                 {"colorsTex", "diffVals", "oldTex",  
     466                {"colorsTex", "normalsTex", "diffVals", "oldTex",  
    462467                 "oldEyePos", "modelViewProj", "oldModelViewProj", 
    463468                 "oldbl", "oldbr", "oldtl", "oldtr"}; 
    464469 
    465         sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 10); 
     470        sCgPrepareSsaoProgram->AddParameters(prepareSsaoParams, 0, 11); 
    466471 
    467472 
     
    640645 
    641646 
    642 void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo,  
    643                                                                    float tempCohFactor) 
     647void DeferredRenderer::ComputeSsao(FrameBufferObject *fbo, float tempCohFactor) 
    644648{ 
    645649        GLuint colorsTex, normalsTex, attribsTex; 
    646650 
    647651        if (0) 
     652        { 
    648653                colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     654                normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     655        } 
    649656        else 
     657        { 
     658                normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 
    650659                colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 
    651          
    652         normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     660        } 
     661 
    653662        attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    654663 
     
    10241033{ 
    10251034        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     1035        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    10261036        GLuint diffVals = fbo->GetColorBuffer(2)->GetTexture(); 
    10271037        // flip flop between illumination buffers 
     
    10311041 
    10321042        sCgPrepareSsaoProgram->SetTexture(i ++, colorsTex); 
     1043        sCgPrepareSsaoProgram->SetTexture(i ++, normalsTex); 
    10331044        sCgPrepareSsaoProgram->SetTexture(i ++, diffVals); 
    10341045        sCgPrepareSsaoProgram->SetTexture(i ++, oldTex); 
     
    10521063        mDownSampleFbo->Bind(); 
    10531064 
    1054         glDrawBuffers(1, mrt); 
     1065// prepare downsampled color and normal texture for ssao 
     1066        glDrawBuffers(2, mrt); 
    10551067 
    10561068        DrawQuad(sCgPrepareSsaoProgram); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaderenv.h

    r3198 r3199  
    66//-- ssao + gi parameters 
    77 
    8 #define NUM_SAMPLES 8 
    9 //#define NUM_SAMPLES 16 
     8//#define NUM_SAMPLES 8 
     9#define NUM_SAMPLES 16 
    1010//#define NUM_SAMPLES 24 
    1111 
    12 #define SAMPLE_INTENSITY 0.5f 
    13 //#define SAMPLE_INTENSITY 1.0f 
     12//#define SAMPLE_INTENSITY 0.5f 
     13#define SAMPLE_INTENSITY 1.0f 
    1414 
    1515#define SAMPLE_RADIUS 8e-1f 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3198 r3199  
    280280 
    281281 
    282 float4 PrepareSsao(fragment IN, 
     282pixel PrepareSsao(fragment IN, 
    283283                                   uniform sampler2D colorsTex, 
     284                                   uniform sampler2D normalsTex, 
    284285                                   uniform sampler2D diffVals, 
    285286                                   uniform sampler2D oldTex, 
     
    291292                                   uniform float3 oldtr, 
    292293                                   uniform float3 oldEyePos 
    293                                    ): COLOR0 
     294                                   ) 
    294295{    
     296        pixel pix; 
    295297        float4 color = tex2Dlod(colorsTex, float4(IN.texCoord, 0, 0)); 
    296298        // store scaled view vector so wie don't have to normalize for e.g., ssao 
     
    298300 
    299301        const float4 difVec = tex2Dlod(diffVals, float4(IN.texCoord, 0, 0)); 
     302        const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0, 0)).xyz); 
    300303 
    301304        // do reprojection and filter out the pixels that are not save 
     
    311314                                                          ); 
    312315 
    313         color.x = pValid; 
    314  
    315         return color; 
     316        pix.color = color; 
     317        pix.color.x = pValid; 
     318        pix.normal = normal; 
     319 
     320        return pix; 
    316321} 
    317322 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3198 r3199  
    205205 
    206206                float3 dirSample = samplePos - centerPosition; 
    207                 const float lengthToSample = max(length(dirSample), 1e-6f); 
     207 
     208                const float sqrLen = max(SqrLen(dirSample), 1e-2f); 
     209                const float lengthToSample = sqrt(sqrLen); 
     210                //const float lengthToSample = max(length(dirSample), 1e-6f); 
    208211 
    209212                dirSample /= lengthToSample; // normalize 
     
    216219                // the distance_scale offset is used to avoid singularity that occurs at global illumination when  
    217220                // the distance to a sample approaches zero 
    218                 const float aoContrib = SAMPLE_INTENSITY / (DISTANCE_SCALE + lengthToSample * lengthToSample); 
     221                //const float aoContrib = SAMPLE_INTENSITY / (DISTANCE_SCALE + lengthToSample * lengthToSample); 
     222                const float aoContrib = SAMPLE_INTENSITY / sqrLen; 
    219223                //const float aoContrib = (1.0f > lengthToSample) ? occlusionPower(9e-2f, DISTANCE_SCALE + lengthToSample): .0f; 
    220224 
     
    397401        if (eyeSpaceDepth < 1e10f) 
    398402        { 
    399                 ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight); 
    400                 //ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
     403                //ao = ssao(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), oldWeight); 
     404                ao = ssao2(IN, colors, noiseTex, samples, normal, eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir), normals); 
    401405        } 
    402406        else 
Note: See TracChangeset for help on using the changeset viewer.