Ignore:
Timestamp:
09/02/08 00:56:48 (16 years ago)
Author:
mattausch
Message:

shadowing partly working

File:
1 edited

Legend:

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

    r2892 r2893  
    4646 
    4747static CGparameter sShadowMatrixParam; 
    48  
    49  
    50  
    51  
    52 DeferredShader::DeferredShader(int w, int h): 
    53 mWidth(w), mHeight(h) 
     48static CGparameter sMaxDepthParam; 
     49 
     50 
     51 
     52DeferredShader::DeferredShader(int w, int h, float scaleFactor): 
     53mWidth(w), mHeight(h), mScaleFactor(scaleFactor) 
    5454{ 
    5555        //mFbo = new FrameBufferObject(w, h, FrameBufferObject::DEPTH_NONE); 
     
    124124                sNormalsTexShadowParam = cgGetNamedParameter(sCgDeferredShadowProgram, "normals");  
    125125                sShadowMapParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMap");   
    126  
     126                sMaxDepthParam = cgGetNamedParameter(sCgDeferredShadowProgram, "maxDepth"); 
    127127                sShadowMatrixParam = cgGetNamedParameter(sCgDeferredShadowProgram, "shadowMatrix"); 
    128128        } 
     
    184184        glDisable(GL_TEXTURE_2D); 
    185185        glDisable(GL_LIGHTING); 
     186        glDepthMask(GL_FALSE); 
     187         
    186188 
    187189        glPushAttrib(GL_VIEWPORT_BIT); 
     
    203205 
    204206        glEnable(GL_LIGHTING); 
    205         glDisable(GL_TEXTURE_2D); 
     207        glEnable(GL_TEXTURE_2D); 
     208        glDepthMask(GL_TRUE); 
    206209         
    207210        glMatrixMode(GL_PROJECTION); 
     
    332335        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    333336        GLuint shadowMap = shadowMapping->mFbo->GetDepthTex(); 
    334  
     337/* 
    335338        static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.0f, 
    336339                                                                0.0f, 0.5f, 0.0f, 0.0f, 
    337340                                                                0.0f, 0.0f, 0.5f, 0.0f, 
    338341                                                                0.5f, 0.5f, 0.5f, 1.0f); //bias from [-1, 1] to [0, 1] 
     342*/ 
     343         
     344static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.5f, 
     345                                                                0.0f, 0.5f, 0.0f, 0.5f, 
     346                                                                0.0f, 0.0f, 0.5f, 0.5f, 
     347                                                                0.0f, 0.0f, 0.0f, 1.0f); //bias from [-1, 1] to [0, 1] 
    339348 
    340349        Matrix4x4 inverseView = matViewing; 
     
    345354        //cout << "matview:\n" << matViewing << endl; 
    346355        //cout << "proj:\n" <<  shadowMapping->mLightProjectionMatrix << endl; 
    347         //cout << "view:\n" <<  shadowMapping->mLightViewMatrix << endl; 
     356        cout << "view:\n" <<  shadowMapping->mLightViewMatrix << endl; 
    348357 
    349358        // compute combined matrix that transforms pixels into light texture space 
     
    353362                                                         inverseView; 
    354363*/ 
    355         Matrix4x4 shadowMatrix = //inverseView *  
    356                                                          lightProjView *  
    357                                                          biasMatrix; 
    358 /* 
    359 Matrix4x4 shadowMatrix = biasMatrix *  
    360                                                          lightProjView;  
     364        //Matrix4x4 shadowMatrix = //inverseView * lightProjView * biasMatrix;* 
     365        Matrix4x4 shadowMatrix = lightProjView*biasMatrix;  
    361366                                                         //inverseView; 
    362 */ 
    363367                                                         cout << "combined:\n" <<  shadowMatrix << endl; 
    364368 
     
    384388        cgGLSetTextureParameter(sShadowMapParam, shadowMap); 
    385389        cgGLEnableTextureParameter(sShadowMapParam); 
     390 
     391        cgGLSetParameter1f(sMaxDepthParam, mScaleFactor); 
    386392 
    387393        cgGLSetMatrixParameterfc(sShadowMatrixParam, (const float *)shadowMatrix.x); 
Note: See TracChangeset for help on using the changeset viewer.