mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 15:02:01 +00:00
Add class updating and managing the shadow map texture
This commit is contained in:
parent
6363c6cf58
commit
7a4b01471d
6 changed files with 91 additions and 3 deletions
|
@ -940,6 +940,7 @@ set( FASTMATH_SOURCES
|
||||||
gl/dynlights/gl_dynlight1.cpp
|
gl/dynlights/gl_dynlight1.cpp
|
||||||
gl/dynlights/gl_lightbuffer.cpp
|
gl/dynlights/gl_lightbuffer.cpp
|
||||||
gl/dynlights/gl_lightbsp.cpp
|
gl/dynlights/gl_lightbsp.cpp
|
||||||
|
gl/dynlights/gl_shadowmap.cpp
|
||||||
gl/shaders/gl_shader.cpp
|
gl/shaders/gl_shader.cpp
|
||||||
gl/shaders/gl_texshader.cpp
|
gl/shaders/gl_texshader.cpp
|
||||||
gl/shaders/gl_shaderprogram.cpp
|
gl/shaders/gl_shaderprogram.cpp
|
||||||
|
|
65
src/gl/dynlights/gl_shadowmap.cpp
Normal file
65
src/gl/dynlights/gl_shadowmap.cpp
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
//
|
||||||
|
//---------------------------------------------------------------------------
|
||||||
|
// 1D dynamic shadow maps
|
||||||
|
// 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/system/gl_system.h"
|
||||||
|
#include "gl/shaders/gl_shader.h"
|
||||||
|
#include "gl/dynlights/gl_shadowmap.h"
|
||||||
|
#include "gl/dynlights/gl_dynlight.h"
|
||||||
|
#include "gl/system/gl_interface.h"
|
||||||
|
#include "gl/system/gl_debug.h"
|
||||||
|
#include "gl/renderer/gl_renderer.h"
|
||||||
|
#include "gl/renderer/gl_postprocessstate.h"
|
||||||
|
#include "gl/shaders/gl_shadowmapshader.h"
|
||||||
|
#include "r_state.h"
|
||||||
|
|
||||||
|
void FShadowMap::Clear()
|
||||||
|
{
|
||||||
|
mLightBSP.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FShadowMap::Update()
|
||||||
|
{
|
||||||
|
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
ADynamicLight *light = it.Next();
|
||||||
|
if (!light) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
FGLDebug::PushGroup("ShadowMap");
|
||||||
|
FGLPostProcessState savedState;
|
||||||
|
|
||||||
|
GLRenderer->mShadowMapShader->Bind();
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, mLightBSP.GetNodesBuffer());
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, mLightBSP.GetSegsBuffer());
|
||||||
|
|
||||||
|
glViewport(0, 0, 1024, 1024);
|
||||||
|
GLRenderer->RenderScreenQuad();
|
||||||
|
|
||||||
|
const auto &viewport = GLRenderer->mScreenViewport;
|
||||||
|
glViewport(viewport.left, viewport.top, viewport.width, viewport.height);
|
||||||
|
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, 0);
|
||||||
|
glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, 0);
|
||||||
|
|
||||||
|
FGLDebug::PopGroup();
|
||||||
|
}
|
20
src/gl/dynlights/gl_shadowmap.h
Normal file
20
src/gl/dynlights/gl_shadowmap.h
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "gl/dynlights/gl_lightbsp.h"
|
||||||
|
|
||||||
|
class FShadowMap
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FShadowMap() { }
|
||||||
|
~FShadowMap() { Clear(); }
|
||||||
|
|
||||||
|
void Clear();
|
||||||
|
void Update();
|
||||||
|
|
||||||
|
private:
|
||||||
|
FLightBSP mLightBSP;
|
||||||
|
|
||||||
|
FShadowMap(const FShadowMap &) = delete;
|
||||||
|
FShadowMap &operator=(FShadowMap &) = delete;
|
||||||
|
};
|
|
@ -6,7 +6,7 @@
|
||||||
#include "vectors.h"
|
#include "vectors.h"
|
||||||
#include "r_renderer.h"
|
#include "r_renderer.h"
|
||||||
#include "gl/data/gl_matrix.h"
|
#include "gl/data/gl_matrix.h"
|
||||||
#include "gl/dynlights/gl_lightbsp.h"
|
#include "gl/dynlights/gl_shadowmap.h"
|
||||||
|
|
||||||
struct particle_t;
|
struct particle_t;
|
||||||
class FCanvasTexture;
|
class FCanvasTexture;
|
||||||
|
@ -126,7 +126,7 @@ public:
|
||||||
FPresent3DRowShader *mPresent3dRowShader;
|
FPresent3DRowShader *mPresent3dRowShader;
|
||||||
FShadowMapShader *mShadowMapShader;
|
FShadowMapShader *mShadowMapShader;
|
||||||
|
|
||||||
FLightBSP mLightBSP;
|
FShadowMap mShadowMap;
|
||||||
|
|
||||||
FTexture *gllight;
|
FTexture *gllight;
|
||||||
FTexture *glpart2;
|
FTexture *glpart2;
|
||||||
|
|
|
@ -950,6 +950,8 @@ void FGLRenderer::RenderView (player_t* player)
|
||||||
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
TThinkerIterator<ADynamicLight> it(STAT_DLIGHT);
|
||||||
GLRenderer->mLightCount = ((it.Next()) != NULL);
|
GLRenderer->mLightCount = ((it.Next()) != NULL);
|
||||||
|
|
||||||
|
GLRenderer->mShadowMap.Update();
|
||||||
|
|
||||||
sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView.Degrees, ratio, fovratio, true, true);
|
sector_t * viewsector = RenderViewpoint(player->camera, NULL, FieldOfView.Degrees, ratio, fovratio, true, true);
|
||||||
|
|
||||||
All.Unclock();
|
All.Unclock();
|
||||||
|
|
|
@ -112,5 +112,5 @@ float rayTest(vec2 from, vec2 to)
|
||||||
|
|
||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
FragColor = vec4(rayTest(vec2(0.0, 0.0), vec2(1.0, 1.0));
|
FragColor = vec4(rayTest(vec2(0.0, 0.0), vec2(1.0, 1.0)));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue