]> git.lizzy.rs Git - minetest.git/blob - src/client/shadows/shadowsshadercallbacks.h
8x block meshes (#13133)
[minetest.git] / src / client / shadows / shadowsshadercallbacks.h
1 /*
2 Minetest
3 Copyright (C) 2021 Liso <anlismon@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #pragma once
21 #include "irrlichttypes_extrabloated.h"
22 #include <IMaterialRendererServices.h>
23 #include <IShaderConstantSetCallBack.h>
24 #include "client/shader.h"
25
26 class ShadowDepthShaderCB : public video::IShaderConstantSetCallBack
27 {
28 public:
29         ShadowDepthShaderCB() :
30                         m_light_mvp_setting("LightMVP"),
31                         m_map_resolution_setting("MapResolution"),
32                         m_max_far_setting("MaxFar"),
33                         m_color_map_sampler_setting("ColorMapSampler"),
34                         m_perspective_bias0("xyPerspectiveBias0"),
35                         m_perspective_bias1("xyPerspectiveBias1"),
36                         m_perspective_zbias("zPerspectiveBias"),
37                         m_cam_pos_setting("CameraPos")
38         {}
39
40         void OnSetMaterial(const video::SMaterial &material) override {}
41
42         void OnSetConstants(video::IMaterialRendererServices *services,
43                         s32 userData) override;
44
45         f32 MaxFar{2048.0f}, MapRes{1024.0f};
46         f32 PerspectiveBiasXY {0.9f}, PerspectiveBiasZ {0.5f};
47         v3f CameraPos;
48
49 private:
50         CachedVertexShaderSetting<f32, 16> m_light_mvp_setting;
51         CachedVertexShaderSetting<f32> m_map_resolution_setting;
52         CachedVertexShaderSetting<f32> m_max_far_setting;
53         CachedPixelShaderSetting<s32> m_color_map_sampler_setting;
54         CachedVertexShaderSetting<f32> m_perspective_bias0;
55         CachedVertexShaderSetting<f32> m_perspective_bias1;
56         CachedVertexShaderSetting<f32> m_perspective_zbias;
57         CachedVertexShaderSetting<f32, 4> m_cam_pos_setting;
58 };