Luanti 5.11.0-dev
 
Loading...
Searching...
No Matches
dynamicshadows.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2021 Liso <anlismon@gmail.com>
4
5#pragma once
6
8#include <matrix4.h>
9#include "util/basic_macros.h"
10#include "constants.h"
11
12class Camera;
13class Client;
14
16{
17 f32 zNear{0.0f};
18 f32 zFar{0.0f};
19 f32 length{0.0f};
20 f32 radius{0.0f};
21 core::matrix4 ProjOrthMat;
22 core::matrix4 ViewMat;
26};
27
29{
30public:
31 DirectionalLight(const u32 shadowMapResolution,
32 const v3f &position,
33 video::SColorf lightColor = video::SColor(0xffffffff),
34 f32 farValue = 100.0f);
35 ~DirectionalLight() = default;
36
37 //DISABLE_CLASS_COPY(DirectionalLight)
38
39 void update_frustum(const Camera *cam, Client *client, bool force = false);
40
41 // when set direction is updated to negative normalized(direction)
42 void setDirection(v3f dir);
44 return direction;
45 };
46 v3f getPosition() const;
47 v3f getPlayerPos() const;
48 v3f getFuturePlayerPos() const;
49
51 const core::matrix4 &getViewMatrix() const;
52 const core::matrix4 &getProjectionMatrix() const;
53 const core::matrix4 &getFutureViewMatrix() const;
54 const core::matrix4 &getFutureProjectionMatrix() const;
55 core::matrix4 getViewProjMatrix();
56
58 f32 getMaxFarValue() const
59 {
60 return farPlane * BS;
61 }
62
64 f32 getFarValue() const
65 {
66 return shadow_frustum.zFar;
67 }
68
69
71 const video::SColorf &getLightColor() const
72 {
73 return diffuseColor;
74 }
75
77 void setLightColor(const video::SColorf &lightColor)
78 {
79 diffuseColor = lightColor;
80 }
81
83 u32 getMapResolution() const
84 {
85 return mapRes;
86 }
87
89
90 void commitFrustum();
91
92private:
93 void createSplitMatrices(const Camera *cam);
94
95 video::SColorf diffuseColor;
96
98 u32 mapRes;
99
102
105
108 bool dirty{false};
109};
static v2f dir(const v2f &pos_dist)
Definition camera.cpp:191
Definition camera.h:68
Definition client.h:105
Definition dynamicshadows.h:29
v3f getPlayerPos() const
Definition dynamicshadows.cpp:153
bool should_update_map_shadow
Definition dynamicshadows.h:88
u32 getMapResolution() const
Gets the shadow map resolution for this light.
Definition dynamicshadows.h:83
DirectionalLight(const u32 shadowMapResolution, const v3f &position, video::SColorf lightColor=video::SColor(0xffffffff), f32 farValue=100.0f)
Definition dynamicshadows.cpp:92
void commitFrustum()
Definition dynamicshadows.cpp:133
core::matrix4 getViewProjMatrix()
Definition dynamicshadows.cpp:183
void setDirection(v3f dir)
Definition dynamicshadows.cpp:142
~DirectionalLight()=default
bool dirty
Definition dynamicshadows.h:108
f32 getFarValue() const
Gets the current far value of the light.
Definition dynamicshadows.h:64
f32 getMaxFarValue() const
Gets the light's maximum far value, i.e. the shadow boundary.
Definition dynamicshadows.h:58
const core::matrix4 & getFutureViewMatrix() const
Definition dynamicshadows.cpp:173
shadowFrustum shadow_frustum
Definition dynamicshadows.h:106
v3f getPosition() const
Definition dynamicshadows.cpp:148
void createSplitMatrices(const Camera *cam)
Definition dynamicshadows.cpp:28
v3f last_look
Definition dynamicshadows.h:104
void setLightColor(const video::SColorf &lightColor)
Sets the light's color.
Definition dynamicshadows.h:77
v3f direction
Definition dynamicshadows.h:101
const core::matrix4 & getViewMatrix() const
Gets the light's matrices.
Definition dynamicshadows.cpp:163
video::SColorf diffuseColor
Definition dynamicshadows.h:95
const core::matrix4 & getProjectionMatrix() const
Definition dynamicshadows.cpp:168
v3f getFuturePlayerPos() const
Definition dynamicshadows.cpp:158
void update_frustum(const Camera *cam, Client *client, bool force=false)
Definition dynamicshadows.cpp:99
v3f last_cam_pos_world
Definition dynamicshadows.h:103
v3f pos
Definition dynamicshadows.h:100
u32 mapRes
Definition dynamicshadows.h:98
v3f getDirection() const
Definition dynamicshadows.h:43
f32 farPlane
Definition dynamicshadows.h:97
const video::SColorf & getLightColor() const
Gets the light's color.
Definition dynamicshadows.h:71
const core::matrix4 & getFutureProjectionMatrix() const
Definition dynamicshadows.cpp:178
shadowFrustum future_frustum
Definition dynamicshadows.h:107
#define BS
Definition constants.h:61
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
core::vector3df v3f
Definition irr_v3d.h:11
Definition activeobjectmgr.cpp:11
Definition dynamicshadows.h:16
f32 radius
Definition dynamicshadows.h:20
v3f position
Definition dynamicshadows.h:23
f32 zFar
Definition dynamicshadows.h:18
f32 length
Definition dynamicshadows.h:19
v3f player
Definition dynamicshadows.h:24
v3s16 camera_offset
Definition dynamicshadows.h:25
f32 zNear
Definition dynamicshadows.h:17
core::matrix4 ViewMat
Definition dynamicshadows.h:22
core::matrix4 ProjOrthMat
Definition dynamicshadows.h:21