diff options
author | Liso <anlismon@gmail.com> | 2021-06-06 18:51:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-06 18:51:21 +0200 |
commit | c47313db65f968559711ac1b505ef341a9872017 (patch) | |
tree | 63d9b1b2be512918e2361d96e4fb52ff1ec3f9de /src/client/render | |
parent | 46f42e15c41cf4ab23c5ff4cd8a7d99d94d10d7b (diff) | |
download | minetest-c47313db65f968559711ac1b505ef341a9872017.tar.gz minetest-c47313db65f968559711ac1b505ef341a9872017.tar.bz2 minetest-c47313db65f968559711ac1b505ef341a9872017.zip |
Shadow mapping render pass (#11244)
Co-authored-by: x2048 <codeforsmile@gmail.com>
Diffstat (limited to 'src/client/render')
-rw-r--r-- | src/client/render/core.cpp | 21 | ||||
-rw-r--r-- | src/client/render/core.h | 5 |
2 files changed, 24 insertions, 2 deletions
diff --git a/src/client/render/core.cpp b/src/client/render/core.cpp index 3c4583623..4a820f583 100644 --- a/src/client/render/core.cpp +++ b/src/client/render/core.cpp @@ -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; diff --git a/src/client/render/core.h b/src/client/render/core.h index 52ea8f99f..cabfbbfad 100644 --- a/src/client/render/core.h +++ b/src/client/render/core.h @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #pragma once #include "irrlichttypes_extrabloated.h" +class ShadowRenderer; class Camera; class Client; class Hud; @@ -47,6 +48,8 @@ protected: Minimap *mapper; Hud *hud; + ShadowRenderer *shadow_renderer; + void updateScreenSize(); virtual void initTextures() {} virtual void clearTextures() {} @@ -72,4 +75,6 @@ public: bool _draw_wield_tool, bool _draw_crosshair); inline v2u32 getVirtualSize() const { return virtual_size; } + + ShadowRenderer *get_shadow_renderer() { return shadow_renderer; }; }; |