Ticket #504: shadow_culling_frustum_adjust.patch

File shadow_culling_frustum_adjust.patch, 1.8 KB (added by Xin, 14 years ago)

Patch for culling frustum widening.

  • GameView.cpp

     
    7070const float CGameView::defaultFOV = DEGTORAD(20.f);
    7171const float CGameView::defaultNear = 4.f;
    7272const float CGameView::defaultFar = 4096.f;
     73const float CGameView::defaultCullFOV = CGameView::defaultFOV + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum
    7374
    7475class CGameViewImpl : public CJSObject<CGameViewImpl>
    7576{
     
    310311
    311312        // This can be uncommented to try getting a bigger frustum..
    312313        // but then it makes shadow maps too low-detail.
    313         //m_CullCamera.SetProjection(1.0f, 10000.0f, DEGTORAD(30));
    314         //m_CullCamera.UpdateFrustum();
     314        //
     315        // Xin: I'm not sure what the previous comment is referring to with shadow maps becoming too low-detail,
     316        // but one way to fix shadows popping in at the edge of the screen is to widen the culling frustum so that
     317        // objects aren't culled as early. The downside is that objects will get rendered even though they appear
     318        // off screen, which is somewhat inefficient. A better solution would be to decouple shadow map rendering
     319        // from model rendering; as it is now, a shadow map is only rendered if its associated model is to be
     320        // rendered.
     321        m->CullCamera.SetProjection(defaultNear, defaultFar, defaultCullFOV);
     322        m->CullCamera.UpdateFrustum();
    315323    }
    316324    g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera);
    317325
  • GameView.h

     
    4242{
    4343    NONCOPYABLE(CGameView);
    4444public:
    45     static const float defaultFOV, defaultNear, defaultFar;
     45    static const float defaultFOV, defaultCullFOV, defaultNear, defaultFar;
    4646
    4747private:
    4848    CGameViewImpl* m;