diff --git a/Source/Engine/ShadersCompilation/ShaderCompiler.cpp b/Source/Engine/ShadersCompilation/ShaderCompiler.cpp index 72e3aacf8..eba3bd2ed 100644 --- a/Source/Engine/ShadersCompilation/ShaderCompiler.cpp +++ b/Source/Engine/ShadersCompilation/ShaderCompiler.cpp @@ -264,6 +264,9 @@ bool ShaderCompiler::OnCompileBegin() const auto profile = GetProfile(); const auto featureLevel = RenderTools::GetFeatureLevel(profile); _globalMacros.Add({ "FEATURE_LEVEL", Numbers[(int32)featureLevel] }); +#if FLAX_REVERSE_Z + _globalMacros.Add({ "FLAX_REVERSE_Z", "1"}); +#endif return false; } diff --git a/Source/Shaders/Common.hlsl b/Source/Shaders/Common.hlsl index d0c5ee858..433832698 100644 --- a/Source/Shaders/Common.hlsl +++ b/Source/Shaders/Common.hlsl @@ -4,22 +4,26 @@ #define __COMMON__ // Platform macros -#if !defined(DIRECTX) +#ifndef DIRECTX #define DIRECTX 0 #endif -#if !defined(OPENGL) +#ifndef OPENGL #define OPENGL 0 #endif -#if !defined(VULKAN) +#ifndef VULKAN #define VULKAN 0 #endif -#if defined(PLATFORM_PS4) +#ifdef PLATFORM_PS4 #include "./FlaxPlatforms/PS4/Shaders/PS4Common.hlsl" #endif -#if defined(PLATFORM_PS5) +#ifdef PLATFORM_PS5 #include "./FlaxPlatforms/PS5/Shaders/PS5Common.hlsl" #endif +#ifndef FLAX_REVERSE_Z +#define FLAX_REVERSE_Z 0 +#endif + // Feature levels #define FEATURE_LEVEL_ES2 0 #define FEATURE_LEVEL_ES3 1 @@ -53,9 +57,6 @@ #define SHADING_MODEL_SUBSURFACE 2 #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 #if FEATURE_LEVEL >= FEATURE_LEVEL_SM5 #define CAN_USE_GATHER 1