vkmEngine 1.0.0
A C++ game engine · vkmengine.com
Loading...
Searching...
No Matches
render_settings.h
1#pragma once
2
3#include <cstdint>
4
5#include "core/reflect.h"
6
7namespace Vkm::Engine {
8
16enum class TextureFiltering : uint8_t {
17 Nearest = 0,
18 Bilinear,
19 Trilinear,
20 Count
21};
22
30#define VKM_RENDER_MODES(X) \
31 X(Default, "Default", DEFAULT, true) \
32 X(Depth, "Depth", DEPTH, false) \
33 X(Normals, "Normals", NORMALS, false) \
34 X(Roughness, "Roughness (authored)", ROUGHNESS, false) \
35 X(Metalness, "Metalness (authored)", METALNESS, false) \
36 X(AmbientOcclusion, "Ambient Occlusion", AMBIENT_OCCLUSION, false) \
37 X(Bloom, "Bloom", BLOOM, false) \
38 X(ShadowAtlas, "Shadow Atlas", SHADOW_ATLAS, false) \
39 X(Fog, "Fog", FOG, false) \
40 X(GiOnly, "GI Only", GI_ONLY, true) \
41 X(DirectOnly, "Direct Only", DIRECT_ONLY, true) \
42 X(Clusters, "Light Clusters", CLUSTERS, true)
43
51#define VKM_TONEMAPS(X) \
52 X(Reinhard, "Reinhard", REINHARD) \
53 X(ACES, "ACES (filmic)", ACES) \
54 X(KhronosNeutral, "Khronos PBR Neutral", KHRONOS_NEUTRAL)
55
62enum class Tonemap : uint8_t {
63#define VKM_TONEMAP_ENUMERATOR(name, label, glsl) name,
64 VKM_TONEMAPS(VKM_TONEMAP_ENUMERATOR)
65#undef VKM_TONEMAP_ENUMERATOR
66 Count,
67};
68
74enum class RenderMode : uint8_t {
75#define VKM_RENDER_MODE_ENUMERATOR(name, label, glsl, shaded) name,
76 VKM_RENDER_MODES(VKM_RENDER_MODE_ENUMERATOR)
77#undef VKM_RENDER_MODE_ENUMERATOR
78 Count,
79};
80
87 // Debug
88 RenderMode renderMode = RenderMode::Default;
89
90 // Pass toggles
91 bool gtao = true;
92 bool bloom = true;
93 bool probes = true;
94 bool ssr = true;
95
96 // GTAO
97 float gtaoRadius = 0.6f;
98 float gtaoIntensity = 1.0f;
99 float gtaoPower = 1.5f;
100
101 // Screen-space reflections
102 float ssrMaxRoughness = 0.6f;
103 float ssrMaxDistance = 50.0f;
104
105 // Bloom
106 float bloomStrength = 0.06f;
107 float bloomThreshold = 1.0f;
108 float bloomKnee = 0.5f;
109 float bloomRadius = 0.005f;
110
111 // Display transform
112 Tonemap tonemap = Tonemap::Reinhard;
113
119 float exposure = 0.0f;
120
121 // Culling
122 float cullMaxDistance = 500.0f;
123 float cullMinPixels = 3.0f;
124
125 // Anti-aliasing
127 uint32_t msaaSamples = 4;
128
135 TextureFiltering textureFiltering = TextureFiltering::Trilinear;
137 uint32_t textureAnisotropy = 16;
138
139 // Shadows
141 uint32_t shadowResolution = 4096;
142
143 // Overlays
144 bool grid = false;
145
147 static constexpr float MIN_GTAO_RADIUS = 0.05f;
149 static constexpr float MAX_GTAO_RADIUS = 5.0f;
150
151 static constexpr uint32_t MSAA_SAMPLE_COUNTS[] = {1, 2, 4, 8};
152
159 static bool isMsaaSampleCount(uint32_t samples) {
160 for (const uint32_t count : MSAA_SAMPLE_COUNTS) {
161 if (count == samples) return true;
162 }
163 return false;
164 }
165};
166
177template <typename Settings, typename Fn>
178void visitShippedRenderFields(Settings& r, Fn&& f) {
179 f("gtao", r.gtao);
180 f("bloom", r.bloom);
181 f("probes", r.probes);
182 f("ssr", r.ssr);
183 f("gtaoRadius", r.gtaoRadius);
184 f("gtaoIntensity", r.gtaoIntensity);
185 f("gtaoPower", r.gtaoPower);
186 f("ssrMaxRoughness", r.ssrMaxRoughness);
187 f("ssrMaxDistance", r.ssrMaxDistance);
188 f("bloomStrength", r.bloomStrength);
189 f("bloomThreshold", r.bloomThreshold);
190 f("bloomKnee", r.bloomKnee);
191 f("bloomRadius", r.bloomRadius);
192 f("tonemap", r.tonemap);
193 f("exposure", r.exposure);
194 f("cullMaxDistance", r.cullMaxDistance);
195 f("cullMinPixels", r.cullMinPixels);
196 f("msaaSamples", r.msaaSamples);
197 f("textureFiltering", r.textureFiltering);
198 f("textureAnisotropy", r.textureAnisotropy);
199 f("shadowResolution", r.shadowResolution);
200}
201
202} // namespace Vkm::Engine
203
204#define VKM_TONEMAP_LABEL(name, label, glsl) label,
205VKM_ENUM_NAMES(::Vkm::Engine::Tonemap, VKM_TONEMAPS(VKM_TONEMAP_LABEL))
206#undef VKM_TONEMAP_LABEL
207
208#define VKM_RENDER_MODE_LABEL(name, label, glsl, shaded) label,
209VKM_ENUM_NAMES(::Vkm::Engine::RenderMode, VKM_RENDER_MODES(VKM_RENDER_MODE_LABEL))
210#undef VKM_RENDER_MODE_LABEL
211
212VKM_ENUM_NAMES(::Vkm::Engine::TextureFiltering, "Nearest", "Bilinear", "Trilinear")
Editable render tuning: pass toggles + per-effect parameters.
Definition render_settings.h:86
float cullMaxDistance
World-space.
Definition render_settings.h:122
bool ssr
Screen-space reflections, over the probes and the sky.
Definition render_settings.h:94
float cullMinPixels
Screen-pixel size; 0 disables.
Definition render_settings.h:123
uint32_t shadowResolution
Per-tile shadow-atlas resolution (1024/2048/4096); costly to raise.
Definition render_settings.h:141
TextureFiltering textureFiltering
The frame's default texel sampling; TextureParams::filterOverride outranks it.
Definition render_settings.h:135
float bloomStrength
Bloom scale, added pre-tonemap.
Definition render_settings.h:106
static constexpr float MIN_GTAO_RADIUS
The search divides by the radius, so it is never zero.
Definition render_settings.h:147
float bloomRadius
Upsample tent radius, fraction of frame width.
Definition render_settings.h:109
float ssrMaxDistance
World-space trace length.
Definition render_settings.h:103
float ssrMaxRoughness
Rougher surfaces reflect the probes and the sky alone.
Definition render_settings.h:102
float bloomThreshold
On a pixel's brightest channel (linear HDR).
Definition render_settings.h:107
uint32_t msaaSamples
Scene-pass MSAA samples, one of MSAA_SAMPLE_COUNTS; post runs on the resolved buffer.
Definition render_settings.h:127
float bloomKnee
Soft-knee width around the threshold.
Definition render_settings.h:108
static bool isMsaaSampleCount(uint32_t samples)
Whether samples is one of MSAA_SAMPLE_COUNTS.
Definition render_settings.h:159
static constexpr float MAX_GTAO_RADIUS
Past this the search reads the screen, not a neighbourhood.
Definition render_settings.h:149
float gtaoPower
Contrast curve.
Definition render_settings.h:99
float gtaoIntensity
Occlusion strength.
Definition render_settings.h:98
bool grid
Editor ground grid.
Definition render_settings.h:144
float gtaoRadius
World-space sample radius, MIN_GTAO_RADIUS..MAX_GTAO_RADIUS.
Definition render_settings.h:97
static constexpr uint32_t MSAA_SAMPLE_COUNTS[]
1 is off.
Definition render_settings.h:151
uint32_t textureAnisotropy
Degree when the mode is Trilinear (1 = off); clamped to the driver's ceiling.
Definition render_settings.h:137
float exposure
A fixed exposure in stops: the frame is scaled by 2^exposure before the tonemap.
Definition render_settings.h:119