Ignore:
Timestamp:
11/11/08 12:18:07 (16 years ago)
Author:
mattausch
Message:

strange errors

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

Legend:

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

    r3115 r3117  
    234234 
    235235 
    236 static void InitBuffer(FrameBufferObject *fbo, int index) 
    237 { 
    238         // read the second buffer, write to the first buffer 
    239         fbo->Bind(); 
    240         glDrawBuffers(1, mrt + index); 
    241  
    242         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
    243  
    244         FrameBufferObject::Release(); 
    245 } 
    246  
    247  
    248236DeferredRenderer::DeferredRenderer(int w, int h, PerspectiveCamera *cam): 
    249237mWidth(w), mHeight(h),  
     
    270258        { 
    271259                mIllumFbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
    272                 InitBuffer(mIllumFbo, i); 
    273         } 
     260                FrameBufferObject::InitBuffer(mIllumFbo, i); 
     261        } 
     262 
     263 
     264        /////////////// 
     265        //-- the downsampled ssao + color bleeding textures: as gi is inherently low frequency, we can use these to improve performance 
    274266 
    275267        mDownSampleFbo = new FrameBufferObject(dsw, dsh, FrameBufferObject::DEPTH_NONE); 
     
    278270        // downsample buffer for the normal texture 
    279271        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_16, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     272        // downsample buffer for the offset texture 
     273        mDownSampleFbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR); 
     274 
     275        for (int i = 0; i < 3; ++ i) 
     276        { 
     277                FrameBufferObject::InitBuffer(mDownSampleFbo, i); 
     278        } 
    280279 
    281280        mFBOs.push_back(mDownSampleFbo); 
     
    453452                // normals 
    454453                DownSample(fbo, 1, mDownSampleFbo, 1); 
     454                // offsets 
     455                DownSample(fbo, 2, mDownSampleFbo, 2); 
    455456        } 
    456457 
     
    458459        { 
    459460        case SSAO: 
    460  
    461461                ComputeSsao(fbo, tempCohFactor); 
    462462                CombineSsao(fbo); 
     
    501501                                                                   float tempCohFactor) 
    502502{ 
     503        GLuint colorsTex, normalsTex, attribsTex; 
     504 
     505        if (0) 
     506        { 
     507                colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     508                normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     509                attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 
     510        } 
     511        else 
     512        { 
     513                colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 
     514                normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 
     515                attribsTex = mDownSampleFbo->GetColorBuffer(2)->GetTexture(); 
     516        } 
     517 
     518        // flip flop between illumination buffers 
     519        GLuint oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 
     520 
     521        cout << colorBufferIdx; 
     522 
     523        glPushAttrib(GL_VIEWPORT_BIT); 
     524        glViewport(0, 0, mIllumFbo->GetWidth(), mIllumFbo->GetHeight()); 
     525 
     526        // read the second buffer, write to the first buffer 
     527        mIllumFbo->Bind(); 
     528        glDrawBuffers(1, mrt + mIllumFboIndex); 
     529 
     530        int i = 0; 
     531 
     532        sCgSsaoProgram->SetTexture(i ++, colorsTex); 
     533        sCgSsaoProgram->SetTexture(i ++, normalsTex); 
     534        sCgSsaoProgram->SetTexture(i ++, oldTex); 
     535        sCgSsaoProgram->SetTexture(i ++, noiseTex); 
     536 
     537        sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
     538         
     539        if (mUseTemporalCoherence || mRegenerateSamples) 
     540        { 
     541                mRegenerateSamples = false; 
     542 
     543                // q: should we generate new samples or only rotate the old ones? 
     544                // in the first case, the sample patterns look nicer, but the kernel 
     545                // needs longer to converge 
     546                GenerateSamples(mSamplingMethod);  
     547                sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 
     548        } 
     549         
     550        ++ i; 
     551 
     552        for (int j = 0; j < 4; ++ j, ++ i) 
     553                sCgSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 
     554 
     555        sCgSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 
     556        sCgSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 
     557 
     558        Vector3 de; 
     559        de.x = mOldEyePos.x - mEyePos.x; 
     560        de.y = mOldEyePos.y - mEyePos.y;  
     561        de.z = mOldEyePos.z - mEyePos.z; 
     562 
     563        sCgSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z); 
     564 
     565        for (int j = 0; j < 4; ++ j, ++ i) 
     566                sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 
     567 
     568        sCgSsaoProgram->SetTexture(i ++, attribsTex); 
     569 
     570        DrawQuad(sCgSsaoProgram); 
     571 
     572        glPopAttrib(); 
     573 
     574        PrintGLerror("ssao first pass"); 
     575} 
     576 
     577 
     578static void SetVertex(float x, float y, float x_offs, float y_offs) 
     579{ 
     580        glMultiTexCoord2fARB(GL_TEXTURE0_ARB, x, y); // center 
     581        glMultiTexCoord2fARB(GL_TEXTURE1_ARB, x - x_offs, y + y_offs); // left top 
     582        glMultiTexCoord2fARB(GL_TEXTURE2_ARB, x + x_offs, y - y_offs); // right bottom 
     583        glMultiTexCoord2fARB(GL_TEXTURE3_ARB, x + x_offs, y + y_offs); // right top 
     584        glMultiTexCoord2fARB(GL_TEXTURE4_ARB, x - x_offs, y - y_offs); // left bottom 
     585 
     586        glMultiTexCoord4fARB(GL_TEXTURE5_ARB, x - x_offs, y, x + x_offs, y); // left right 
     587        glMultiTexCoord4fARB(GL_TEXTURE6_ARB, x, y + y_offs, x, y - y_offs); // top bottom 
     588 
     589        //glVertex3f(x - 0.5f, y - 0.5f, -0.5f); 
     590        glVertex2f(x, y); 
     591} 
     592 
     593 
     594void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo, DirectionalLight *light) 
     595{ 
     596        FrameBufferObject::Release(); 
     597 
     598        ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
     599 
     600        GLuint colorsTex = colorBuffer->GetTexture(); 
     601        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
     602 
     603        sCgAntiAliasingProgram->SetTexture(0, colorsTex); 
     604        sCgAntiAliasingProgram->SetTexture(1, normalsTex); 
     605 
     606        sCgAntiAliasingProgram->Bind(); 
     607 
     608        glBegin(GL_QUADS); 
     609 
     610        // the neighbouring texels 
     611        float x_offs = 1.0f / mWidth; 
     612        float y_offs = 1.0f / mHeight; 
     613 
     614        SetVertex(0, 0, x_offs, y_offs); 
     615        SetVertex(1, 0, x_offs, y_offs); 
     616        SetVertex(1, 1, x_offs, y_offs); 
     617        SetVertex(0, 1, x_offs, y_offs); 
     618 
     619        glEnd(); 
     620 
     621        PrintGLerror("antialiasing"); 
     622} 
     623 
     624 
     625void DeferredRenderer::FirstPass(FrameBufferObject *fbo, DirectionalLight *light) 
     626{ 
     627        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     628        GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
     629 
     630        fbo->Bind(); 
     631 
     632        colorBufferIdx = 3 - colorBufferIdx; 
     633        glDrawBuffers(1, mrt + colorBufferIdx); 
     634 
     635        const Vector3 lightDir = -light->GetDirection(); 
     636 
     637        sCgDeferredProgram->SetTexture(0, colorsTex); 
     638        sCgDeferredProgram->SetTexture(1, normalsTex); 
     639        sCgDeferredProgram->SetValue3f(2, lightDir.x, lightDir.y, lightDir.z); 
     640         
     641        DrawQuad(sCgDeferredProgram); 
     642 
     643        PrintGLerror("deferred shading"); 
     644} 
     645 
     646 
     647void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo,  
     648                                                                                float tempCohFactor) 
     649{ 
    503650#if 0 
    504651        GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
     
    509656#endif 
    510657 
    511         // flip flop between illumination buffers 
    512         GLuint oldTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 
    513  
    514658        glPushAttrib(GL_VIEWPORT_BIT); 
    515659        glViewport(0, 0, mIllumFbo->GetWidth(), mIllumFbo->GetHeight()); 
     
    517661        // read the second buffer, write to the first buffer 
    518662        mIllumFbo->Bind(); 
    519         glDrawBuffers(1, mrt + mIllumFboIndex); 
    520  
    521         int i = 0; 
    522  
    523         sCgSsaoProgram->SetTexture(i ++, colorsTex); 
    524         sCgSsaoProgram->SetTexture(i ++, normalsTex); 
    525         sCgSsaoProgram->SetTexture(i ++, oldTex); 
    526         sCgSsaoProgram->SetTexture(i ++, noiseTex); 
    527  
    528         sCgSsaoProgram->SetValue1f(i ++, (mUseTemporalCoherence && !mRegenerateSamples) ? tempCohFactor : 0); 
    529          
    530         if (mUseTemporalCoherence || mRegenerateSamples) 
    531         { 
    532                 mRegenerateSamples = false; 
    533  
    534                 // q: should we generate new samples or only rotate the old ones? 
    535                 // in the first case, the sample patterns look nicer, but the kernel 
    536                 // needs longer to converge 
    537                 GenerateSamples(mSamplingMethod);  
    538                 sCgSsaoProgram->SetArray2f(i, (float *)samples2, NUM_SAMPLES); 
    539         } 
    540          
    541         ++ i; 
    542  
    543         for (int j = 0; j < 4; ++ j, ++ i) 
    544                 sCgSsaoProgram->SetValue3f(i, mCornersView[j].x, mCornersView[j].y, mCornersView[j].z); 
    545  
    546         sCgSsaoProgram->SetMatrix(i ++, mProjViewMatrix); 
    547         sCgSsaoProgram->SetMatrix(i ++, mOldProjViewMatrix); 
    548  
    549         //Vector3 de = mOldEyePos - mEyePos; 
    550         Vector3 de; 
    551         de.x = mOldEyePos.x - mEyePos.x; 
    552         de.y = mOldEyePos.y - mEyePos.y;  
    553         de.z = mOldEyePos.z - mEyePos.z; 
    554         //Vector3 de = mEyePos - mOldEyePos; 
    555  
    556         sCgSsaoProgram->SetValue3f(i ++, de.x, de.y, de.z); 
    557  
    558         for (int j = 0; j < 4; ++ j, ++ i) 
    559                 sCgSsaoProgram->SetValue3f(i, mOldCornersView[j].x, mOldCornersView[j].y, mOldCornersView[j].z); 
    560  
    561         GLuint attribsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    562         sCgSsaoProgram->SetTexture(i ++, attribsTex); 
    563  
    564         float trafos[32]; 
    565         for (int i = 0; i < 16; ++ i) 
    566                 trafos[i] = ((const float *)invTrafo.x)[i]; 
    567  
    568         static Matrix4x4 identity = IdentityMatrix(); 
    569  
    570         for (int i = 0; i < 16; ++ i) 
    571                 trafos[i+16] = ((const float *)identity.x)[i]; 
    572  
    573         //sCgSsaoProgram->SetMatrixArray(i ++, trafos, 2); 
    574         //sCgSsaoProgram->SetMatrix(i ++, IdentityMatrix()); 
    575  
    576         DrawQuad(sCgSsaoProgram); 
    577  
    578         glPopAttrib(); 
    579  
    580         PrintGLerror("ssao first pass"); 
    581 } 
    582  
    583  
    584 static void SetVertex(float x, float y, float x_offs, float y_offs) 
    585 { 
    586         glMultiTexCoord2fARB(GL_TEXTURE0_ARB, x, y); // center 
    587         glMultiTexCoord2fARB(GL_TEXTURE1_ARB, x - x_offs, y + y_offs); // left top 
    588         glMultiTexCoord2fARB(GL_TEXTURE2_ARB, x + x_offs, y - y_offs); // right bottom 
    589         glMultiTexCoord2fARB(GL_TEXTURE3_ARB, x + x_offs, y + y_offs); // right top 
    590         glMultiTexCoord2fARB(GL_TEXTURE4_ARB, x - x_offs, y - y_offs); // left bottom 
    591  
    592         glMultiTexCoord4fARB(GL_TEXTURE5_ARB, x - x_offs, y, x + x_offs, y); // left right 
    593         glMultiTexCoord4fARB(GL_TEXTURE6_ARB, x, y + y_offs, x, y - y_offs); // top bottom 
    594  
    595         //glVertex3f(x - 0.5f, y - 0.5f, -0.5f); 
    596         glVertex2f(x, y); 
    597 } 
    598  
    599  
    600 void DeferredRenderer::AntiAliasing(FrameBufferObject *fbo, DirectionalLight *light) 
    601 { 
    602         FrameBufferObject::Release(); 
    603  
    604         ColorBufferObject *colorBuffer = fbo->GetColorBuffer(colorBufferIdx); 
    605  
    606         GLuint colorsTex = colorBuffer->GetTexture(); 
    607         GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    608  
    609         sCgAntiAliasingProgram->SetTexture(0, colorsTex); 
    610         sCgAntiAliasingProgram->SetTexture(1, normalsTex); 
    611  
    612         sCgAntiAliasingProgram->Bind(); 
    613  
    614         glBegin(GL_QUADS); 
    615  
    616         // the neighbouring texels 
    617         float x_offs = 1.0f / mWidth; 
    618         float y_offs = 1.0f / mHeight; 
    619  
    620         SetVertex(0, 0, x_offs, y_offs); 
    621         SetVertex(1, 0, x_offs, y_offs); 
    622         SetVertex(1, 1, x_offs, y_offs); 
    623         SetVertex(0, 1, x_offs, y_offs); 
    624  
    625         glEnd(); 
    626  
    627         PrintGLerror("antialiasing"); 
    628 } 
    629  
    630  
    631 void DeferredRenderer::FirstPass(FrameBufferObject *fbo, DirectionalLight *light) 
    632 { 
    633         GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    634         GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    635  
    636         fbo->Bind(); 
    637  
    638         colorBufferIdx = 3 - colorBufferIdx; 
    639         glDrawBuffers(1, mrt + colorBufferIdx); 
    640  
    641         const Vector3 lightDir = -light->GetDirection(); 
    642  
    643         sCgDeferredProgram->SetTexture(0, colorsTex); 
    644         sCgDeferredProgram->SetTexture(1, normalsTex); 
    645         sCgDeferredProgram->SetValue3f(2, lightDir.x, lightDir.y, lightDir.z); 
    646          
    647         DrawQuad(sCgDeferredProgram); 
    648  
    649         PrintGLerror("deferred shading"); 
    650 } 
    651  
    652  
    653 void DeferredRenderer::ComputeGlobIllum(FrameBufferObject *fbo,  
    654                                                                                 float tempCohFactor) 
    655 { 
    656 #if 0 
    657         GLuint colorsTex = fbo->GetColorBuffer(colorBufferIdx)->GetTexture(); 
    658         GLuint normalsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    659 #else 
    660         GLuint colorsTex = mDownSampleFbo->GetColorBuffer(0)->GetTexture(); 
    661         GLuint normalsTex = mDownSampleFbo->GetColorBuffer(1)->GetTexture(); 
    662 #endif 
    663  
    664         glPushAttrib(GL_VIEWPORT_BIT); 
    665         glViewport(0, 0, mIllumFbo->GetWidth(), mIllumFbo->GetHeight()); 
    666  
    667         // read the second buffer, write to the first buffer 
    668         mIllumFbo->Bind(); 
    669663 
    670664        glDrawBuffers(2, mrt + mIllumFboIndex); 
     
    672666        GLuint oldSsaoTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex)->GetTexture(); 
    673667        GLuint oldIllumTex = mIllumFbo->GetColorBuffer(2 - mIllumFboIndex + 1)->GetTexture(); 
    674          
    675668 
    676669        sCgGiProgram->SetTexture(0, colorsTex); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.cpp

    r3021 r3117  
    364364 
    365365 
     366void FrameBufferObject::InitBuffer(FrameBufferObject *fbo, int index) 
     367{ 
     368        // read the second buffer, write to the first buffer 
     369        fbo->Bind(); 
     370        glDrawBuffers(1, mrt + index); 
     371 
     372        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 
     373 
     374        FrameBufferObject::Release(); 
     375} 
     376 
    366377} // namespace 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrameBufferObject.h

    r3017 r3117  
    2929                                          WRAP_TYPE wrapType,  
    3030                                          FILTER_TYPE filterType); 
    31  
    3231        /** Same as above, with mipmapping enabled. 
    3332        */ 
     
    4140 
    4241        ~ColorBufferObject(); 
    43  
     42        /** Returns associated texture id. 
     43        */ 
    4444        inline unsigned int GetTexture() const { return mTexId; } 
    45  
     45        /** Returns width of render target. 
     46        */ 
    4647        inline int GetWidth() { return mWidth; } 
    47  
     48        /** Returns height of render target. 
     49        */ 
    4850        inline int GetHeight() { return mHeight; } 
    4951        /** Returns texture data. 
     
    7880 
    7981 
    80 /** This class implements a wrapper for a frame buffer object 
     82/** This class implements a wrapper for a frame buffer object. 
    8183*/ 
    8284class FrameBufferObject 
     
    8486public: 
    8587 
     88        /// Available depth formats 
    8689        enum DEPTH_FORMAT {DEPTH_NONE, DEPTH_16, DEPTH_24, DEPTH_32}; 
    8790 
     
    8992        */ 
    9093        FrameBufferObject(int w, int h, DEPTH_FORMAT d, bool useDepthTex = false); 
    91          
     94        /** Destructor destroying gl resources. 
     95        */ 
    9296        ~FrameBufferObject(); 
    9397        /** Creates and adds a color buffer to the current frame buffer object. 
     
    105109                                           ColorBufferObject::FILTER_TYPE filterTypeMipMap); 
    106110 
    107         /** Returns the color buffer object on position i. 
    108         */ 
    109         ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; } 
    110111        /** Binds this frame buffer object. 
    111112        */ 
    112113        void Bind() const; 
     114         
     115        /////////////////// 
     116         
     117        /** Returns the color buffer object on position i. 
     118        */ 
     119        inline ColorBufferObject *GetColorBuffer(int i) const { return mColorBuffers[i]; } 
     120        /** Returns depth texture id 
     121        */ 
     122        inline unsigned int GetDepthTex() const { return mDepthTexId; } 
     123        /** Returns width of fbo 
     124        */ 
     125        inline int GetWidth() { return mWidth; } 
     126        /** Returns height of fbo 
     127        */ 
     128        inline int GetHeight() { return mHeight; } 
     129 
     130 
     131        //////////////// 
     132 
     133        /** Initialise a render target (using current clear color) 
     134        */ 
     135        static void InitBuffer(FrameBufferObject *fbo, int index); 
    113136        /** Releases any bound frame buffer object. 
    114137        */ 
    115138        static void Release(); 
    116139         
    117         unsigned int GetDepthTex() const { return mDepthTexId; } 
    118  
    119         inline int GetWidth() { return mWidth; } 
    120  
    121         inline int GetHeight() { return mHeight; } 
    122  
    123  
    124140protected: 
    125141 
     
    137153}; 
    138154 
     155 
    139156} // namespace  
     157 
    140158#endif // _FrameBufferObject_H__ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp

    r3114 r3117  
    139139{ 
    140140        //if (mCurrentTechnique == tech) return; 
    141  
    142141        mCurrentTechnique = tech; 
    143142 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3115 r3117  
    361361                env.GetIntParam(string("winWidth"), winWidth); 
    362362                env.GetIntParam(string("winHeight"), winHeight); 
    363  
    364                 env.GetBoolParam(string("useFullScreen"), useFullScreen); 
    365363                env.GetFloatParam(string("tempCohFactor"), ssaoTempCohFactor); 
    366364                env.GetVectorParam(string("camPosition"), camPos); 
    367365                env.GetVectorParam(string("camDirection"), camDir); 
    368366                env.GetVectorParam(string("lightDirection"), lightDir); 
    369  
     367                env.GetIntParam(string("shadowSize"), shadowSize); 
     368 
     369                env.GetBoolParam(string("useFullScreen"), useFullScreen); 
    370370                env.GetBoolParam(string("useLODs"), useLODs); 
    371                 env.GetIntParam(string("shadowSize"), shadowSize); 
    372  
    373371                env.GetBoolParam(string("useHDR"), useHDR); 
     372 
    374373 
    375374                //env.GetStringParam(string("modelPath"), model_path); 
     
    464463        //-- load some dynamic stuff 
    465464 
    466         LoadModel("hbuddha.dem", dynamicObjects); 
     465/*      LoadModel("hbuddha.dem", dynamicObjects); 
    467466        buddha = dynamicObjects.back(); 
    468467         
     
    488487                dynamicObjects.push_back(ent); 
    489488        } 
    490  
     489*/ 
    491490 
    492491        /////////// 
     
    523522        preetham = new SkyPreetham(turbitiy, skyDome); 
    524523 
    525         CreateAnimation(); 
    526  
    527         for (int i = 0; i < sceneEntities.size(); ++ i) 
    528                 sceneEntities[i]->mId = 0; 
    529         for (int i = 0; i < dynamicObjects.size(); ++ i) 
    530                 dynamicObjects[i]->mId = 0; 
    531          
    532         //buddha->mId = 250; 
    533         buddha->mId = 1; 
     524        //CreateAnimation(); 
    534525 
    535526 
     
    567558        // we store diffuse colors, eye space depth and normals 
    568559        fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_32); 
    569         //fbo = new FrameBufferObject(texWidth, texHeight, FrameBufferObject::DEPTH_24); 
    570560 
    571561        // the diffuse color buffer 
     
    575565        // a rgb buffer which could hold material properties 
    576566        //fbo->AddColorBuffer(ColorBufferObject::RGB_UBYTE, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
    577         // holding the difference vector to the old frame 
     567        // buffer holding the difference vector to the old frame 
    578568        fbo->AddColorBuffer(ColorBufferObject::RGB_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_NEAREST); 
    579569        // another color buffer 
    580570        fbo->AddColorBuffer(ColorBufferObject::RGBA_FLOAT_32, ColorBufferObject::WRAP_CLAMP_TO_EDGE, ColorBufferObject::FILTER_LINEAR, ColorBufferObject::FILTER_NEAREST); 
    581571 
    582         PrintGLerror("fbo"); 
     572        for (int i = 0; i < 4; ++ i) 
     573                FrameBufferObject::InitBuffer(fbo, i); 
     574         
     575        PrintGLerror("init fbo"); 
    583576} 
    584577 
     
    902895void MainLoop()  
    903896{        
    904         GPUProgramParameters *vtxParams =  
     897        /*GPUProgramParameters *vtxParams =  
    905898                buddha->GetShape(0)->GetMaterial()->GetTechnique(1)->GetVertexProgramParameters(); 
    906899 
     
    915908        dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 
    916909 
    917  
     910*/ 
    918911        ///////////// 
    919912 
     
    11441137        ///////////////////////// 
    11451138 
    1146         //motionPath->Move(0.3f); 
     1139        /*//motionPath->Move(0.3f); 
    11471140        motionPath->Move(0.01f); 
    11481141        Vector3 oldBuddhaPos = buddhaPos; 
     
    11551148        invTrafo = TranslationMatrix(diff); 
    11561149        //cout<< "diff " << diff << endl; 
     1150        */ 
    11571151} 
    11581152 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/mrt.cg

    r3113 r3117  
    1616 
    1717        float4 color: COLOR0;   
    18         float4 eyePos: TEXCOORD1; // eye position 
     18         // eye position 
     19        float4 eyePos: TEXCOORD1; 
    1920        float4 normal: TEXCOORD2; 
    2021        float4 worldPos: TEXCOORD3; 
     
    3031 
    3132        float4 winPos: WPOS; 
    32         float4 eyePos: TEXCOORD1; // eye position 
     33        // eye position 
     34        float4 eyePos: TEXCOORD1; 
    3335        float4 normal: TEXCOORD2; 
    3436        float4 worldPos: TEXCOORD3; 
     
    6163        // transform the vertex position into post projection space 
    6264        OUT.position = mul(glstate.matrix.mvp, IN.position); 
    63  
    6465        // the normal has to be correctly transformed with the inverse transpose 
    6566        OUT.normal = mul(glstate.matrix.invtrans.modelview[0], IN.normal); 
    66  
    6767        // transform the old vertex position into world space 
    6868        OUT.worldPos = mul(modelMatrix, IN.position); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/ssao.cg

    r3115 r3117  
    177177 
    178178#else 
     179 
    179180        // calculate eye space position of sample in old frame 
    180181        const float oldDepth = oldPixel.w; 
     
    182183        // vector from eye pos to old sample  
    183184        const float depthDif = abs(projectedDepth - oldDepth); 
     185 
    184186#endif 
    185187 
     
    210212        } 
    211213 
    212  
    213         // the number of valid samples in this frame 
    214         //const float newNumSamples = ao.y; 
    215         //const float oldNumSamples = oldCol.y; 
    216  
    217214        const float oldWeight = clamp(oldPixel.y, .0f, temporalCoherence); 
    218215        float newWeight; 
     
    256253*/ 
    257254float2 ssao(fragment IN, 
    258                         uniform sampler2D colors, 
    259                         uniform sampler2D noiseTex, 
    260                         uniform float2 samples[NUM_SAMPLES], 
    261                         uniform float3 normal, 
    262                         uniform float3 centerPosition, 
    263                         uniform float scaleFactor, 
    264                         uniform float3 bl, 
    265                         uniform float3 br, 
    266                         uniform float3 tl, 
    267                         uniform float3 tr,  
    268                         uniform float3 viewDir 
     255                        sampler2D colors, 
     256                        sampler2D noiseTex, 
     257                        float2 samples[NUM_SAMPLES], 
     258                        float3 normal, 
     259                        float3 centerPosition, 
     260                        float scaleFactor, 
     261                        float3 bl, 
     262                        float3 br, 
     263                        float3 tl, 
     264                        float3 tr,  
     265                        float3 viewDir 
     266                        //,float2 noiseOffs 
    269267                        ) 
    270268{ 
     
    285283                //-- add random noise: reflect around random normal vector (rather slow!) 
    286284 
     285                //float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f + noiseOffs, 0, 0)).xy; 
    287286                float2 mynoise = tex2Dlod(noiseTex, float4(IN.texCoord * 4.0f, 0, 0)).xy; 
    288287                const float2 offsetTransformed = myreflect(offset, mynoise); 
     
    374373        { 
    375374                ao = ssao(IN, colors, noiseTex, samples, normal,  
    376                           eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir)); 
     375                          eyeSpacePos.xyz, scaleFactor, bl, br, tl, tr, normalize(viewDir));//, noiseOffs); 
    377376        } 
    378377 
Note: See TracChangeset for help on using the changeset viewer.