#ifndef FOXY_SETTINGS_GLSL
#define FOXY_SETTINGS_GLSL

// Iris/DH exposes LOD buffers as LOD_MOD_ACTIVE in regular composite passes,
// while DH terrain/final passes may expose DISTANT_HORIZONS.  Treat both as
// one feature so every stage uses the same front-layer depth.
#if defined(DISTANT_HORIZONS) || defined(LOD_MOD_ACTIVE) || defined(VOXY)
#define FOXY_DH_ACTIVE 1
#else
#define FOXY_DH_ACTIVE 0
#endif

// Internal water reflection stability defaults.
#define FOXY_WATER_SSR_NORMAL_STABILIZATION 1
#define FOXY_WATER_SSR_TEMPORAL_STABILIZATION 1

#define FOXY_EXPOSURE 1.0 // [0.25 0.35 0.50 0.65 0.70 0.80 1.0 1.15 1.30 1.50 1.75 2.0 2.40 2.80 3.20]
#define FOXY_AUTO_EXPOSURE 1.0 // [0.0 0.25 0.40 0.55 0.70 0.85 1.0]
#define FOXY_AUTO_EXPOSURE_DARK_LIMIT 2.0 // [2.0 3.0 4.0 6.0 8.0 12.0 16.0 24.0 32.0 48.0 64.0]
#define FOXY_POST_EXPOSURE_BRIGHTNESS 1.0 // [0.25 0.35 0.50 0.65 0.80 1.0 1.15 1.30 1.50 1.75 2.0 2.40 2.80 3.20 4.0]
#define FOXY_SUN_INTENSITY 1.15 // [0.0 0.25 0.50 0.75 1.0 1.15 1.25 1.50 2.0]
#define FOXY_MOON_INTENSITY 0.12 // [0.0 0.05 0.08 0.12 0.18 0.25 0.35 0.50]
#define FOXY_AMBIENT_INTENSITY 0.65 // [0.10 0.20 0.35 0.50 0.65 0.80 1.0 1.25]
#define FOXY_SKY_AMBIENT_NEUTRALITY 0.70 // [0.0 0.20 0.35 0.50 0.60 0.70 0.80 0.90 1.0]
#define FOXY_SKY_AMBIENT_LIFT 1.15 // [0.80 0.90 1.0 1.05 1.10 1.15 1.20 1.30 1.40 1.50]
#define FOXY_PBR 1 // [0 1]
#define FOXY_PBR_SPECULAR_MAPS 1 // [0 1]
#define FOXY_PBR_NORMAL_MAPS 1 // [0 1]
#define FOXY_PBR_TEXTURE_FORMAT 0 // [0 1]
// Visible PBR emission is scene-linear radiance before exposure and
// ACES presentation. Keep its calibration separate from screen-space GI.
#define FOXY_PBR_EMISSION_BRIGHTNESS 6.0 // [0.50 1.0 1.50 2.0 3.0 4.0 5.0 6.0 8.0 10.0 12.0 16.0 20.0]
#define FOXY_SSPT_PBR_EMISSION_BRIGHTNESS 2.0
#define FOXY_PBR_SPECULAR_STRENGTH 1.25 // [0.0 0.15 0.25 0.40 0.60 0.80 1.0 1.25 1.50]
#define FOXY_PBR_FALLBACK_F0 0.035 // [0.010 0.015 0.020 0.025 0.030 0.035 0.040 0.050]
#define FOXY_PBR_LIGHT_ANGULAR_RADIUS 0.00465 // [0.00200 0.00350 0.00465 0.00600 0.00800 0.01200]
#define FOXY_PBR_SPECULAR_CLAMP 4.0 // [0.50 1.0 1.5 2.0 2.5 3.0 4.0 6.0]
#define FOXY_PBR_METAL_DIFFUSE 0.30 // [0.0 0.10 0.20 0.30 0.40 0.50]
#define FOXY_PBR_SSS 1 // [0 1]
#define FOXY_PBR_SSS_INTENSITY 1.0 // [0.0 0.15 0.30 0.50 0.70 0.90 1.0 1.10 1.35 1.60]
#define FOXY_PBR_SSS_ALPHA_NEIGHBORS 0 // [0 1]
#define FOXY_PBR_SSS_SHEEN 1 // [0 1]
#define FOXY_PBR_PARALLAX 0 // [0 1]
#define FOXY_PBR_PARALLAX_DEPTH 0.25 // [0.05 0.10 0.15 0.20 0.25 0.30 0.40 0.50]
#define FOXY_PBR_PARALLAX_STEPS 16 // [8 12 16 20 24 32 40]
#define FOXY_PBR_PARALLAX_DISTANCE 24.0 // [8.0 12.0 16.0 24.0 32.0 48.0 64.0]
#define FOXY_MATERIAL_REFLECTIONS 0 // [0 1]
// Two geometry-guided cross filters feed an independent reflection history.
// Global TAA remains a final-image resolver only.
#define FOXY_MATERIAL_REFLECTION_HIGH_QUALITY 0 // [0 1]
#define FOXY_MATERIAL_REFLECTION_GLOBAL 0 // [0 1]
#define FOXY_MATERIAL_REFLECTION_STEPS 12 // [8 10 12 16 20 24 28]
#define FOXY_MATERIAL_REFLECTION_STRENGTH 1.0 // [0.25 0.50 0.75 1.0 1.25 1.50]
#define FOXY_MATERIAL_REFLECTION_ROUGHNESS_CUTOFF 0.72 // [0.35 0.45 0.55 0.65 0.72 0.80 0.90]
// Ordinary diffuse surfaces never enter the SSR/denoiser chain. Metals stay
// eligible at every roughness, preserving iron-like reflective blocks.
#define FOXY_MATERIAL_REFLECTION_MIN_SMOOTHNESS 0.34
// Additional material-energy gates used internally by the reflection policy.
// They add no buffers or passes and keep the broad material controls above.
#define FOXY_MATERIAL_REFLECTION_ENERGY_THRESHOLD 0.01
#define FOXY_MATERIAL_REFLECTION_ENERGY_ROUGHNESS_ATTENUATION 2.0
#define FOXY_MATERIAL_REFLECTION_GLOBAL_MIN_ENERGY 0.025
#define FOXY_ATMOSPHERE_STYLE 2 // [1 2 3]
#define FOXY_SUN_ANGULAR_RADIUS 0.0218 // [0.0120 0.0160 0.0180 0.0218 0.0240 0.0280 0.0320]
#define FOXY_SUN_PROFILE_FALLOFF 2.05 // [1.20 1.45 1.70 1.85 2.05 2.30 2.60 3.0]
#define FOXY_SUN_PROFILE_ENERGY 520.0 // [180.0 260.0 360.0 520.0 700.0 900.0 1200.0]
#define FOXY_SKY_SCATTER_EXPOSURE 0.15 // [0.05 0.10 0.15 0.25 0.35 0.45 0.55 0.65 0.75 0.82 0.88 0.95 1.0 1.10 1.25 1.40]
#define FOXY_SKY_HORIZON_WHITE 0.15 // [0.0 0.15 0.30 0.42 0.50 0.58 0.70 0.85 1.0 1.20 1.50]
#define FOXY_SKY_HORIZON_WHITE_RANGE 0.72 // [0.20 0.35 0.50 0.62 0.72 0.85 1.0 1.20 1.50]
#define FOXY_SKY_BLUE_DEPTH 1.0 // [0.70 0.82 0.92 1.0 1.08 1.16 1.25 1.35 1.50]
#define FOXY_SKY_SUNSET_WARMTH 1.0 // [0.50 0.65 0.80 1.0 1.16 1.35 1.60 1.85 2.20]
#define FOXY_SKY_SUNSET_HORIZON_OFFSET 400.0 // [-6000.0 -4800.0 -3600.0 -2400.0 -1600.0 -1200.0 -800.0 -400.0 0.0 400.0 800.0 1200.0 1600.0 2400.0 3600.0 4800.0 6000.0]
#define FOXY_SKY_SUNRISE_HORIZON_OFFSET 0.0 // [-6000.0 -4800.0 -3600.0 -2400.0 -1600.0 -1200.0 -800.0 -400.0 0.0 400.0 800.0 1200.0 1600.0 2400.0 3600.0 4800.0 6000.0]
#define FOXY_SKY_SOLAR_SUNSET_HORIZON_OFFSET 400.0 // [-6000.0 -4800.0 -3600.0 -2400.0 -1600.0 -1200.0 -800.0 -400.0 0.0 400.0 800.0 1200.0 1600.0 2400.0 3600.0 4800.0 6000.0]
#define FOXY_SKY_SOLAR_SUNRISE_HORIZON_OFFSET 0.0 // [-6000.0 -4800.0 -3600.0 -2400.0 -1600.0 -1200.0 -800.0 -400.0 0.0 400.0 800.0 1200.0 1600.0 2400.0 3600.0 4800.0 6000.0]
#define FOXY_SKY_TWILIGHT_SCALE 1.0 // [0.70 0.80 0.90 1.0 1.10 1.20 1.35 1.50]
#define FOXY_SKY_VANILLA_CELESTIALS 0 // [0 1]
#define FOXY_SKY_VANILLA_MOON 1 // [0 1]
#define FOXY_NASA_GALAXY 1 // [0 1]
#define FOXY_NASA_GALAXY_INTENSITY 0.25 // [0.0 0.10 0.16 0.20 0.25 0.32 0.40 0.50 0.65 0.80 1.0]
#define FOXY_FOG_DENSITY 0.30 // [0.0 0.15 0.30 0.45 0.60 0.75 1.0 1.25 1.50 2.0]
#define FOXY_FOG_BLUE_SHIFT 1.0 // [0.0 0.25 0.50 0.75 1.0 1.25 1.50 1.75 2.0 2.50 3.0]
#define FOXY_FOG_START 0.50 // [0.15 0.25 0.35 0.50 0.65 0.78 0.88]
#define FOXY_WORLD_FOG_STRENGTH 0.25 // [0.0 0.10 0.20 0.25 0.35 0.50 0.75 1.0]
#define FOXY_WORLD_FOG_HEIGHT 72.0 // [0.0 16.0 32.0 48.0 56.0 64.0 72.0 80.0 96.0 112.0 128.0 160.0 192.0 256.0 320.0]
#define FOXY_WORLD_FOG_FALLOFF 96.0 // [32.0 48.0 72.0 96.0 128.0 192.0 256.0]
#define FOXY_AIR_AEROSOL_ENABLED 1 // [0 1]
#define FOXY_AIR_AEROSOL_DENSITY 0.16 // [0.0 0.04 0.08 0.12 0.16 0.24 0.34 0.46 0.62 0.82 1.0 1.25 1.50 2.0]
#define FOXY_AIR_AEROSOL_FADE_START 72.0 // [-64.0 -32.0 0.0 16.0 32.0 48.0 56.0 64.0 72.0 80.0 96.0 112.0 128.0 160.0 192.0 224.0 256.0 320.0 384.0 512.0]
#define FOXY_AIR_AEROSOL_FADE_END 384.0 // [0.0 16.0 32.0 48.0 64.0 72.0 80.0 96.0 112.0 128.0 144.0 160.0 192.0 224.0 256.0 280.0 320.0 384.0 448.0 512.0 640.0 768.0 896.0 1024.0 1088.0 1280.0 1536.0 2048.0]
#define FOXY_AIR_MOLECULAR_ENABLED 1 // [0 1]
#define FOXY_AIR_MOLECULAR_DENSITY 0.16 // [0.0 0.04 0.08 0.12 0.16 0.24 0.34 0.46 0.62 0.82 1.0 1.25 1.50 2.0]
#define FOXY_AIR_MOLECULAR_FADE_START 72.0 // [-64.0 -32.0 0.0 16.0 32.0 48.0 56.0 64.0 72.0 80.0 96.0 112.0 128.0 160.0 192.0 224.0 256.0 320.0 384.0 512.0]
#define FOXY_AIR_MOLECULAR_FADE_END 1088.0 // [0.0 16.0 32.0 48.0 64.0 72.0 80.0 96.0 112.0 128.0 144.0 160.0 192.0 224.0 256.0 280.0 320.0 384.0 448.0 512.0 640.0 768.0 896.0 1024.0 1088.0 1280.0 1536.0 2048.0]
#define FOXY_AIR_DENSITY_NOON 1.0 // [0.0 0.25 0.50 0.75 0.85 1.0 1.15 1.25 1.50 1.75 2.0]
#define FOXY_AIR_DENSITY_TWILIGHT 1.0 // [0.0 0.25 0.50 0.75 0.85 1.0 1.15 1.25 1.50 1.75 2.0]
#define FOXY_AIR_DENSITY_NIGHT 1.0 // [0.0 0.25 0.50 0.75 0.85 1.0 1.15 1.25 1.50 1.75 2.0]
#define FOXY_AIR_TEMPERATURE_TWILIGHT 6500 // [2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 9000 10000 12000]
#define FOXY_AIR_TEMPERATURE_NOON 6500 // [2500 3000 3500 4000 4500 5000 5500 6000 6500 7000 7500 8000 9000 10000 12000]
#define FOXY_VOLUMETRIC_LIGHT 1 // [0 1]
#define FOXY_VL_CLUMPY_FOG 1 // [0 1]
#define FOXY_VL_QUALITY 1 // [0 1 2]
#define FOXY_VL_STRENGTH 1.20 // [0.0 0.15 0.25 0.35 0.42 0.55 0.70 0.90 1.20 1.35]
#define FOXY_VL_RESOLUTION 0.50 // [0.10 0.15 0.20 0.25 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.0]
#define FOXY_VL_DISTANCE 320.0 // directional beam and shadow-modulation range [48.0 72.0 96.0 128.0 144.0 176.0 192.0 224.0 320.0]
#define FOXY_VL_ANISOTROPY 0.62 // [0.0 0.25 0.45 0.55 0.62 0.72 0.82]
#define FOXY_VL_SHADOWING 1.0 // [0.0 0.25 0.50 0.75 0.88 1.0]
#define FOXY_VL_SHADOW_DARKEN 2.0 // shaft-edge contrast [0.50 0.75 1.0 1.25 1.50 2.0 2.50 3.0 4.0]
#define FOXY_VL_CLUMPINESS 0.58 // [0.0 0.15 0.28 0.42 0.58 0.68 0.75 1.0]
#define FOXY_VOLUME_COMPACT_CBR 0
#define FOXY_COLOR_SATURATION 1.0 // [0.70 0.80 0.90 1.0 1.08 1.16 1.25]
#define FOXY_COLOR_SHADOW_CURVE 0.08 // [-0.30 -0.20 -0.10 0.0 0.08 0.12 0.18 0.25 0.35]
#define FOXY_COLOR_HIGHLIGHT_CURVE 0.18 // [-0.30 -0.20 -0.10 0.0 0.08 0.12 0.18 0.25 0.35]
#define FOXY_WHITE_BALANCE 6500 // [4000 4500 5000 5500 6000 6500 7000 7500 8000 8500 9000]
#define FOXY_COLOR_GRADING 0.35 // [0.0 0.15 0.25 0.35 0.50 0.65 0.80 1.0]
#define FOXY_PURKINJE_SHIFT 0.30 // [0.0 0.15 0.30 0.45 0.60 0.80 1.0]
#define FOXY_VIGNETTE 0.08 // [0.0 0.04 0.08 0.12 0.16 0.22 0.30]
#define FOXY_BLOOM_STRENGTH 0.15 // [0.0 0.08 0.15 0.25 0.35 0.45 0.60 0.80 1.0]
#define FOXY_BLOOM_THRESHOLD 0.35 // [0.20 0.28 0.35 0.45 0.60 0.75 0.90 1.10 1.35 1.70]
#define FOXY_BLOOM_RADIUS 0.85 // [0.25 0.40 0.55 0.65 0.80 0.85 1.0 1.25 1.50]
#define FOXY_BLOOM_FOG 0.25 // [0.0 0.10 0.20 0.25 0.35 0.50 0.75 1.0]
#define FOXY_MOTION_BLUR 0.45 // [0.0 0.15 0.30 0.45 0.60 0.80 1.0 1.25 1.50 2.0 2.50 3.0]
#define FOXY_TONEMAPPER 2 // [0 1 2 3 4 5]
#define FOXY_CAS 0 // [0 1]
#define FOXY_CAS_STRENGTH 0.55 // [0.15 0.30 0.40 0.55 0.70 0.85 1.0]
#define FOXY_DOF 0 // [0 1]
#define FOXY_DOF_AUTO_FOCUS 1 // [0 1]
const float centerDepthHalflife = 1.0; // [0.1 0.2 0.3 0.5 0.75 1.0 1.5 2.0 3.0 4.0]
#define FOXY_DOF_QUALITY 1 // [0 1 2 3 4]
#define FOXY_DOF_FOCUS_DISTANCE 12.0 // [2.0 4.0 6.0 8.0 12.0 16.0 24.0 32.0 48.0 64.0]
#define FOXY_DOF_APERTURE 1.0 // [0.25 0.50 0.75 1.0 1.25 1.50 2.0]
#define FOXY_DOF_MAX_BLUR 6.0 // [2.0 3.0 4.0 6.0 8.0 10.0 12.0]
// Native temporal anti-aliasing and optional temporal upscaling.
#include "/lib/temporal_options.glsl"

#define FOXY_RAY_MODE 0 // [0 1 2]
#define FOXY_SSPT_SPP 1 // [1 2]
#define FOXY_SSPT_TRACE_STEPS 16 // [8 12 16 20 24 28 32]
#define FOXY_SSPT_MAX_DISTANCE 48.0 // [16.0 24.0 32.0 48.0 64.0 96.0]
#define FOXY_SSPT_HISTORY_FRAMES 48 // [8 12 16 24 32 48 64 80 96 128]
#define FOXY_SSPT_DENOISER 1 // [0 1]
#define FOXY_SSPT_DENOISE_QUALITY 2 // [0 1 2]
#define FOXY_SSPT_BOUNCE_BRIGHTNESS 8.0 // [0.0 0.25 0.50 0.75 0.90 1.0 1.10 1.25 1.50 1.75 2.0 2.50 3.0 4.0 5.0 6.0 8.0 10.0 12.0 15.0]
#define FOXY_SSPT_DENOISE_STRENGTH 1.25 // [0.0 0.25 0.50 0.75 1.0 1.25 1.50 1.75 2.0]
#define FOXY_SSPT_MINIMUM_LIGHT 1 // [0 1]
#define FOXY_SSPT_MINIMUM_LIGHT_STRENGTH 3.0 // [0.0 0.25 0.50 0.75 1.0 1.25 1.50 2.0 2.50 3.0 4.0 5.0 6.0 8.0 10.0 12.0 15.0 20.0 25.0 30.0 40.0 50.0]
#define FOXY_SSPT_EMISSIVE_FEEDBACK 1 // [0 1]
#define FOXY_SSPT_EMISSIVE_BRIGHTNESS 1.0 // [0.0 0.25 0.50 0.75 0.90 1.0 1.10 1.25 1.50 1.75 2.0 2.50 3.0]

// VXGI has its own quality and energy controls.  The true-secondary switch is
// deliberately off by default, preserving the one-ray, one-segment preview
// cost; enabling it adds exactly one cosine-weighted DDA continuation.  The
// distance setting also owns the camera-centered traced-surface radius; a
// low-frequency sky fallback takes over smoothly beyond that radius.
#define FOXY_VXGI_TRUE_SECONDARY_BOUNCE 1 // [0 1]
#define FOXY_VRTGI_REALISTIC_MODE 1 // [0 1]
#define FOXY_VRTGI_RESOLUTION 0.5 // [0.25 0.33 0.5 0.67 1.0]
// Dispatch one horizontal parity per frame. The temporal pass resolves the
// missing parity from consistent history and current-frame neighbors.
#define FOXY_VRTGI_TEMPORAL_INTERLEAVE 1 // [0 1]
#define FOXY_IRRADIANCE_CACHE 1 // [0 1]
#define FOXY_IRRADIANCE_CACHE_STRENGTH 1.0 // [0.0 0.25 0.50 0.75 1.0 1.25]
#define FOXY_IRRADIANCE_CACHE_SKY_BRIGHTNESS 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0]
#define FOXY_IRRADIANCE_CACHE_BLOCK_BRIGHTNESS 1.0 // [0.0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 2.0 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 3.0]
#define FOXY_IRRADIANCE_CACHE_HISTORY_FRAMES 160 // [32 48 64 80 96 128 160 192 256]
#if FOXY_RAY_MODE == 2
	#define FOXY_RAY_RESOLUTION FOXY_VRTGI_RESOLUTION
#else
	// The screen-space path keeps its established half-resolution contract.
	#define FOXY_RAY_RESOLUTION 0.5
#endif
// GUI energy controls remain relative and centered at 1.0.
#define FOXY_VXGI_MASTER_CALIBRATION 3.0
#define FOXY_VXGI_SUN_CALIBRATION 2.0
#define FOXY_VXGI_EMITTER_CALIBRATION 3.0
#define FOXY_VOXEL_GI_INTENSITY 1.0 // [0.0 0.25 0.50 0.75 0.90 1.0 1.10 1.25 1.50 1.75 2.0 2.50 3.0]
#define FOXY_VOXEL_GI_SPP 1 // [1 2 3 4]
#define FOXY_VOXEL_GI_DISTANCE_CHUNKS 4 // [2 4 6 8 10 12 16]
#if FOXY_VOXEL_GI_DISTANCE_CHUNKS == 2
	#define FOXY_VOXEL_GI_MAX_DISTANCE 32.0
	#define FOXY_VOXEL_GRID_SIZE 64
	#define FOXY_VOXEL_GRID_COUNT 262144u
	#define FOXY_VOXEL_GI_MIN_TRACE_ITERATIONS 64
#elif FOXY_VOXEL_GI_DISTANCE_CHUNKS == 4
	#define FOXY_VOXEL_GI_MAX_DISTANCE 64.0
	#define FOXY_VOXEL_GRID_SIZE 128
	#define FOXY_VOXEL_GRID_COUNT 2097152u
	#define FOXY_VOXEL_GI_MIN_TRACE_ITERATIONS 96
#elif FOXY_VOXEL_GI_DISTANCE_CHUNKS == 6
	#define FOXY_VOXEL_GI_MAX_DISTANCE 96.0
	#define FOXY_VOXEL_GRID_SIZE 192
	#define FOXY_VOXEL_GRID_COUNT 7077888u
	#define FOXY_VOXEL_GI_MIN_TRACE_ITERATIONS 144
#elif FOXY_VOXEL_GI_DISTANCE_CHUNKS == 8
	#define FOXY_VOXEL_GI_MAX_DISTANCE 128.0
	#define FOXY_VOXEL_GRID_SIZE 256
	#define FOXY_VOXEL_GRID_COUNT 16777216u
	#define FOXY_VOXEL_GI_MIN_TRACE_ITERATIONS 192
#elif FOXY_VOXEL_GI_DISTANCE_CHUNKS == 10
	#define FOXY_VOXEL_GI_MAX_DISTANCE 160.0
	#define FOXY_VOXEL_GRID_SIZE 320
	#define FOXY_VOXEL_GRID_COUNT 32768000u
	#define FOXY_VOXEL_GI_MIN_TRACE_ITERATIONS 240
#elif FOXY_VOXEL_GI_DISTANCE_CHUNKS == 12
	#define FOXY_VOXEL_GI_MAX_DISTANCE 192.0
	#define FOXY_VOXEL_GRID_SIZE 384
	#define FOXY_VOXEL_GRID_COUNT 56623104u
	#define FOXY_VOXEL_GI_MIN_TRACE_ITERATIONS 288
#elif FOXY_VOXEL_GI_DISTANCE_CHUNKS == 16
	#define FOXY_VOXEL_GI_MAX_DISTANCE 256.0
	#define FOXY_VOXEL_GRID_SIZE 512
	#define FOXY_VOXEL_GRID_COUNT 134217728u
	#define FOXY_VOXEL_GI_MIN_TRACE_ITERATIONS 384
#else
	#error FOXY_VOXEL_GI_DISTANCE_CHUNKS must be 2, 4, 6, 8, 10, 12, or 16.
#endif
#define FOXY_VOXEL_GRID_HALF_SIZE (float(FOXY_VOXEL_GRID_SIZE) * 0.5)
#define FOXY_VOXEL_GI_TRACE_ITERATIONS max(FOXY_VOXEL_GI_MAX_STEPS, FOXY_VOXEL_GI_MIN_TRACE_ITERATIONS)
#define FOXY_VOXEL_GI_MAX_STEPS 96 // [32 48 64 80 96 112 128]
#define FOXY_VOXEL_GI_SUN_DIFFUSE_BRIGHTNESS 1.0 // [0.0 0.25 0.50 0.75 0.90 1.0 1.10 1.25 1.50 1.75 2.0]
#define FOXY_VOXEL_GI_EMITTER_BRIGHTNESS 1.0 // [0.0 0.25 0.50 0.75 0.90 1.0 1.10 1.25 1.50 1.75 2.0 2.50 3.0]
#define FOXY_VOXEL_GI_SKY_BRIGHTNESS 1.5 // [0.0 0.25 0.50 0.75 0.90 1.0 1.10 1.25 1.50 1.75 2.0]

// Every rendering mode shares one scene-referred exposure system. Automatic
// adaptation has a user-facing dark-scene ceiling: a nearly black meter must
// remain perceptually dark instead of being lifted toward daylight without
// limit. Manual and post-exposure controls remain independent artistic gains.
#define FOXY_PRESENTATION_EXPOSURE_MIN 0.00390625
#define FOXY_PRESENTATION_EXPOSURE_MAX min(max(FOXY_AUTO_EXPOSURE_DARK_LIMIT, 1.0), 64.0)
#define FOXY_PRESENTATION_EXPOSURE_STATE_MIN 0.0030
#define FOXY_PRESENTATION_EXPOSURE_STATE_MAX (FOXY_PRESENTATION_EXPOSURE_MAX * 1.125)
#define FOXY_PRESENTATION_MANUAL_EXPOSURE FOXY_EXPOSURE
#define FOXY_PRESENTATION_AUTO_WEIGHT FOXY_AUTO_EXPOSURE

// Realistic VRTGI changes scene lighting energy, never the exposure algorithm.
// Post-exposure calibration absorbs the user's matched outdoor reference so
// the GUI brightness control remains a relative 1.0x artistic adjustment.
#define FOXY_PRESENTATION_BASE_POST_EXPOSURE_CALIBRATION 2.0
#if FOXY_RAY_MODE == 2 && FOXY_VRTGI_REALISTIC_MODE == 1
	#define FOXY_VRTGI_REALISTIC_ACTIVE 1
	#define FOXY_PRESENTATION_SUN_SCALE 5.0
	#define FOXY_PRESENTATION_SKY_SCALE 4.0
	#define FOXY_PRESENTATION_POST_EXPOSURE_CALIBRATION 1.5
#else
	#define FOXY_VRTGI_REALISTIC_ACTIVE 0
	#define FOXY_PRESENTATION_SUN_SCALE 1.0
	#define FOXY_PRESENTATION_SKY_SCALE 1.0
	#define FOXY_PRESENTATION_POST_EXPOSURE_CALIBRATION 2.0
#endif

float PresentationDayWeight(const in float sunAltitude) {
	#if FOXY_VRTGI_REALISTIC_ACTIVE == 1
		// Enter the realistic daylight range smoothly over four solar degrees.
		return smoothstep(0.0, 0.07, sunAltitude);
	#else
		return 0.0;
	#endif
}

float PresentationSunScale(const in float sunAltitude) {
	return mix(1.0, FOXY_PRESENTATION_SUN_SCALE, PresentationDayWeight(sunAltitude));
}

float PresentationSkyScale(const in float sunAltitude) {
	return mix(1.0, FOXY_PRESENTATION_SKY_SCALE, PresentationDayWeight(sunAltitude));
}

float PresentationPostExposureCalibration(const in float daylightWeight) {
	return mix(
		FOXY_PRESENTATION_BASE_POST_EXPOSURE_CALIBRATION,
		FOXY_PRESENTATION_POST_EXPOSURE_CALIBRATION,
		clamp(daylightWeight, 0.0, 1.0)
	);
}

// The three ray modes are compile-time exclusive.  SSGI and VXGI share
// one trace/history/denoise chain, while AO allocates and dispatches neither.
#if FOXY_RAY_MODE > 0
	#define FOXY_RAY_ACTIVE 1
#else
	#define FOXY_RAY_ACTIVE 0
#endif
#if FOXY_RAY_MODE == 1
	#define FOXY_SSPT 1
#else
	#define FOXY_SSPT 0
#endif
#if FOXY_RAY_MODE == 2
	#define FOXY_VOXEL_GI_ACTIVE 1
#else
	#define FOXY_VOXEL_GI_ACTIVE 0
#endif
#if FOXY_VOXEL_GI_ACTIVE == 1 && FOXY_IRRADIANCE_CACHE == 1
	#define FOXY_IRRADIANCE_CACHE_ACTIVE 1
#else
	#define FOXY_IRRADIANCE_CACHE_ACTIVE 0
#endif
#if FOXY_SSPT == 1
	#define FOXY_SSPT_TRACE_ACTIVE 1
#else
	#define FOXY_SSPT_TRACE_ACTIVE 0
#endif
#if FOXY_RAY_ACTIVE == 1
	#define FOXY_SSPT_TEMPORAL_ACTIVE 1
#else
	#define FOXY_SSPT_TEMPORAL_ACTIVE 0
#endif
#if FOXY_RAY_ACTIVE == 1 || FOXY_MATERIAL_REFLECTIONS == 1
	#define FOXY_PT_GBUFFER_ACTIVE 1
#else
	#define FOXY_PT_GBUFFER_ACTIVE 0
#endif
#define FOXY_RAY_PIPELINE FOXY_RAY_ACTIVE
#if FOXY_VOXEL_GI_ACTIVE == 1
	#define FOXY_VOXEL_ACTIVE 1
	#define FOXY_VOXEL_SPACE 1
	const float voxelDistance = FOXY_VOXEL_GI_MAX_DISTANCE;
#else
	#define FOXY_VOXEL_ACTIVE 0
	#define FOXY_VOXEL_SPACE 0
#endif
#if FOXY_VOXEL_GI_ACTIVE == 1
	#define FOXY_VOXEL_TRACING 1
#else
	#define FOXY_VOXEL_TRACING 0
#endif

// Both traced modes supply their own geometric occlusion, so do not bake
// Minecraft corner darkening into block vertex colors while either is active.
#if FOXY_RAY_ACTIVE == 1
	const float ambientOcclusionLevel = 0.0;
#else
	const float ambientOcclusionLevel = 1.0;
#endif

#define FOXY_CLOUDS 1 // [0 1]
#define FOXY_CLOUD_QUALITY 0 // [0 1 2]
#define FOXY_CLOUD_STEPS 40 // [4 6 8 10 12 14 16 20 24 28 34 40 48 56 64 72 84]
#define FOXY_CLOUD_LIGHT_STEPS 6 // [1 2 3 4 5 6 8]
#define FOXY_CLOUD_MULTISCATTERING 0 // [0 1 2]
#define FOXY_CLOUD_COVERAGE 0.40 // [0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15 0.16 0.17 0.18 0.19 0.20 0.21 0.22 0.23 0.24 0.25 0.26 0.27 0.28 0.29 0.30 0.31 0.32 0.33 0.34 0.35 0.36 0.37 0.38 0.39 0.40 0.41 0.42 0.43 0.44 0.45 0.46 0.47 0.48 0.49 0.50 0.51 0.52 0.53 0.54 0.55 0.56 0.57 0.58 0.59 0.60 0.61 0.62 0.63 0.64 0.65 0.66 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.74 0.75 0.76 0.77 0.78 0.79 0.80 0.81 0.82 0.83 0.84 0.85 0.86 0.87 0.88 0.89 0.90 0.91 0.92 0.93 0.94 0.95 0.96 0.97 0.98 0.99 1.00]
#define FOXY_CLOUD_DENSITY 1.50 // [0.25 0.40 0.55 0.72 0.90 1.05 1.10 1.30 1.50]
#define FOXY_CLOUD_TEMPERATURE -1.0 // [-1.0 -0.75 -0.50 -0.25 0.0 0.25 0.50 0.75 1.0]
#define FOXY_CLOUD_SPEED 0.35 // [0.0 0.20 0.35 0.55 0.75 1.0 1.30]
#define FOXY_CLOUD_HEIGHT 520.0 // [256.0 320.0 420.0 520.0 640.0 800.0 960.0]
#define FOXY_CLOUD_THICKNESS 2500.0 // [800.0 1280.0 1800.0 2500.0 3200.0 4200.0 5600.0]
#define FOXY_CLOUD_RANGE 48000.0 // [24000.0 32000.0 48000.0 60000.0 80000.0 100000.0 120000.0]
#define FOXY_CLOUD_WORLD_SCALE 0.20 // [0.10 0.15 0.20 0.25 0.30 0.35 0.40 0.42 0.45 0.50 0.60 0.75 1.00]
#define FOXY_CLOUD_SHAPE_SCALE 1.0 // [0.60 0.70 0.80 0.90 1.0 1.10 1.20 1.35 1.50 1.70]
#define FOXY_CLOUD_BASE_BREAKUP 1.0 // [0.0 0.25 0.50 0.75 1.0 1.25 1.50 1.75 2.0]
#define FOXY_CLOUD_EDGE_SOFTNESS 1.0 // [0.50 0.65 0.80 0.90 1.0 1.15 1.30 1.50 1.75 2.0]
#define FOXY_CLOUD_BOTTOM_EROSION_SIZE 1.0 // [0.35 0.50 0.65 0.80 1.0 1.25 1.50 1.75 2.0 2.50 3.0]
#define FOXY_CLOUD_BOTTOM_RELIEF 1.0 // [0.0 0.20 0.35 0.50 0.65 0.80 1.0 1.20 1.40 1.60 1.80 2.0]
#define FOXY_CLOUD_SHAPE_BASE_SCALE 0.000075 // [0.000020 0.000035 0.000050 0.000065 0.000075 0.000090 0.000120]
#define FOXY_CLOUD_SHAPE_DETAIL_SCALE 0.001120 // [0.000020 0.000080 0.000160 0.000320 0.000560 0.000720 0.000920 0.001060 0.001120 0.001300 0.001500 0.001700 0.002000]
#define FOXY_CLOUD_CLOUD_SIZE 0.37 // [0.10 0.16 0.22 0.28 0.37 0.45 0.58 0.72 0.86 1.0]
#define FOXY_CLOUD_HORIZONTAL_COVERAGE_BIAS 0.08 // [-0.65 -0.64 -0.63 -0.62 -0.61 -0.60 -0.59 -0.58 -0.57 -0.56 -0.55 -0.54 -0.53 -0.52 -0.51 -0.50 -0.49 -0.48 -0.47 -0.46 -0.45 -0.44 -0.43 -0.42 -0.41 -0.40 -0.39 -0.38 -0.37 -0.36 -0.35 -0.34 -0.33 -0.32 -0.31 -0.30 -0.29 -0.28 -0.27 -0.26 -0.25 -0.24 -0.23 -0.22 -0.21 -0.20 -0.19 -0.18 -0.17 -0.16 -0.15 -0.14 -0.13 -0.12 -0.11 -0.10 -0.09 -0.08 -0.07 -0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15]
#define FOXY_CLOUD_VERTICAL_COVERAGE_BIAS 0.06 // [-0.65 -0.64 -0.63 -0.62 -0.61 -0.60 -0.59 -0.58 -0.57 -0.56 -0.55 -0.54 -0.53 -0.52 -0.51 -0.50 -0.49 -0.48 -0.47 -0.46 -0.45 -0.44 -0.43 -0.42 -0.41 -0.40 -0.39 -0.38 -0.37 -0.36 -0.35 -0.34 -0.33 -0.32 -0.31 -0.30 -0.29 -0.28 -0.27 -0.26 -0.25 -0.24 -0.23 -0.22 -0.21 -0.20 -0.19 -0.18 -0.17 -0.16 -0.15 -0.14 -0.13 -0.12 -0.11 -0.10 -0.09 -0.08 -0.07 -0.06 -0.05 -0.04 -0.03 -0.02 -0.01 0.00 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.10 0.11 0.12 0.13 0.14 0.15]
#define FOXY_CLOUD_CUMULUS_BIAS 1.0 // [0.0 0.20 0.40 0.60 0.80 1.0]
#define FOXY_CLOUD_EROSION_SCALE 3.0 // [0.0 0.20 0.40 0.56 0.68 0.82 1.0 1.35 1.70 2.20 3.0 3.5 4.0]
#define FOXY_CLOUD_BOTTOM_DENSITY_POWER 0.88 // [0.70 0.75 0.82 0.88 0.92 1.00 1.05 1.15 1.30]
#define FOXY_CLOUD_VERTICAL_SHEAR 0.0 // [0.0 0.08 0.16 0.25 0.38 0.50 0.65 0.82 1.0]
#define FOXY_CLOUD_HEIGHT_GRADIENT_SCALE 2.48 // [0.25 0.50 0.80 1.0 1.35 1.75 2.10 2.48 3.0 3.6 4.71]
#define FOXY_CLOUD_HEIGHT_GRADIENT_CONTRAST 1.37 // [0.25 0.50 0.75 1.0 1.20 1.37 1.60 1.90 2.20 2.53]
#define FOXY_CLOUD_TOP_LIMIT 2.0 // [0.55 0.70 0.85 1.0 1.20 1.45 1.70 2.0]
#define FOXY_CLOUD_HARD_HEIGHT_LIMIT 3.0 // [1.0 1.20 1.45 1.70 2.0 2.35 2.70 3.0]
#define FOXY_CLOUD_RENDER_RANGE_SCALE 1.0 // [1.0 4.0 8.0 16.0 24.0 32.0 48.0 57.0 72.0 88.0 100.0]
#define FOXY_CLOUD_SHADOW_STRENGTH 0.0 // [0.0 0.15 0.30 0.42 0.55 0.70 0.85]
const float sunPathRotation = -28.0; // [-45.0 -35.0 -28.0 -20.0 -10.0 0.0 10.0 20.0 28.0 35.0 45.0]
#define FOXY_SUN_PATH_ROTATION sunPathRotation
#define FOXY_SHADOW_FILTERING 1 // [0 1]
#define FOXY_SHADOW_QUALITY 0 // [0 1 2]
#define FOXY_SHADOW_RESOLUTION 1024 // [1024 1536 2048 3072 4096]
#define FOXY_SHADOW_DISTANCE 160.0 // [64.0 96.0 128.0 160.0 192.0 256.0 320.0]
#define FOXY_SHADOW_STRENGTH 1.0 // [0.0 0.25 0.50 0.65 0.82 0.92 1.0]
#define FOXY_SHADOW_SOFTNESS 0.25 // [0.0 0.08 0.15 0.25 0.35 0.50 0.75 1.0]
#define FOXY_SHADOW_WARP 0.88 // [0.0 0.35 0.55 0.70 0.82 0.88 0.92]
#define FOXY_SHADOW_AMBIENT_DARKEN 0.32 // [0.0 0.15 0.25 0.32 0.45 0.60 0.75]
#if FOXY_SHADOW_QUALITY <= 0
	#define FOXY_SHADOW_BLOCKER_SAMPLES 4
	#define FOXY_SHADOW_BLOCKER_BASE_SAMPLES 4
	#define FOXY_SHADOW_FILTER_SAMPLES 8
#elif FOXY_SHADOW_QUALITY == 1
	#define FOXY_SHADOW_BLOCKER_SAMPLES 6
	#define FOXY_SHADOW_BLOCKER_BASE_SAMPLES 4
	#define FOXY_SHADOW_FILTER_SAMPLES 12
#else
	#define FOXY_SHADOW_BLOCKER_SAMPLES 8
	#define FOXY_SHADOW_BLOCKER_BASE_SAMPLES 4
	#define FOXY_SHADOW_FILTER_SAMPLES 16
#endif
#define FOXY_WATER_REFLECTION 0.65 // [0.0 0.15 0.25 0.38 0.50 0.65 0.80]
#define FOXY_WATER_REFLECTION_STRETCH 0.55 // [0.15 0.25 0.40 0.55 0.75 1.0]
#define FOXY_WATER_SUN_GLINT 1.0 // [0.0 0.25 0.50 0.75 1.0 1.25 1.50 2.0]
#define FOXY_WATER_UNDERWATER 0.65 // [0.0 0.25 0.45 0.65 0.85 1.0]
#define FOXY_UNDERWATER_VL_STRENGTH 2.0 // [0.0 0.25 0.50 0.75 1.0 1.5 2.0 3.0 4.0 5.0 6.0 8.0 10.0]
#define FOXY_WATER_FOG 0.75 // [0.0 0.25 0.45 0.65 0.75 0.90 1.0]
#define FOXY_WATER_DENSITY 1.0 // [0.25 0.35 0.50 0.70 0.85 1.0 1.20 1.45 1.75 2.10 2.50 3.0]
#define FOXY_WATER_UNDERWATER_DIRECT_LIGHT 0.20 // [0.0 0.10 0.20 0.35 0.50 0.65 0.80 1.0 1.25 1.50 2.0 2.50 3.0]
#define FOXY_WATER_ABOVE_DIRECT_LIGHT 0.70 // [0.0 0.10 0.20 0.30 0.40 0.50 0.60 0.70 0.80 0.90 1.0]
#define FOXY_WATER_CAUSTICS 0 // [0 1]
#define FOXY_WATER_CAUSTICS_BRIGHTNESS 0.65 // [0.0 0.10 0.20 0.35 0.50 0.65 0.80 1.0 1.25 1.50 2.0 2.50 3.0]
#define FOXY_WATER_SPECTRUM_WAVES 1 // [0 1]
#define FOXY_WATER_SPECTRUM_SCALE 1.0 // [0.25 0.35 0.50 0.70 0.85 1.0 1.25 1.50 2.0 3.0 4.0 6.0 8.0]
#define FOXY_WATER_SPECTRUM_VERTEX_HEIGHT 2.0 // [0.0 0.25 0.50 0.75 1.0 1.50 2.0 3.0 4.0 6.0 8.0]
#define FOXY_WATER_SPECTRUM_VERTEX_ANCHOR 0.60 // [0.0 0.25 0.40 0.50 0.60 0.75 0.90 1.0 1.25 1.50]
#define FOXY_WATER_SPECTRUM_LARGE_SCALE 3.0 // [0.25 0.35 0.50 0.70 0.85 1.0 1.25 1.50 2.0 3.0 4.0 6.0 8.0]
#define FOXY_WATER_SPECTRUM_LARGE_HEIGHT 6.0 // [0.0 0.25 0.50 0.75 1.0 1.50 2.0 3.0 4.0 6.0 8.0]
#define FOXY_WATER_SPECTRUM_MID_SCALE 3.0 // [0.25 0.35 0.50 0.70 0.85 1.0 1.25 1.50 2.0 3.0 4.0 6.0 8.0]
#define FOXY_WATER_SPECTRUM_MID_HEIGHT 1.50 // [0.0 0.25 0.50 0.75 1.0 1.50 2.0 3.0 4.0 6.0 8.0]
#define FOXY_WATER_SPECTRUM_FINE_SCALE 1.50 // [0.25 0.35 0.50 0.70 0.85 1.0 1.25 1.50 2.0 3.0 4.0 6.0 8.0]
#define FOXY_WATER_SPECTRUM_FINE_HEIGHT 0.75 // [0.0 0.25 0.50 0.75 1.0 1.50 2.0 3.0 4.0 6.0 8.0]
#define FOXY_WATER_SPECTRUM_WARP 0.75 // [0.0 0.25 0.50 0.75 1.0 1.50 2.0 3.0 4.0]
#define FOXY_WATER_SPECTRUM_NORMAL_DETAIL 1.0 // [0.0 0.25 0.50 0.75 1.0 1.50 2.0 3.0 4.0]
#define FOXY_WATER_WAVE_STRENGTH 0.55 // [0.0 0.25 0.40 0.55 0.70 0.85 1.0]
#define FOXY_WATER_WAVE_SPEED 1.75 // [0.0 0.25 0.45 0.65 0.85 1.0 1.35 1.75 2.0 2.5]
#define FOXY_WATER_NORMAL_AA_STRENGTH 1.0 // [0.0 0.25 0.50 0.75 1.0]
#define FOXY_WATER_OPT_FAST_REFLECTION_TRACE 0 // [0 1]
#define FOXY_WATER_OPT_SKIP_REFLECTION_REFINE 0 // [0 1]
#define FOXY_WATER_OPT_FAST_SHADOW 0 // [0 1]
#define FOXY_WATER_OPT_FAST_WAVE_NORMAL 0 // [0 1]


#define FOXY_SKY_LUT_WIDTH 256.0
#define FOXY_SKY_LUT_HEIGHT 192.0

const int shadowMapResolution = FOXY_SHADOW_RESOLUTION;
// sampler2DShadow always requires depth-compare mode. Lightweight shadows
// disable smoothing with nearest sampling and the single-tap shader path.
const bool shadowHardwareFiltering1 = true;
#if FOXY_SHADOW_FILTERING == 0
const bool shadowtex0Nearest = true;
const bool shadowtex1Nearest = true;
#else
const bool shadowtex0Nearest = false;
const bool shadowtex1Nearest = false;
#endif
#if FOXY_VOXEL_ACTIVE == 1
const float shadowDistance = max(
	FOXY_SHADOW_DISTANCE,
	FOXY_VOXEL_GI_MAX_DISTANCE
);
#else
const float shadowDistance = FOXY_SHADOW_DISTANCE;
#endif
const float shadowDistanceRenderMul = 1.0;

#endif
