1
1
forked from 0ad/0ad

Expand the culling frustum to reduce shadow popping (see #504). Based on patch from Zoomastigophora.

This was SVN commit r7562.
This commit is contained in:
Ykkrosh 2010-05-21 18:31:47 +00:00
parent 2f421082cd
commit 1fc75e7605
2 changed files with 11 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2009 Wildfire Games. /* Copyright (C) 2010 Wildfire Games.
* This file is part of 0 A.D. * This file is part of 0 A.D.
* *
* 0 A.D. is free software: you can redistribute it and/or modify * 0 A.D. is free software: you can redistribute it and/or modify
@ -67,6 +67,7 @@ static i8 currentBookmark = -1;
const float CGameView::defaultFOV = DEGTORAD(20.f); const float CGameView::defaultFOV = DEGTORAD(20.f);
const float CGameView::defaultNear = 4.f; const float CGameView::defaultNear = 4.f;
const float CGameView::defaultFar = 4096.f; const float CGameView::defaultFar = 4096.f;
const float CGameView::defaultCullFOV = CGameView::defaultFOV + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum
class CGameViewImpl : public CJSObject<CGameViewImpl> class CGameViewImpl : public CJSObject<CGameViewImpl>
{ {
@ -280,10 +281,14 @@ void CGameView::Render()
// Set up cull camera // Set up cull camera
m->CullCamera = m->ViewCamera; m->CullCamera = m->ViewCamera;
// This can be uncommented to try getting a bigger frustum.. // One way to fix shadows popping in at the edge of the screen is to widen the culling frustum so that
// but then it makes shadow maps too low-detail. // objects aren't culled as early. The downside is that objects will get rendered even though they appear
//m_CullCamera.SetProjection(1.0f, 10000.0f, DEGTORAD(30)); // off screen, which is somewhat inefficient. A better solution would be to decouple shadow map rendering
//m_CullCamera.UpdateFrustum(); // from model rendering; as it is now, a shadow map is only rendered if its associated model is to be
// rendered.
// (See http://trac.wildfiregames.com/ticket/504)
m->CullCamera.SetProjection(defaultNear, defaultFar, defaultCullFOV);
m->CullCamera.UpdateFrustum();
} }
g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera); g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera);

View File

@ -41,7 +41,7 @@ class CGameView : private Scene
{ {
NONCOPYABLE(CGameView); NONCOPYABLE(CGameView);
public: public:
static const float defaultFOV, defaultNear, defaultFar; static const float defaultFOV, defaultCullFOV, defaultNear, defaultFar;
private: private:
CGameViewImpl* m; CGameViewImpl* m;