Make reverse z define dynamic

This commit is contained in:
ExMatics HydrogenC
2024-06-05 21:51:07 +08:00
parent 1b6a31b6e5
commit 5d050ca020
2 changed files with 12 additions and 8 deletions
@@ -264,6 +264,9 @@ bool ShaderCompiler::OnCompileBegin()
const auto profile = GetProfile(); const auto profile = GetProfile();
const auto featureLevel = RenderTools::GetFeatureLevel(profile); const auto featureLevel = RenderTools::GetFeatureLevel(profile);
_globalMacros.Add({ "FEATURE_LEVEL", Numbers[(int32)featureLevel] }); _globalMacros.Add({ "FEATURE_LEVEL", Numbers[(int32)featureLevel] });
#if FLAX_REVERSE_Z
_globalMacros.Add({ "FLAX_REVERSE_Z", "1"});
#endif
return false; return false;
} }
+9 -8
View File
@@ -4,22 +4,26 @@
#define __COMMON__ #define __COMMON__
// Platform macros // Platform macros
#if !defined(DIRECTX) #ifndef DIRECTX
#define DIRECTX 0 #define DIRECTX 0
#endif #endif
#if !defined(OPENGL) #ifndef OPENGL
#define OPENGL 0 #define OPENGL 0
#endif #endif
#if !defined(VULKAN) #ifndef VULKAN
#define VULKAN 0 #define VULKAN 0
#endif #endif
#if defined(PLATFORM_PS4) #ifdef PLATFORM_PS4
#include "./FlaxPlatforms/PS4/Shaders/PS4Common.hlsl" #include "./FlaxPlatforms/PS4/Shaders/PS4Common.hlsl"
#endif #endif
#if defined(PLATFORM_PS5) #ifdef PLATFORM_PS5
#include "./FlaxPlatforms/PS5/Shaders/PS5Common.hlsl" #include "./FlaxPlatforms/PS5/Shaders/PS5Common.hlsl"
#endif #endif
#ifndef FLAX_REVERSE_Z
#define FLAX_REVERSE_Z 0
#endif
// Feature levels // Feature levels
#define FEATURE_LEVEL_ES2 0 #define FEATURE_LEVEL_ES2 0
#define FEATURE_LEVEL_ES3 1 #define FEATURE_LEVEL_ES3 1
@@ -53,9 +57,6 @@
#define SHADING_MODEL_SUBSURFACE 2 #define SHADING_MODEL_SUBSURFACE 2
#define SHADING_MODEL_FOLIAGE 3 #define SHADING_MODEL_FOLIAGE 3
// Didn't figure out how to pass compilation flags via C++, so hardcode it temporarily
#define FLAX_REVERSE_Z 1
// Detect feature level support // Detect feature level support
#if FEATURE_LEVEL >= FEATURE_LEVEL_SM5 #if FEATURE_LEVEL >= FEATURE_LEVEL_SM5
#define CAN_USE_GATHER 1 #define CAN_USE_GATHER 1