mirror of
https://github.com/ValveSoftware/source-sdk-2013.git
synced 2025-04-08 11:01:33 +00:00
Create a shadow map depth texture greater than the framebuffer size
This commit is contained in:
parent
94a6551038
commit
f44cc37c94
6 changed files with 46 additions and 6 deletions
|
@ -18,7 +18,7 @@
|
|||
#include "tier0/memdbgon.h"
|
||||
|
||||
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
|
||||
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT );
|
||||
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.00001", FCVAR_CHEAT );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
|
|
|
@ -1336,6 +1336,13 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||
{
|
||||
VPROF_BUDGET( "CClientShadowMgr::InitDepthTextureShadows", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
||||
|
||||
// SAUL: start benchmark timer
|
||||
CFastTimer timer;
|
||||
timer.Start();
|
||||
|
||||
// SAUL: set m_nDepthTextureResolution to the depth resolution we want
|
||||
m_nDepthTextureResolution = r_flashlightdepthres.GetInt();
|
||||
|
||||
if( !m_bDepthTextureActive )
|
||||
{
|
||||
m_bDepthTextureActive = true;
|
||||
|
@ -1352,7 +1359,8 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||
m_DummyColorTexture.InitRenderTargetTexture( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, IMAGE_FORMAT_BGR565, MATERIAL_RT_DEPTH_SHARED, false, "_rt_ShadowDummy" );
|
||||
m_DummyColorTexture.InitRenderTargetSurface( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), IMAGE_FORMAT_BGR565, true );
|
||||
#else
|
||||
m_DummyColorTexture.InitRenderTarget( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" );
|
||||
// SAUL: we want to create a render target of specific size, so use RT_SIZE_NO_CHANGE
|
||||
m_DummyColorTexture.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_NO_CHANGE, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" );
|
||||
#endif
|
||||
|
||||
// Create some number of depth-stencil textures
|
||||
|
@ -1372,9 +1380,13 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||
depthTex.InitRenderTargetTexture( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
||||
depthTex.InitRenderTargetSurface( 1, 1, dstFormat, false );
|
||||
#else
|
||||
depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
||||
// SAUL: we want to create a *DEPTH TEXTURE* of specific size, so use RT_SIZE_NO_CHANGE and MATERIAL_RT_DEPTH_ONLY
|
||||
depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_NO_CHANGE, dstFormat, MATERIAL_RT_DEPTH_ONLY, false, strRTName );
|
||||
#endif
|
||||
|
||||
// SAUL: ensure the depth texture size wasn't changed
|
||||
Assert(depthTex->GetActualWidth() == m_nDepthTextureResolution);
|
||||
|
||||
if ( i == 0 )
|
||||
{
|
||||
// Shadow may be resized during allocation (due to resolution constraints etc)
|
||||
|
@ -1388,6 +1400,9 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||
|
||||
materials->EndRenderTargetAllocation();
|
||||
}
|
||||
|
||||
timer.End();
|
||||
DevMsg("InitDepthTextureShadows took %.2f msec\n", timer.GetDuration().GetMillisecondsF());
|
||||
}
|
||||
|
||||
void CClientShadowMgr::ShutdownDepthTextureShadows()
|
||||
|
|
|
@ -4983,6 +4983,10 @@ void CShadowDepthView::Draw()
|
|||
render->Push3DView( (*this), VIEW_CLEAR_DEPTH, m_pRenderTarget, GetFrustum() );
|
||||
}
|
||||
|
||||
pRenderContext.GetFrom(materials);
|
||||
pRenderContext->PushRenderTargetAndViewport(m_pRenderTarget, m_pDepthTexture, 0, 0, m_pDepthTexture->GetMappingWidth(), m_pDepthTexture->GetMappingWidth());
|
||||
pRenderContext.SafeRelease();
|
||||
|
||||
SetupCurrentView( origin, angles, VIEW_SHADOW_DEPTH_TEXTURE );
|
||||
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
|
@ -5027,6 +5031,7 @@ void CShadowDepthView::Draw()
|
|||
pRenderContext->CopyRenderTargetToTextureEx( m_pDepthTexture, -1, NULL, NULL );
|
||||
}
|
||||
|
||||
pRenderContext->PopRenderTargetAndViewport();
|
||||
render->PopView( GetFrustum() );
|
||||
|
||||
#if defined( _X360 )
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
#include "tier0/memdbgon.h"
|
||||
|
||||
static ConVar mat_slopescaledepthbias_shadowmap( "mat_slopescaledepthbias_shadowmap", "16", FCVAR_CHEAT );
|
||||
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.0005", FCVAR_CHEAT );
|
||||
static ConVar mat_depthbias_shadowmap( "mat_depthbias_shadowmap", "0.00001", FCVAR_CHEAT );
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
|
|
|
@ -1336,6 +1336,13 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||
{
|
||||
VPROF_BUDGET( "CClientShadowMgr::InitDepthTextureShadows", VPROF_BUDGETGROUP_SHADOW_DEPTH_TEXTURING );
|
||||
|
||||
// SAUL: start benchmark timer
|
||||
CFastTimer timer;
|
||||
timer.Start();
|
||||
|
||||
// SAUL: set m_nDepthTextureResolution to the depth resolution we want
|
||||
m_nDepthTextureResolution = r_flashlightdepthres.GetInt();
|
||||
|
||||
if( !m_bDepthTextureActive )
|
||||
{
|
||||
m_bDepthTextureActive = true;
|
||||
|
@ -1352,7 +1359,8 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||
m_DummyColorTexture.InitRenderTargetTexture( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, IMAGE_FORMAT_BGR565, MATERIAL_RT_DEPTH_SHARED, false, "_rt_ShadowDummy" );
|
||||
m_DummyColorTexture.InitRenderTargetSurface( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), IMAGE_FORMAT_BGR565, true );
|
||||
#else
|
||||
m_DummyColorTexture.InitRenderTarget( r_flashlightdepthres.GetInt(), r_flashlightdepthres.GetInt(), RT_SIZE_OFFSCREEN, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" );
|
||||
// SAUL: we want to create a render target of specific size, so use RT_SIZE_NO_CHANGE
|
||||
m_DummyColorTexture.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_NO_CHANGE, nullFormat, MATERIAL_RT_DEPTH_NONE, false, "_rt_ShadowDummy" );
|
||||
#endif
|
||||
|
||||
// Create some number of depth-stencil textures
|
||||
|
@ -1372,9 +1380,13 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||
depthTex.InitRenderTargetTexture( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
||||
depthTex.InitRenderTargetSurface( 1, 1, dstFormat, false );
|
||||
#else
|
||||
depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_OFFSCREEN, dstFormat, MATERIAL_RT_DEPTH_NONE, false, strRTName );
|
||||
// SAUL: we want to create a *DEPTH TEXTURE* of specific size, so use RT_SIZE_NO_CHANGE and MATERIAL_RT_DEPTH_ONLY
|
||||
depthTex.InitRenderTarget( m_nDepthTextureResolution, m_nDepthTextureResolution, RT_SIZE_NO_CHANGE, dstFormat, MATERIAL_RT_DEPTH_ONLY, false, strRTName );
|
||||
#endif
|
||||
|
||||
// SAUL: ensure the depth texture size wasn't changed
|
||||
Assert(depthTex->GetActualWidth() == m_nDepthTextureResolution);
|
||||
|
||||
if ( i == 0 )
|
||||
{
|
||||
// Shadow may be resized during allocation (due to resolution constraints etc)
|
||||
|
@ -1388,6 +1400,9 @@ void CClientShadowMgr::InitDepthTextureShadows()
|
|||
|
||||
materials->EndRenderTargetAllocation();
|
||||
}
|
||||
|
||||
timer.End();
|
||||
DevMsg("InitDepthTextureShadows took %.2f msec\n", timer.GetDuration().GetMillisecondsF());
|
||||
}
|
||||
|
||||
void CClientShadowMgr::ShutdownDepthTextureShadows()
|
||||
|
|
|
@ -4997,6 +4997,10 @@ void CShadowDepthView::Draw()
|
|||
render->Push3DView( (*this), VIEW_CLEAR_DEPTH, m_pRenderTarget, GetFrustum() );
|
||||
}
|
||||
|
||||
pRenderContext.GetFrom(materials);
|
||||
pRenderContext->PushRenderTargetAndViewport(m_pRenderTarget, m_pDepthTexture, 0, 0, m_pDepthTexture->GetMappingWidth(), m_pDepthTexture->GetMappingWidth());
|
||||
pRenderContext.SafeRelease();
|
||||
|
||||
SetupCurrentView( origin, angles, VIEW_SHADOW_DEPTH_TEXTURE );
|
||||
|
||||
MDLCACHE_CRITICAL_SECTION();
|
||||
|
@ -5041,6 +5045,7 @@ void CShadowDepthView::Draw()
|
|||
pRenderContext->CopyRenderTargetToTextureEx( m_pDepthTexture, -1, NULL, NULL );
|
||||
}
|
||||
|
||||
pRenderContext->PopRenderTargetAndViewport();
|
||||
render->PopView( GetFrustum() );
|
||||
|
||||
#if defined( _X360 )
|
||||
|
|
Loading…
Reference in a new issue