Changeset 3109


Ignore:
Timestamp:
11/07/08 10:15:44 (16 years ago)
Author:
mattausch
Message:

working on incorporation of dynamic objects into ssao

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

Legend:

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

    r3102 r3109  
    1515{ 
    1616 
     17int SceneEntity::sCurrentId = 0; 
    1718bool SceneEntity::sUseLODs = true; 
    1819 
    1920 
    2021SceneEntity::SceneEntity(Transform3 *trafo):  
    21 mTransform(trafo), mCurrentLODLevel(0), mLODLastUpdated(-1) 
     22mTransform(trafo), mCurrentLODLevel(0), mLODLastUpdated(-1), mId(sCurrentId ++) 
    2223{ 
    2324        mBox.Initialize(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r3102 r3109  
    127127        Vector3 mCenter; 
    128128 
     129        int mId; 
     130 
    129131        static bool sUseLODs; 
     132        static int sCurrentId; 
    130133}; 
     134 
    131135 
    132136} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3108 r3109  
    125125                                                                uniform float4x4 oldModelViewProj, 
    126126                                                                uniform float temporalCoherence, 
    127                                                                 uniform float2 samples[NUM_SAMPLES], 
    128127                                                                uniform sampler2D colors, 
    129                                                                 uniform sampler2D noiseTex, 
    130                                                                 float scaleFactor, 
    131128                                                                uniform float3 bl, 
    132129                                                                uniform float3 br, 
    133130                                                                uniform float3 tl, 
    134131                                                                uniform float3 tr,  
     132                                                                float invW, 
     133                                                                float3 projPos, 
     134                                                                float4x4 inverseModelTrafo, 
     135                                                                float id, 
     136                                                                uniform sampler2D noiseTex, 
     137                                                                uniform float2 samples[NUM_SAMPLES], 
     138                                                                float scaleFactor, 
    135139                                                                uniform float3 oldbl, 
    136140                                                                uniform float3 oldbr, 
    137141                                                                uniform float3 oldtl, 
    138                                                                 uniform  float3 oldtr, 
    139                                                                 float invW, 
    140                                                                 float3 projPos 
    141                                                                 //,const uniform float4x4 inverseModelTrafo 
    142                                                                 //, float id 
    143                                                  ) 
     142                                                                uniform  float3 oldtr 
     143                                                                ) 
    144144{ 
    145145        float4 illum_col; 
    146146 
     147        //////////// 
     148        //-- dynamic objects 
     149         
     150        float4x4 trafo; 
     151         
     152        if (id > 20) trafo = oldModelViewProj; 
     153        else trafo = inverseModelTrafo * oldModelViewProj; 
     154 
     155        // compute translational portion 
     156        const float3 translatedPt = worldPos.xyz - oldEyePos; 
     157 
    147158        ///////////////// 
    148         //-- compute reprojection for temporal smoothing 
    149  
    150         //float4x4 trafo; 
    151         // dynamic object 
    152         //if (id > 20) trafo = oldModelViewProj; 
    153         //else trafo = inverseModelTrafo * oldModelViewProj; 
    154  
    155         const float3 translatedPt = worldPos.xyz - oldEyePos; 
    156  
    157         // reproject into old frame and calculate texture position of sample in old frame 
    158         float4 backProjPos = mul(oldModelViewProj, float4(translatedPt, 1.0f)); 
     159        //-- reproject into old frame and calculate texture position of sample in old frame 
     160 
     161        // note: the old model view matrix only holds the view orientation part 
     162        float4 backProjPos = mul(trafo, float4(translatedPt, 1.0f)); 
    159163        backProjPos /= backProjPos.w; 
     164         
    160165        // fit from unit cube into 0 .. 1 
    161166        const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f; 
    162167         
    163  
    164168        // retrieve the sample from the last frame 
    165169        const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f)); 
     170 
    166171 
    167172#if USE_EYESPACE_DEPTH 
     
    171176        // vector from eye pos to old sample  
    172177        const float3 viewVec = Interpol(oldTexCoords, oldbl, oldbr, oldtl, oldtr); 
    173         const float invlen = 1.0f / length(viewVec); 
    174         const float projectedEyeSpaceDepth = invlen * length(translatedPt); 
     178        const float invLen = 1.0f / length(viewVec); 
     179        const float projectedEyeSpaceDepth = invLen * length(translatedPt); 
    175180         
    176181        //const float depthDif = abs(oldEyeSpaceDepth - projectedEyeSpaceDepth); 
    177         //const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 
    178  
    179         const float depthDif = abs(projectedEyeSpaceDepth - oldEyeSpaceDepth ) / projectedEyeSpaceDepth; 
     182        const float depthDif = abs(1.0f - oldEyeSpaceDepth / projectedEyeSpaceDepth); 
     183        //const float depthDif = abs(projectedEyeSpaceDepth - oldEyeSpaceDepth ) / projectedEyeSpaceDepth; 
    180184 
    181185#else 
     
    345349                   uniform float3 oldbr, 
    346350                   uniform float3 oldtl, 
    347                    uniform float3 oldtr 
     351                   uniform float3 oldtr, 
     352                   uniform sampler2D attribs, 
     353                   uniform float4x4 inverseModelTrafo 
    348354                   ) 
    349355{ 
     
    377383        //-- compute temporally smoothing 
    378384 
     385        float id = tex2Dlod(attribs, float4(IN.texCoord, 0, 0)).x; 
     386 
    379387        OUT.illum_col = temporalSmoothing(eyeSpacePos, eyeSpaceDepth, ao, IN.texCoord, oldEyePos, 
    380388                                              oldTex, oldModelViewProj, temporalCoherence, 
    381                                               samples, colors, noiseTex, w, bl, br, tl, tr, 
    382                                                                           oldbl, oldbr, oldtl, oldtr, scaleFactor, projPos); 
     389                                              colors, w, bl, br, tl, tr, projPos, inverseModelTrafo, id, 
     390                                                                          noiseTex, samples, scaleFactor, oldbl, oldbr, oldtl, oldtr); 
    383391 
    384392        //OUT.illum_col.xyz = normal * 0.5f + 0.5f; 
Note: See TracChangeset for help on using the changeset viewer.