1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Shadow mapping render pass (#11244)

Co-authored-by: x2048 <codeforsmile@gmail.com>
This commit is contained in:
Liso 2021-06-06 18:51:21 +02:00 committed by GitHub
parent 46f42e15c4
commit c47313db65
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
35 changed files with 2624 additions and 38 deletions

View file

@ -24,25 +24,35 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "client/clientmap.h"
#include "client/hud.h"
#include "client/minimap.h"
#include "client/shadows/dynamicshadowsrender.h"
RenderingCore::RenderingCore(IrrlichtDevice *_device, Client *_client, Hud *_hud)
: device(_device), driver(device->getVideoDriver()), smgr(device->getSceneManager()),
guienv(device->getGUIEnvironment()), client(_client), camera(client->getCamera()),
mapper(client->getMinimap()), hud(_hud)
mapper(client->getMinimap()), hud(_hud),
shadow_renderer(nullptr)
{
screensize = driver->getScreenSize();
virtual_size = screensize;
if (g_settings->getBool("enable_shaders") &&
g_settings->getBool("enable_dynamic_shadows")) {
shadow_renderer = new ShadowRenderer(device, client);
}
}
RenderingCore::~RenderingCore()
{
clearTextures();
delete shadow_renderer;
}
void RenderingCore::initialize()
{
// have to be called late as the VMT is not ready in the constructor:
initTextures();
if (shadow_renderer)
shadow_renderer->initialize();
}
void RenderingCore::updateScreenSize()
@ -72,7 +82,14 @@ void RenderingCore::draw(video::SColor _skycolor, bool _show_hud, bool _show_min
void RenderingCore::draw3D()
{
smgr->drawAll();
if (shadow_renderer) {
// Shadow renderer will handle the draw stage
shadow_renderer->setClearColor(skycolor);
shadow_renderer->update();
} else {
smgr->drawAll();
}
driver->setTransform(video::ETS_WORLD, core::IdentityMatrix);
if (!show_hud)
return;