Changeset 3111


Ignore:
Timestamp:
11/09/08 13:34:36 (16 years ago)
Author:
mattausch
Message:

worked on dynamic objects indexing not working yet

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

Legend:

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

    r3110 r3111  
    253253mSamplingMethod(SAMPLING_POISSON), 
    254254mShadingMethod(DEFAULT), 
    255 mIllumFboIndex(0) 
     255mIllumFboIndex(0), 
     256invTrafo(IdentityMatrix()) 
    256257{ 
    257258        /////////// 
     
    337338        string ssaoParams[] =  
    338339                {"colors", "normals", "oldTex", "noiseTex", "temporalCoherence",  
    339                  "samples", "bl", "br", "tl", "tr", "modelViewProj", "oldModelViewProj", 
    340                  "oldEyePos", "oldbl", "oldbr", "oldtl", "oldtr", "attribsTex", "inverseModelTrafo"}; 
     340                 "samples", "bl", "br", "tl", "tr",  
     341                 "modelViewProj", "oldModelViewProj", "oldEyePos", "oldbl", "oldbr",  
     342                 "oldtl", "oldtr", "attribsTex", "inverseModelTrafo"}; 
    341343        sCgSsaoProgram->AddParameters(ssaoParams, 0, 19); 
    342344         
    343345        string giParams[] =  
    344346                {"colors", "normals", "noiseTex", "oldSsaoTex", "oldIllumTex",  
    345                  "temporalCoherence", "samples", "bl", "br", "tl", "tr", "oldModelViewProj", "modelViewProj"}; 
     347                 "temporalCoherence", "samples", "bl", "br", "tl",  
     348                 "tr", "oldModelViewProj", "modelViewProj"}; 
    346349        sCgGiProgram->AddParameters(giParams, 0, 13); 
    347350 
     
    562565        sCgSsaoProgram->SetTexture(i ++, attribsTex); 
    563566 
    564         sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix()); 
     567        sCgSsaoProgram->SetMatrix(i ++, invTrafo); 
     568        //sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix()); 
    565569 
    566570        DrawQuad(sCgSsaoProgram); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.h

    r3085 r3111  
    6060        static int colorBufferIdx; 
    6161 
     62        Matrix4x4 invTrafo; 
    6263 
    6364protected: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3110 r3111  
    212212static int sCurrentMrtSet = 0; 
    213213 
     214static Matrix4x4 invTrafo = IdentityMatrix(); 
     215 
    214216 
    215217////////////// 
     
    234236ShadowMap *shadowMap = NULL; 
    235237DirectionalLight *light = NULL; 
    236 DeferredRenderer *ssaoShader = NULL; 
     238DeferredRenderer *deferredShader = NULL; 
    237239 
    238240//SceneEntity *cube = NULL; 
     
    462464 
    463465        LoadModel("hbuddha.dem", dynamicObjects); 
    464         //LoadModel("hbuddha2.dem", dynamicObjects); 
    465466        buddha = dynamicObjects.back(); 
    466467         
     
    528529                dynamicObjects[i]->mId = 0; 
    529530         
    530         buddha->mId = 50; 
     531        buddha->mId = 250; 
    531532 
    532533 
     
    897898void MainLoop()  
    898899{        
    899         Vector3 oldPos = motionPath->GetCurrentPosition(); 
    900  
    901         //motionPath->Move(0.3f); 
    902         motionPath->Move(0.01f); 
    903  
    904         nMatrix mat =  
    905         Vector3 planepos = motionPath->GetCurrentPosition(); 
    906  
    907         Matrix4x4 mat = TranslationMatrix(planepos); 
    908         buddha->GetTransform()->SetMatrix(mat); 
     900        static Matrix4x4 invTrafo = IdentityMatrix(); 
     901 
     902        Vector3 buddhaPos = motionPath->GetCurrentPosition(); 
     903        Matrix4x4 trafo = TranslationMatrix(buddhaPos); 
     904        buddha->GetTransform()->SetMatrix(trafo); 
     905 
     906        ///////////// 
    909907 
    910908        Vector3 oldPos = camera->GetPosition(); 
     
    10701068                FrameBufferObject::Release(); 
    10711069 
    1072                 if (!ssaoShader) ssaoShader =  
     1070                if (!deferredShader) deferredShader =  
    10731071                        new DeferredRenderer(texWidth, texHeight, camera); 
    10741072                 
     
    10851083                        shadingMethod = DeferredRenderer::DEFAULT; 
    10861084 
    1087  
    1088                 ssaoShader->SetShadingMethod(shadingMethod); 
    1089                 ssaoShader->SetSamplingMethod(samplingMethod); 
    1090                 ssaoShader->SetUseTemporalCoherence(useTemporalCoherence); 
     1085                deferredShader->invTrafo = invTrafo; 
     1086                deferredShader->SetShadingMethod(shadingMethod); 
     1087                deferredShader->SetSamplingMethod(samplingMethod); 
     1088                deferredShader->SetUseTemporalCoherence(useTemporalCoherence); 
    10911089 
    10921090                ShadowMap *sm = showShadowMap ? shadowMap : NULL; 
    1093                 ssaoShader->Render(fbo, ssaoTempCohFactor, light, useHDR, sm); 
     1091                deferredShader->Render(fbo, ssaoTempCohFactor, light, useHDR, sm); 
    10941092        } 
    10951093 
     
    11301128 
    11311129        glutSwapBuffers(); 
     1130 
     1131 
     1132        ///////////////////////// 
     1133 
     1134        //motionPath->Move(0.3f); 
     1135        motionPath->Move(0.01f); 
     1136        Vector3 oldBuddhaPos = buddhaPos; 
     1137        // new position 
     1138        buddhaPos = motionPath->GetCurrentPosition(); 
     1139 
     1140        Vector3 diff = oldBuddhaPos - buddhaPos; 
     1141        //Vector3 diff = buddhaPos - oldBuddhaPos; 
     1142 
     1143        invTrafo = TranslationMatrix(diff); 
     1144        //cout<< "diff " << diff << endl; 
    11321145} 
    11331146 
     
    17041717        DEL_PTR(perfGraph); 
    17051718        DEL_PTR(fbo); 
    1706         DEL_PTR(ssaoShader); 
     1719        DEL_PTR(deferredShader); 
    17071720        DEL_PTR(light); 
    17081721        DEL_PTR(visCamera); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3110 r3111  
    145145        float4 illum_col; 
    146146 
     147 
    147148        //////////// 
    148149        //-- dynamic objects 
    149150         
    150         float4x4 trafo; 
    151          
    152         if (id < 10)  
    153                 trafo = oldModelViewProj; 
    154         else  
    155                 trafo = inverseModelTrafo * oldModelViewProj; 
     151        //float4x4 trafo = (id < 10.0f) ? oldModelViewProj : mul(oldModelViewProj, inverseModelTrafo); 
     152        float4x4 trafo = mul(oldModelViewProj, inverseModelTrafo); 
    156153 
    157154        // compute translational portion 
    158155        const float3 translatedPt = worldPos.xyz - oldEyePos; 
     156 
    159157 
    160158        ///////////////// 
     
    167165        // fit from unit cube into 0 .. 1 
    168166        const float2 oldTexCoords = backProjPos.xy * 0.5f + 0.5f; 
    169          
    170167        // retrieve the sample from the last frame 
    171168        const float4 oldPixel = tex2Dlod(oldTex, float4(oldTexCoords, .0f, .0f)); 
     
    173170 
    174171#if USE_EYESPACE_DEPTH 
     172 
    175173        // calculate eye space position of sample in old frame 
    176174        const float oldEyeSpaceDepth = oldPixel.w; 
Note: See TracChangeset for help on using the changeset viewer.