Changeset 3350 for GTP


Ignore:
Timestamp:
04/14/09 08:59:19 (15 years ago)
Author:
mattausch
Message:

implemented ssao for diffuse illumination

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

Legend:

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

    r3349 r3350  
    447447 
    448448        mTempFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     449        mTempFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    449450        FrameBufferObject::InitBuffer(mTempFbo, 0); 
     451        FrameBufferObject::InitBuffer(mTempFbo, 1); 
    450452         
    451453 
     
    561563        ////////////// 
    562564 
    563         string deferredParams[] = {"colors", "normals", "lightDir"}; 
    564         sCgDeferredProgram->AddParameters(deferredParams, 0, 3); 
     565        string deferredParams[] = {"colors", "normals", "lightDir", "aoTex"}; 
     566        sCgDeferredProgram->AddParameters(deferredParams, 0, 4); 
    565567 
    566568        /////////////////// 
     
    652654        InitFrame(); 
    653655 
    654         if (shadowMap) 
     656        /*if (shadowMap) 
    655657                FirstPassShadow(fbo, light, shadowMap); 
    656658        else 
    657659                FirstPass(fbo, light); 
     660        */ 
    658661 
    659662        if (mShadingMethod != 0) 
     
    681684        } 
    682685 
     686        if (shadowMap) 
     687                FirstPassShadow(fbo, light, shadowMap); 
     688        else 
     689                FirstPass(fbo, light); 
     690 
    683691        /// depth of field 
    684692        if (mUseDepthOfField) 
     
    958966        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    959967        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     968        GLuint aoTex = mTempFbo->GetColorBuffer(1)->GetTexture(); 
    960969 
    961970        FlipFbos(fbo); 
     
    966975        sCgDeferredProgram->SetTexture(1, normalsTex); 
    967976        sCgDeferredProgram->SetValue3f(2, lightDir.x, lightDir.y, lightDir.z); 
    968          
     977        sCgDeferredProgram->SetTexture(3, aoTex); 
     978 
    969979        DrawQuad(sCgDeferredProgram); 
    970980 
     
    10931103        GLuint ssaoTex = mTempFbo->GetColorBuffer(0)->GetTexture(); 
    10941104         
    1095         FlipFbos(fbo); 
     1105        mTempFbo->Bind(); 
     1106        glDrawBuffers(1, mrt + 1); 
     1107        //FlipFbos(fbo); 
    10961108 
    10971109        int i = 0; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3349 r3350  
    2424                         uniform float4 color, 
    2525                         uniform float3 normal, 
    26                          float3 lightDir) 
     26                         float3 lightDir, 
     27                         float4 ao) 
    2728{ 
    2829        // diffuse intensity 
     
    4445        else  
    4546        { 
    46                 outColor = (ambient + diffuse) * color; 
     47                outColor = (ambient * ao + diffuse) * color; 
     48                //outColor = ambient + diffuse * color; 
    4749        } 
    4850 
     
    5759                   uniform sampler2D colors, 
    5860                   uniform sampler2D normals, 
    59                    uniform float3 lightDir 
     61                   uniform float3 lightDir, 
     62                   uniform sampler2D aoTex 
    6063                   ) 
    6164{ 
     
    6467        float4 norm = tex2D(normals, IN.texCoord); 
    6568        float4 color = tex2Dlod(colors, float4(IN.texCoord, 0, 0)); 
     69        float4 ao = tex2Dlod(aoTex, float4(IN.texCoord, 0, 0)); 
    6670         
    6771        float3 normal = normalize(norm.xyz); 
    68         float4 col = shade(IN, color, normal, lightDir); 
     72        float4 col = shade(IN, color, normal, lightDir, ao); 
    6973         
    7074        OUT.color = col; 
    71         // store scaled view vector so wie don't have to normalize for e.g., ssao 
     75        // store scaled view vector so wie don't have to normalize for later 
    7276        //OUT.color.w = color.w / length(IN.view); 
    7377        OUT.color.w = color.w; 
     
    172176 
    173177                float shadowTerm = CalcShadowTerm(IN, shadowMap, sampleWidth,  
    174                                                       lightSpacePos.xy, lightSpacePos.z, samples, weights, noiseTex); 
     178                                                      lightSpacePos.xy, lightSpacePos.z, samples,  
     179                                                                                  weights, noiseTex); 
    175180                diffuse *= shadowTerm; 
    176181        } 
Note: See TracChangeset for help on using the changeset viewer.