SleakEngine
0.1.0
C++23 multi-backend game engine
Toggle main menu visibility
Loading...
Searching...
No Matches
GraphicsConfig.cpp
Go to the documentation of this file.
1
#include <
Core/GraphicsConfig.hpp
>
2
3
#include <
Lighting/DirectionalLight.hpp
>
4
5
namespace
Sleak
{
6
7
/// Builds a config with every render feature toggle set for a named quality tier.
8
GraphicsConfig
GraphicsConfig::Preset
(
GraphicsQuality
q) {
9
GraphicsConfig
cfg;
10
switch
(q) {
11
case
GraphicsQuality::Off
: {
12
cfg.
ssaoEnabled
=
false
;
13
cfg.
ssrEnabled
=
false
;
14
cfg.
bloomEnabled
=
false
;
15
cfg.
iblEnabled
=
false
;
16
cfg.
taaEnabled
=
false
;
17
cfg.
lightShaftEnabled
=
false
;
18
cfg.
shadowEnabled
=
false
;
19
cfg.
pcssEnabled
=
false
;
20
cfg.
occlusionCullingEnabled
=
false
;
21
cfg.
occlusionBufferWidth
= 160;
22
cfg.
occlusionBufferHeight
= 90;
23
break
;
24
}
25
case
GraphicsQuality::Low
: {
26
// Shadows only — no filter, no post-FX.
27
cfg.
ssaoEnabled
=
false
;
28
cfg.
ssrEnabled
=
false
;
29
cfg.
bloomEnabled
=
false
;
30
cfg.
iblEnabled
=
false
;
31
cfg.
taaEnabled
=
false
;
32
cfg.
lightShaftEnabled
=
false
;
33
cfg.
shadowEnabled
=
true
;
34
cfg.
pcssEnabled
=
false
;
35
cfg.
shadowMapResolution
= 1024;
36
cfg.
shadowFrustumSize
= 96.0f;
37
cfg.
shadowCasterDistance
= 64.0f;
38
cfg.
occlusionCullingEnabled
=
false
;
39
cfg.
occlusionBufferWidth
= 160;
40
cfg.
occlusionBufferHeight
= 90;
41
break
;
42
}
43
case
GraphicsQuality::Medium
: {
44
// Shadows + shadow filter + SSAO.
45
cfg.
ssaoEnabled
=
true
;
46
cfg.
ssrEnabled
=
false
;
47
cfg.
bloomEnabled
=
false
;
48
cfg.
iblEnabled
=
false
;
49
cfg.
taaEnabled
=
false
;
50
cfg.
lightShaftEnabled
=
false
;
51
cfg.
shadowEnabled
=
true
;
52
cfg.
pcssEnabled
=
true
;
53
cfg.
occlusionCullingEnabled
=
true
;
54
cfg.
occlusionBufferWidth
= 256;
55
cfg.
occlusionBufferHeight
= 144;
56
break
;
57
}
58
case
GraphicsQuality::High
: {
59
// Shadows + SSAO + SSR + bloom + IBL + light shafts.
60
cfg.
ssaoEnabled
=
true
;
61
cfg.
ssrEnabled
=
true
;
62
cfg.
bloomEnabled
=
true
;
63
cfg.
iblEnabled
=
true
;
64
cfg.
taaEnabled
=
false
;
65
cfg.
lightShaftEnabled
=
true
;
66
cfg.
shadowEnabled
=
true
;
67
cfg.
pcssEnabled
=
true
;
68
cfg.
occlusionCullingEnabled
=
true
;
69
cfg.
occlusionBufferWidth
= 256;
70
cfg.
occlusionBufferHeight
= 144;
71
break
;
72
}
73
case
GraphicsQuality::Ultra
: {
74
// High + larger shadow range + TAA.
75
cfg.
ssaoEnabled
=
true
;
76
cfg.
ssrEnabled
=
true
;
77
cfg.
bloomEnabled
=
true
;
78
cfg.
iblEnabled
=
true
;
79
cfg.
taaEnabled
=
true
;
80
cfg.
lightShaftEnabled
=
true
;
81
cfg.
shadowEnabled
=
true
;
82
cfg.
pcssEnabled
=
true
;
83
cfg.
shadowMapResolution
= 3072;
84
cfg.
shadowDistance
= 256.0f;
85
cfg.
shadowFrustumSize
= 160.0f;
86
cfg.
shadowCasterDistance
= 160.0f;
87
cfg.
occlusionCullingEnabled
=
true
;
88
cfg.
occlusionBufferWidth
= 320;
89
cfg.
occlusionBufferHeight
= 180;
90
cfg.
maxOccluders
= 256;
91
break
;
92
}
93
}
94
return
cfg;
95
}
96
97
/// Pushes this config's shadow settings onto a directional light.
98
void
GraphicsConfig::ApplyShadows
(
Sleak::DirectionalLight
& light)
const
{
99
light.
SetCastShadows
(
shadowEnabled
);
100
light.
SetShadowFrustumSize
(
shadowFrustumSize
);
101
light.
SetShadowDistance
(
shadowDistance
);
102
light.
SetShadowBias
(
shadowBias
);
103
light.
SetShadowStrength
(
shadowStrength
);
104
}
105
106
}
// namespace Sleak
DirectionalLight.hpp
GraphicsConfig.hpp
Sleak::DirectionalLight
Definition
DirectionalLight.hpp:51
Sleak::DirectionalLight::SetShadowFrustumSize
void SetShadowFrustumSize(float size)
Definition
DirectionalLight.hpp:66
Sleak::DirectionalLight::SetShadowDistance
void SetShadowDistance(float dist)
Definition
DirectionalLight.hpp:69
Sleak::Light::SetShadowBias
void SetShadowBias(float bias)
Definition
Light.hpp:42
Sleak::Light::SetCastShadows
void SetCastShadows(bool cast)
Definition
Light.hpp:39
Sleak::Light::SetShadowStrength
void SetShadowStrength(float strength)
Definition
Light.hpp:45
Sleak::GraphicsQuality
GraphicsQuality
Definition
GraphicsConfig.hpp:13
Sleak::GraphicsQuality::Low
@ Low
Definition
GraphicsConfig.hpp:13
Sleak::GraphicsQuality::High
@ High
Definition
GraphicsConfig.hpp:13
Sleak::GraphicsQuality::Ultra
@ Ultra
Definition
GraphicsConfig.hpp:13
Sleak::GraphicsQuality::Medium
@ Medium
Definition
GraphicsConfig.hpp:13
Sleak::GraphicsQuality::Off
@ Off
Definition
GraphicsConfig.hpp:13
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
Sleak::GraphicsConfig
Definition
GraphicsConfig.hpp:18
Sleak::GraphicsConfig::taaEnabled
bool taaEnabled
Definition
GraphicsConfig.hpp:28
Sleak::GraphicsConfig::pcssEnabled
bool pcssEnabled
Definition
GraphicsConfig.hpp:55
Sleak::GraphicsConfig::shadowDistance
float shadowDistance
Definition
GraphicsConfig.hpp:33
Sleak::GraphicsConfig::ssaoEnabled
bool ssaoEnabled
Definition
GraphicsConfig.hpp:20
Sleak::GraphicsConfig::shadowStrength
float shadowStrength
Definition
GraphicsConfig.hpp:37
Sleak::GraphicsConfig::ssrEnabled
bool ssrEnabled
Definition
GraphicsConfig.hpp:24
Sleak::GraphicsConfig::shadowMapResolution
uint32_t shadowMapResolution
Definition
GraphicsConfig.hpp:32
Sleak::GraphicsConfig::occlusionBufferWidth
uint32_t occlusionBufferWidth
Definition
GraphicsConfig.hpp:42
Sleak::GraphicsConfig::bloomEnabled
bool bloomEnabled
Definition
GraphicsConfig.hpp:25
Sleak::GraphicsConfig::shadowCasterDistance
float shadowCasterDistance
Definition
GraphicsConfig.hpp:35
Sleak::GraphicsConfig::shadowBias
float shadowBias
Definition
GraphicsConfig.hpp:36
Sleak::GraphicsConfig::lightShaftEnabled
bool lightShaftEnabled
Definition
GraphicsConfig.hpp:63
Sleak::GraphicsConfig::occlusionBufferHeight
uint32_t occlusionBufferHeight
Definition
GraphicsConfig.hpp:43
Sleak::GraphicsConfig::maxOccluders
uint32_t maxOccluders
Definition
GraphicsConfig.hpp:44
Sleak::GraphicsConfig::shadowFrustumSize
float shadowFrustumSize
Definition
GraphicsConfig.hpp:34
Sleak::GraphicsConfig::ApplyShadows
void ApplyShadows(Sleak::DirectionalLight &light) const
Copies the shadow-related fields onto a directional light.
Definition
GraphicsConfig.cpp:98
Sleak::GraphicsConfig::Preset
static GraphicsConfig Preset(GraphicsQuality q)
Builds a config from a named quality preset.
Definition
GraphicsConfig.cpp:8
Sleak::GraphicsConfig::shadowEnabled
bool shadowEnabled
Definition
GraphicsConfig.hpp:31
Sleak::GraphicsConfig::iblEnabled
bool iblEnabled
Definition
GraphicsConfig.hpp:26
Sleak::GraphicsConfig::occlusionCullingEnabled
bool occlusionCullingEnabled
Definition
GraphicsConfig.hpp:41
src
Graphics
Common
GraphicsConfig.cpp
Generated on
for SleakEngine by
1.18.0