Ignore:
Timestamp:
09/02/08 09:07:45 (16 years ago)
Author:
mattausch
Message:

shadow mapping almost working (but ulgy!!)

File:
1 edited

Legend:

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

    r2893 r2894  
    176176 
    177177void DeferredShader::Render(FrameBufferObject *fbo,  
    178                                                         const Matrix4x4 &matViewing,  
    179                                                         ShadowMapping *shadowMapping) 
     178                                                        ShadowMap *shadowMap) 
    180179{ 
    181180        cgGLEnableProfile(RenderState::sCgFragmentProfile); 
     
    201200        glOrtho(-offs, offs, -offs, offs, 0, 1); 
    202201 
    203         FirstPassShadow(fbo, matViewing, shadowMapping); 
     202        FirstPassShadow(fbo, shadowMap); 
    204203        AntiAliasing(fbo); 
    205204 
     
    328327 
    329328void DeferredShader::FirstPassShadow(FrameBufferObject *fbo,  
    330                                                                          const Matrix4x4 &matViewing,  
    331                                                                          ShadowMapping *shadowMapping) 
     329                                                                         ShadowMap *shadowMap) 
    332330{ 
    333331        GLuint colorsTex = fbo->GetColorBuffer(0)->GetTexture(); 
    334332        GLuint positionsTex = fbo->GetColorBuffer(1)->GetTexture(); 
    335333        GLuint normalsTex = fbo->GetColorBuffer(2)->GetTexture(); 
    336         GLuint shadowMap = shadowMapping->mFbo->GetDepthTex(); 
    337 /* 
    338         static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.0f, 
    339                                                                 0.0f, 0.5f, 0.0f, 0.0f, 
    340                                                                 0.0f, 0.0f, 0.5f, 0.0f, 
    341                                                                 0.5f, 0.5f, 0.5f, 1.0f); //bias from [-1, 1] to [0, 1] 
    342 */ 
    343          
    344 static 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] 
    348  
    349         Matrix4x4 inverseView = matViewing; 
    350         inverseView.Invert(); 
    351  
    352         Matrix4x4 lightProjView = shadowMapping->mLightViewMatrix * shadowMapping->mLightProjectionMatrix; 
    353  
    354         //cout << "matview:\n" << matViewing << endl; 
    355         //cout << "proj:\n" <<  shadowMapping->mLightProjectionMatrix << endl; 
    356         cout << "view:\n" <<  shadowMapping->mLightViewMatrix << endl; 
    357  
    358         // compute combined matrix that transforms pixels into light texture space 
    359         /*Matrix4x4 shadowMatrix = biasMatrix *  
    360                                                          shadowMapping->mLightProjectionMatrix *  
    361                                                          shadowMapping->mLightViewMatrix * 
    362                                                          inverseView; 
    363 */ 
    364         //Matrix4x4 shadowMatrix = //inverseView * lightProjView * biasMatrix;* 
    365         Matrix4x4 shadowMatrix = lightProjView*biasMatrix;  
    366                                                          //inverseView; 
    367                                                          cout << "combined:\n" <<  shadowMatrix << endl; 
     334        GLuint shadowTex = shadowMap->GetShadowTexture(); 
     335 
     336        Matrix4x4 shadowMatrix; 
     337        shadowMap->GetTextureMatrix(shadowMatrix); 
    368338 
    369339        fbo->Bind(); 
     
    386356        cgGLEnableTextureParameter(sNormalsTexShadowParam); 
    387357         
    388         cgGLSetTextureParameter(sShadowMapParam, shadowMap); 
     358        cgGLSetTextureParameter(sShadowMapParam, shadowTex); 
    389359        cgGLEnableTextureParameter(sShadowMapParam); 
    390360 
Note: See TracChangeset for help on using the changeset viewer.