Changeset 3375 for GTP


Ignore:
Timestamp:
07/09/09 10:21:25 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
6 edited

Legend:

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

    r3372 r3375  
    3131# renderMode: Frustum Culling, Stop And Wait, CHC, CHC ++ 
    3232renderMode=0 
     33 
    3334 
    3435############ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3372 r3375  
    537537        string deferredShadowParams[] =  
    538538                {"colors", "normals", "shadowMap", "noiseTex", "shadowMatrix",  
    539                  "sampleWidth", "lightDir", "eyePos", "samples", "weights"}; 
    540          
    541         sCgDeferredShadowProgram->AddParameters(deferredShadowParams, 0, 10); 
     539                 "sampleWidth", "lightDir", "eyePos", "samples", "weights", 
     540             "aoTex", "useAO"}; 
     541         
     542        sCgDeferredShadowProgram->AddParameters(deferredShadowParams, 0, 12); 
    542543         
    543544        //////////////// 
     
    630631        //-- pcf tabs for depth of field 
    631632 
    632         // todo matt: it is stupid to put num samples and width of kernel into constructor => change this!!! 
     633        // todo matt: bad style to put #samples and width of kernel into constructor => change this!!! 
    633634        PoissonDiscSampleGenerator2D poisson3(NUM_DOF_TABS, 1.0f); 
    634635        poisson3.Generate((float *)dofSamples); 
     
    639640                dofSamples[i].y *= 1.0f / mHeight; 
    640641        } 
    641  
    642         //float dofWeights[NUM_PCF_TABS]; 
    643         //sCgDOFProgram->SetArray1f(2, (float *)dofWeights, NUM_DOF_TABS); 
    644642 
    645643        PrintGLerror("init"); 
     
    11481146        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    11491147        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     1148        GLuint aoTex = mTempFbo->GetColorBuffer(1)->GetTexture(); 
    11501149 
    11511150        GLuint shadowTex = shadowMap->GetDepthTexture(); 
     
    11671166        sCgDeferredShadowProgram->SetValue3f(6, lightDir.x, lightDir.y, lightDir.z); 
    11681167        sCgDeferredShadowProgram->SetValue3f(7, mEyePos.x, mEyePos.y, mEyePos.z); 
     1168 
     1169        sCgDeferredShadowProgram->SetTexture(10, aoTex); 
     1170        sCgDeferredShadowProgram->SetValue1f(11, float(mShadingMethod == SSAO)); 
    11691171 
    11701172        DrawQuad(sCgDeferredShadowProgram); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Geometry.cpp

    r3294 r3375  
    3939/* 
    4040        mIndices = new unsigned int[mNumVertices]; 
    41  
    42         for (int i = 0; i < mNumVertices; ++ i) 
    43         { 
    44                 mIndices[i] = i; 
    45         }*/ 
     41        for (int i = 0; i < mNumVertices; ++ i) { mIndices[i] = i; } 
     42*/ 
    4643 
    4744        // prepare vbos 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r3372 r3375  
    3939        float4 outColor; 
    4040 
    41 #if 0 
     41#if 1 
    4242        // hack: prevent to shade the sky 
    4343        if (color.w > DEPTH_THRESHOLD) 
     
    4747        else  
    4848        { 
    49                 if (useAO > .5f) 
    50                         outColor = (ambient * ao + diffuse) * color; 
    51                 else 
    52                         outColor = (ambient + diffuse) * color; 
     49                outColor = (useAO > .5f) ? (ambient * ao + diffuse) * color : (ambient + diffuse) * color; 
    5350        } 
    5451#else 
     52        // just output ambient occlusion 
    5553        outColor = ao; 
    5654#endif 
     
    8179         
    8280        OUT.color = col; 
     81 
    8382        // store scaled view vector so wie don't have to normalize for later 
    84         //OUT.color.w = color.w / length(IN.view); 
     83        if (0) OUT.color.w = color.w / length(IN.view); 
     84 
    8585        OUT.color.w = color.w; 
    8686 
     
    150150                                  uniform float3 br, 
    151151                                  uniform float3 tl, 
    152                                   uniform float3 tr 
     152                                  uniform float3 tr, 
     153                                  uniform sampler2D aoTex, 
     154                                  uniform float useAO 
    153155                                  ) 
    154156{ 
    155157        pixel OUT; 
     158 
     159        float4 ao = 1;//(useAO > .5f) ? tex2Dlod(aoTex, float4(IN.texCoord, 0, 0)) : 1.0f; 
    156160 
    157161        const float3 normal = tex2D(normals, IN.texCoord.xy); 
     
    192196        const float4 ambient = glstate.light[0].ambient; 
    193197        // compute shading 
    194         OUT.color = useShading ? (ambient + diffuse) * color : color; 
     198        OUT.color = useShading ? (ambient * ao + diffuse) * color : color * ao; 
     199         
    195200        // store scaled view vector from now on so wie don't have to normalize later (e.g., for ssao) 
    196         //OUT.color.w = color.w / lenView; 
     201        if (0) OUT.color.w = color.w / lenView; 
     202 
    197203        OUT.color.w = color.w; 
    198204 
     
    216222        return color; 
    217223} 
    218  
    219  
    220 /** This shader computes the reprojection and checks 
    221         if the reprojected pixel from last frame is still 
    222         valid in the current frame 
    223 */ 
    224 /*inline float2 ComputeInfo(sampler2D oldTex, 
    225                                                   float4 color, 
    226                                                   float3 difVec, 
    227                                                   float2 texCoord, 
    228                                                   float3 viewDir, 
    229                                                   float3 oldEyePos, 
    230                                                   float4x4 modelViewProj, 
    231                                                   float4x4 oldModelViewProj, 
    232                                                   float3 oldbl, 
    233                                                   float3 oldbr, 
    234                                                   float3 oldtl, 
    235                                                   float3 oldtr, 
    236                                                   sampler2D myTex 
    237                                                   ) 
    238 { 
    239         // reconstruct position from the eye space depth 
    240         const float eyeSpaceDepth = color.w; 
    241         const float4 worldPos = float4(-viewDir * eyeSpaceDepth, 1.0f); 
    242  
    243         // compute position from old frame for dynamic objects + translational portion 
    244         const float3 translatedPos = -oldEyePos + worldPos.xyz + difVec; 
    245  
    246  
    247         ///////////////// 
    248         //-- reproject into old frame and calculate texture position of sample in old frame 
    249  
    250         // note: the old model view matrix only holds the view orientation part 
    251         float4 backProjPos = mul(oldModelViewProj, float4(translatedPos, 1.0f)); 
    252         backProjPos /= backProjPos.w; 
    253          
    254         // fit from unit cube into 0 .. 1 
    255         const float2 oldTexCoords = backProjPos.xy * .5f + .5f; 
    256          
    257         // retrieve the sample from the last frame 
    258         const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f)); 
    259         const float oldDiff = tex2Dlod(myTex, float4(oldTexCoords, .0f, .0f)).x; 
    260  
    261         // calculate eye space position of sample in old frame 
    262         const float oldEyeSpaceDepth = oldPixel.w; 
    263  
    264         // vector from eye pos to old sample  
    265         const float3 oldViewDir = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 
    266         const float invLen = 1.0f / length(oldViewDir); 
    267          
    268  
    269         // check if the pixel was outside of the frame buffer 
    270         if ((oldTexCoords.x <= .0f) || (oldTexCoords.x >= 1.0f) ||  
    271                 (oldTexCoords.y <= .0f) || (oldTexCoords.y >= 1.0f) 
    272                 ) 
    273         { 
    274                 isPixelValid = pixelIsNotValid; 
    275         } 
    276         else if (// check if changed from dynamic to not dynamic object 
    277                  ( 
    278                          // (oldDynamic && !newDynamic) || (!oldDynamic && newDynamic) || 
    279                          ( 
    280                           (oldEyeSpaceDepth < DEPTH_THRESHOLD) && (projectedEyeSpaceDepth < DEPTH_THRESHOLD) && 
    281                           //(oldDynamic || newDynamic) &&  // check if we have a dynamic object  
    282                           (depthDif > 5e-2f)))//MIN_DEPTH_DIFF))) 
    283                           ) // and there is a depth discontinuity 
    284         {        
    285                 isPixelValid = pixelCouldBeValid; 
    286         } 
    287         else  
    288         { 
    289                 isPixelValid = pixelIsValid; 
    290         } 
    291          
    292         //isPixelValid = depthDif; 
    293  
    294         return float3(isPixelValid, abs(oldEyeSpaceDepth - projectedEyeSpaceDepth)); 
    295 } 
    296 */ 
    297224 
    298225 
     
    365292        const float3 normal = normalize(tex2Dlod(normalsTex, float4(IN.texCoord, 0, 0)).xyz); 
    366293 
    367         // do reprojection and filter out the pixels that are not save 
    368 /*      const float2 pValid = PixelValid(oldTex, 
    369                                              color,  
    370                                                                          difVec.xyz, 
    371                                                                          IN.texCoord, 
    372                                                                          IN.view, 
    373                                                                          oldEyePos, 
    374                                                                          modelViewProj,                                                    
    375                                                                          oldModelViewProj, 
    376                                                                          oldbl, oldbr, oldtl, oldtr, 
    377                                                                          myTex 
    378                                                                          ); 
    379  
    380         pix.color = color; 
    381         pix.color.xy = pValid.xy; 
    382         pix.color.z = color.w; 
    383 */ 
    384294        const float3 translatedPos =  
    385295                ComputeTranslatedPos(color, difVec.xyz, IN.view, oldEyePos, oldModelViewProj); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3373 r3375  
    547547                                pixelValid = 100.0f; 
    548548                        } 
    549                         else if ((cosAngle >= 0) && (distanceDiff > 1e-3f)) 
     549                        else if (/*(cosAngle >= 0) && */(distanceDiff > 1e-3f)) 
    550550                        { 
    551551                                pixelValid = 5.0f; 
     552                                //pixelValid = 100.0f; 
    552553                        } 
    553554                } 
     
    732733        if (ao.y > partlyResetThres) 
    733734        { 
    734                 const float factor = 2.0f; 
     735                const float factor = 3.0f; 
    735736 
    736737                oldWeight = min(oldWeight, factor * NUM_SAMPLES); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/vienna.env

    r3362 r3375  
    8989 
    9090# tone mapping 
    91 useHDR=0 
     91useHDR=1 
    9292# use antialiasing 
    9393useAA=0 
     
    111111ssaoKernelRadius=4e-1f 
    112112# ssao sample intensity 
    113 ssaoSampleIntensity=0.2f 
    114 #ssaoSampleIntensity=0.8f 
     113#ssaoSampleIntensity=0.2f 
     114ssaoSampleIntensity=0.8f 
    115115# ssao temporal coherence factor 
    116116tempCohFactor=2000.0f 
Note: See TracChangeset for help on using the changeset viewer.