- moved the last remaining function from gl_shadowmap.cpp elsewhere so that the file can be deleted.

This commit is contained in:
Christoph Oelckers 2018-10-28 17:09:22 +01:00
parent 54f46fdfee
commit e6efee61b1
7 changed files with 61 additions and 98 deletions

View File

@ -700,7 +700,6 @@ file( GLOB HEADER_FILES
hwrenderer/textures/*.h
hwrenderer/utility/*.h
gl/*.h
gl/dynlights/*.h
gl/models/*.h
gl/renderer/*.h
gl/scene/*.h
@ -1037,7 +1036,6 @@ set (PCH_SOURCES
g_statusbar/sbarinfo.cpp
g_statusbar/sbar_mugshot.cpp
g_statusbar/shared_sbar.cpp
gl/dynlights/gl_shadowmap.cpp
gl/renderer/gl_renderer.cpp
gl/renderer/gl_renderstate.cpp
gl/renderer/gl_renderbuffers.cpp

View File

@ -1,69 +0,0 @@
//
//---------------------------------------------------------------------------
// 1D dynamic shadow maps (OpenGL dependent part)
// Copyright(C) 2017 Magnus Norddahl
// All rights reserved.
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with this program. If not, see http://www.gnu.org/licenses/
//
//--------------------------------------------------------------------------
//
#include "gl_load/gl_system.h"
#include "gl/shaders/gl_shader.h"
#include "gl/dynlights/gl_shadowmap.h"
#include "gl/system/gl_debug.h"
#include "hwrenderer/utility/hw_cvars.h"
#include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_postprocessstate.h"
#include "gl/renderer/gl_renderbuffers.h"
#include "hwrenderer/postprocessing/hw_shadowmapshader.h"
#include "hwrenderer/dynlights/hw_dynlightdata.h"
#include "stats.h"
void FShadowMap::Update()
{
UpdateCycles.Reset();
LightsProcessed = 0;
LightsShadowmapped = 0;
if (!IsEnabled())
return;
UpdateCycles.Clock();
PerformUpdate();
FGLDebug::PushGroup("ShadowMap");
FGLPostProcessState savedState;
GLRenderer->mBuffers->BindShadowMapFB();
GLRenderer->mShadowMapShader->Bind(NOQUEUE);
GLRenderer->mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
GLRenderer->mShadowMapShader->Uniforms.Set();
glViewport(0, 0, gl_shadowmap_quality, 1024);
GLRenderer->RenderScreenQuad();
const auto &viewport = screen->mScreenViewport;
glViewport(viewport.left, viewport.top, viewport.width, viewport.height);
GLRenderer->mBuffers->BindShadowMapTexture(16);
FGLDebug::PopGroup();
UpdateCycles.Unclock();
}

View File

@ -1,13 +0,0 @@
#pragma once
#include "hwrenderer/dynlights/hw_shadowmap.h"
class IDataBuffer;
class FShadowMap : public IShadowMap
{
public:
// Update shadow map texture
void Update() override;
};

View File

@ -60,6 +60,7 @@
#include "hwrenderer/data/hw_viewpointbuffer.h"
#include "r_videoscale.h"
#include "r_data/models/models.h"
#include "gl/renderer/gl_postprocessstate.h"
EXTERN_CVAR(Int, screenblocks)
EXTERN_CVAR(Bool, cl_capfps)
@ -177,6 +178,38 @@ void FGLRenderer::EndOffscreen()
glBindFramebuffer(GL_FRAMEBUFFER, mOldFBID);
}
//===========================================================================
//
//
//
//===========================================================================
void FGLRenderer::UpdateShadowMap()
{
if (mShadowMap.PerformUpdate())
{
FGLDebug::PushGroup("ShadowMap");
FGLPostProcessState savedState;
mBuffers->BindShadowMapFB();
mShadowMapShader->Bind(NOQUEUE);
mShadowMapShader->Uniforms->ShadowmapQuality = gl_shadowmap_quality;
mShadowMapShader->Uniforms.Set();
glViewport(0, 0, gl_shadowmap_quality, 1024);
RenderScreenQuad();
const auto &viewport = screen->mScreenViewport;
glViewport(viewport.left, viewport.top, viewport.width, viewport.height);
mBuffers->BindShadowMapTexture(16);
FGLDebug::PopGroup();
mShadowMap.FinishUpdate();
}
}
//-----------------------------------------------------------------------------
//
// renders the view
@ -230,7 +263,7 @@ sector_t *FGLRenderer::RenderView(player_t* player)
fovratio = ratio;
}
mShadowMap.Update();
UpdateShadowMap();
retsec = RenderViewpoint(r_viewpoint, player->camera, NULL, r_viewpoint.FieldOfView.Degrees, ratio, fovratio, true, true);
}
All.Unclock();

View File

@ -7,7 +7,7 @@
#include "r_renderer.h"
#include "r_data/matrix.h"
#include "hwrenderer/scene/hw_portal.h"
#include "gl/dynlights/gl_shadowmap.h"
#include "hwrenderer/dynlights/hw_shadowmap.h"
#include <functional>
#ifdef _MSC_VER
@ -65,7 +65,7 @@ public:
FShadowMapShader *mShadowMapShader = nullptr;
FCustomPostProcessShaders *mCustomPostProcessShaders = nullptr;
FShadowMap mShadowMap;
IShadowMap mShadowMap;
//FRotator mAngles;
@ -103,6 +103,7 @@ public:
bool StartOffscreen();
void EndOffscreen();
void UpdateShadowMap();
void BindToFrameBuffer(FMaterial *mat);
};

View File

@ -162,13 +162,24 @@ bool IShadowMap::ValidateAABBTree()
return false;
}
void IShadowMap::PerformUpdate()
bool IShadowMap::PerformUpdate()
{
UploadAABBTree();
UploadLights();
mLightList->BindBase();
mNodesBuffer->BindBase();
mLinesBuffer->BindBase();
UpdateCycles.Reset();
LightsProcessed = 0;
LightsShadowmapped = 0;
if (IsEnabled())
{
UpdateCycles.Clock();
UploadAABBTree();
UploadLights();
mLightList->BindBase();
mNodesBuffer->BindBase();
mLinesBuffer->BindBase();
return true;
}
return false;
}
void IShadowMap::UploadLights()

View File

@ -15,9 +15,6 @@ public:
IShadowMap() { }
virtual ~IShadowMap();
// Update shadow map texture
virtual void Update() = 0;
// Test if a world position is in shadow relative to the specified light and returns false if it is
bool ShadowTest(ADynamicLight *light, const DVector3 &pos);
@ -27,11 +24,16 @@ public:
static cycle_t UpdateCycles;
static int LightsProcessed;
static int LightsShadowmapped;
bool PerformUpdate();
void FinishUpdate()
{
UpdateCycles.Clock();
}
protected:
void CollectLights();
bool ValidateAABBTree();
void PerformUpdate();
// Upload the AABB-tree to the GPU
void UploadAABBTree();