11#include "core/reflect.h"
13namespace Vkm::Engine {
22enum class TextureFiltering : uint8_t {
37#define VKM_RENDER_MODES(X) \
38 X(Default, "Default", DEFAULT, true) \
39 X(Wireframe, "Wireframe", WIREFRAME, true) \
40 X(LightingOnly, "Lighting Only", LIGHTING_ONLY, true) \
41 X(Albedo, "Albedo", ALBEDO, false) \
42 X(Roughness, "Roughness", ROUGHNESS, false) \
43 X(Metalness, "Metalness", METALNESS, false) \
44 X(Normals, "Normals", NORMALS, false) \
45 X(Depth, "Depth", DEPTH, false) \
46 X(AmbientOcclusion, "Ambient Occlusion", AMBIENT_OCCLUSION, false) \
47 X(ScreenShadows, "Screen Shadows", SCREEN_SHADOWS, false) \
48 X(GiOnly, "GI Only", GI_ONLY, true) \
49 X(DirectOnly, "Direct Only", DIRECT_ONLY, true) \
50 X(Clusters, "Light Clusters", CLUSTERS, true) \
51 X(Bloom, "Bloom", BLOOM, false) \
52 X(ShadowAtlas, "Shadow Atlas", SHADOW_ATLAS, false) \
53 X(Fog, "Fog", FOG, false)
62#define VKM_TONEMAPS(X) \
63 X(Reinhard, "Reinhard", REINHARD) \
64 X(ACES, "ACES (filmic)", ACES) \
65 X(KhronosNeutral, "Khronos PBR Neutral", KHRONOS_NEUTRAL) \
77enum class Tonemap : uint8_t {
78#define VKM_TONEMAP_ENUMERATOR(name, label, glsl) name,
79 VKM_TONEMAPS(VKM_TONEMAP_ENUMERATOR)
80#undef VKM_TONEMAP_ENUMERATOR
89enum class RenderMode : uint8_t {
90#define VKM_RENDER_MODE_ENUMERATOR(name, label, glsl, shaded) name,
91 VKM_RENDER_MODES(VKM_RENDER_MODE_ENUMERATOR)
92#undef VKM_RENDER_MODE_ENUMERATOR
103 RenderMode renderMode = RenderMode::Default;
133 Tonemap tonemap = Tonemap::ACES;
148 float exposureMaximum = 8.0f;
152 float adaptDarker = 3.0f;
202 bool gridAxisX =
false;
203 bool gridAxisY =
false;
204 bool gridAxisZ =
false;
230 if (viewportHeight == 0)
return 1.0f;
231 const float share =
static_cast<float>(height) /
static_cast<float>(viewportHeight);
244 return static_cast<uint32_t
>(std::lround(
static_cast<float>(viewportPixels) * scale));
253 return gridAxisX || gridAxisY || gridAxisZ;
264 if (count == samples)
return true;
280template <
typename Settings,
typename Fn>
281void visitShippedRenderFields(Settings& r, Fn&& f) {
284 f(
"probes", r.probes);
286 f(
"screenShadows", r.screenShadows);
287 f(
"gtaoRadius", r.gtaoRadius);
288 f(
"gtaoIntensity", r.gtaoIntensity);
289 f(
"gtaoPower", r.gtaoPower);
290 f(
"ssrMaxRoughness", r.ssrMaxRoughness);
291 f(
"ssrMaxDistance", r.ssrMaxDistance);
292 f(
"ssrHalfResolution", r.ssrHalfResolution);
293 f(
"bloomStrength", r.bloomStrength);
294 f(
"bloomThreshold", r.bloomThreshold);
295 f(
"bloomKnee", r.bloomKnee);
296 f(
"bloomRadius", r.bloomRadius);
297 f(
"tonemap", r.tonemap);
298 f(
"exposure", r.exposure);
299 f(
"autoExposure", r.autoExposure);
300 f(
"exposureMinimum", r.exposureMinimum);
301 f(
"exposureMaximum", r.exposureMaximum);
302 f(
"adaptBrighter", r.adaptBrighter);
303 f(
"adaptDarker", r.adaptDarker);
304 f(
"cullMaxDistance", r.cullMaxDistance);
305 f(
"cullMinPixels", r.cullMinPixels);
306 f(
"occlusionCulling", r.occlusionCulling);
307 f(
"msaaSamples", r.msaaSamples);
308 f(
"textureFiltering", r.textureFiltering);
309 f(
"textureAnisotropy", r.textureAnisotropy);
310 f(
"shadowResolution", r.shadowResolution);
311 f(
"softShadows", r.softShadows);
312 f(
"renderScale", r.renderScale);
318enum class GraphicsPreset : uint8_t {
341 VKM_ASSERT(preset < GraphicsPreset::Count,
"withPreset takes a tier, not the Count sentinel");
355 static constexpr Tier TIERS[] = {
356 {1, 1024,
false,
false,
false,
false, 4,
false, 0.67f,
true},
357 {2, 2048,
true,
true,
false,
true, 8,
false, 0.85f,
true},
358 {4, 4096,
true,
true,
true,
true, 16,
true, 1.0f,
true},
359 {8, 4096,
true,
true,
true,
true, 16,
true, 1.0f,
false},
361 static_assert(std::size(TIERS) ==
static_cast<size_t>(GraphicsPreset::Count));
362 const Tier& tier = TIERS[std::min(
static_cast<size_t>(preset), std::size(TIERS) - 1)];
365 r.shadowResolution = tier.shadows;
366 r.gtao = project.gtao && tier.gtao;
367 r.screenShadows = project.screenShadows && tier.screenShadows;
368 r.ssr = project.ssr && tier.ssr;
369 r.bloom = project.bloom && tier.bloom;
370 r.textureAnisotropy = tier.anisotropy;
371 r.softShadows = project.softShadows && tier.softShadows;
372 r.renderScale = tier.renderScale;
373 r.ssrHalfResolution = tier.ssrHalf;
379#define VKM_TONEMAP_LABEL(name, label, glsl) label,
380VKM_ENUM_NAMES(::Vkm::Engine::Tonemap, VKM_TONEMAPS(VKM_TONEMAP_LABEL))
381#undef VKM_TONEMAP_LABEL
383#define VKM_RENDER_MODE_LABEL(name, label, glsl, shaded) label,
384VKM_ENUM_NAMES(::Vkm::Engine::RenderMode, VKM_RENDER_MODES(VKM_RENDER_MODE_LABEL))
385#undef VKM_RENDER_MODE_LABEL
387VKM_ENUM_NAMES(::Vkm::Engine::TextureFiltering,
"Nearest",
"Bilinear",
"Trilinear")
389VKM_ENUM_NAMES(::Vkm::Engine::GraphicsPreset,
"Low",
"Medium",
"High",
"Ultra")
Editable render tuning: pass toggles + per-effect parameters.
Definition render_settings.h:101
float cullMaxDistance
World-space.
Definition render_settings.h:155
float exposureMinimum
Definition render_settings.h:147
bool ssr
Screen-space reflections, over the probes and the sky.
Definition render_settings.h:109
float cullMinPixels
Screen-pixel size; 0 disables.
Definition render_settings.h:156
uint32_t shadowResolution
The largest shadow tile's edge, one of SHADOW_RESOLUTIONS, the sun's near cascades'; costly to raise.
Definition render_settings.h:181
TextureFiltering textureFiltering
The frame's default texel sampling; TextureParams::filterOverride outranks it.
Definition render_settings.h:175
float renderScale
The scene's pixels as a share of the viewport's on each axis, MIN_RENDER_SCALE..MAX_RENDER_SCALE.
Definition render_settings.h:198
float bloomStrength
Definition render_settings.h:125
static constexpr float MIN_GTAO_RADIUS
The search divides by the radius, so it is never zero.
Definition render_settings.h:207
bool softShadows
Shadows soft as each light's sourceRadius makes them (PCSS); off, every shadow takes the hard 3x3 fil...
Definition render_settings.h:188
float bloomRadius
Upsample tent radius, fraction of frame width.
Definition render_settings.h:130
float ssrMaxDistance
Definition render_settings.h:119
float ssrMaxRoughness
Rougher surfaces reflect the probes and the sky alone.
Definition render_settings.h:118
bool screenShadows
The cascaded sun's contacts its cascades are too coarse for.
Definition render_settings.h:110
float bloomThreshold
Definition render_settings.h:128
uint32_t msaaSamples
Scene-pass MSAA samples, one of MSAA_SAMPLE_COUNTS; post runs on the resolved buffer.
Definition render_settings.h:167
float adaptBrighter
Definition render_settings.h:151
float bloomKnee
Soft-knee width around the threshold.
Definition render_settings.h:129
static bool isMsaaSampleCount(uint32_t samples)
Whether samples is one of MSAA_SAMPLE_COUNTS.
Definition render_settings.h:262
static constexpr uint32_t SHADOW_RESOLUTIONS[]
What shadowResolution may be.
Definition render_settings.h:212
static constexpr float MAX_GTAO_RADIUS
Past this the search reads the screen, not a neighbourhood.
Definition render_settings.h:209
float gtaoPower
Contrast curve.
Definition render_settings.h:115
bool ssrHalfResolution
Definition render_settings.h:122
static constexpr float MAX_RENDER_SCALE
The scene never renders past the viewport's resolution.
Definition render_settings.h:217
uint32_t sceneExtent(uint32_t viewportPixels) const
viewportPixels at the scene's scale, renderScale clamped to MIN_RENDER_SCALE..MAX_RENDER_SCALE.
Definition render_settings.h:242
bool gridShown() const
Whether the editor's world grid draws at all.
Definition render_settings.h:252
float gtaoIntensity
Occlusion strength.
Definition render_settings.h:114
static constexpr float MIN_RENDER_SCALE
Below half, the upscale is a blur no tier wants.
Definition render_settings.h:215
float gtaoRadius
World-space sample radius, MIN_GTAO_RADIUS..MAX_GTAO_RADIUS.
Definition render_settings.h:113
static constexpr uint32_t MSAA_SAMPLE_COUNTS[]
1 is off.
Definition render_settings.h:211
uint32_t textureAnisotropy
Degree when the mode is Trilinear (1 = off); clamped to the driver's ceiling.
Definition render_settings.h:177
bool occlusionCulling
Cull the opaque geometry other geometry hides, on the GPU.
Definition render_settings.h:163
static float renderScaleFor(uint32_t height, uint32_t viewportHeight)
The renderScale that renders a viewport viewportHeight pixels tall at height.
Definition render_settings.h:229
bool autoExposure
Adapt the exposure to the frame's brightness, as an eye does (system/render/exposure....
Definition render_settings.h:144
float exposure
The exposure in stops: the frame is scaled by 2^exposure before the tonemap.
Definition render_settings.h:141