From fb21ffd3be5def9f61e9c76d7fce9c074fe8224a Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Fri, 8 May 2026 10:52:46 +0200 Subject: [PATCH] Rename `FLAX_REVERSE_Z` macro to `REVERSE_Z` #2684 --- Flax.flaxproj | 1 + Source/Editor/Gizmo/SelectionOutline.cs | 2 +- Source/Editor/Viewport/EditorViewport.cs | 2 +- Source/Engine/Core/Math/BoundingFrustum.cpp | 2 +- Source/Engine/Core/Math/BoundingFrustum.cs | 2 +- Source/Engine/Core/Math/Matrix.cpp | 4 ++-- Source/Engine/Core/Math/Matrix.cs | 6 +++--- Source/Engine/Graphics/GPUContext.h | 2 +- Source/Engine/Graphics/GPUDevice.cpp | 6 +++--- .../Materials/DeferredMaterialShader.cpp | 4 ++-- .../Materials/DeformableMaterialShader.cpp | 2 +- .../Materials/ForwardMaterialShader.cpp | 2 +- .../Materials/TerrainMaterialShader.cpp | 2 +- Source/Engine/Graphics/RenderTools.cpp | 6 +++--- Source/Engine/Graphics/RenderTools.h | 2 +- Source/Engine/Graphics/RenderView.cpp | 2 +- Source/Engine/Level/Actors/Sky.cpp | 2 +- Source/Engine/Renderer/DepthOfFieldPass.cpp | 2 +- Source/Engine/Renderer/LightPass.cpp | 4 ++-- Source/Engine/Renderer/ShadowsPass.cpp | 4 ++-- .../ShadersCompilation/ShaderCompiler.cpp | 4 ++-- Source/Shaders/Common.hlsl | 17 ++++++++++++++--- Source/Shaders/DebugDraw.shader | 2 +- Source/Shaders/ShadowsCommon.hlsl | 4 ++-- Source/Tools/Flax.Build/Build/ProjectTarget.cs | 8 +++----- Source/Tools/Flax.Build/Configuration.cs | 12 ++++++------ 26 files changed, 58 insertions(+), 48 deletions(-) diff --git a/Flax.flaxproj b/Flax.flaxproj index fadf436c3..a6039f368 100644 --- a/Flax.flaxproj +++ b/Flax.flaxproj @@ -13,6 +13,7 @@ "Configuration": { "UseCSharp": true, "UseLargeWorlds": false, + "UseReverseZ": true, "UseDotNet": true, "Windows": { "UseSDL": false, diff --git a/Source/Editor/Gizmo/SelectionOutline.cs b/Source/Editor/Gizmo/SelectionOutline.cs index 00f83ccac..618d3487f 100644 --- a/Source/Editor/Gizmo/SelectionOutline.cs +++ b/Source/Editor/Gizmo/SelectionOutline.cs @@ -147,7 +147,7 @@ namespace FlaxEditor.Gizmo _material.SetParameterValue("OutlineColor0", _color0); _material.SetParameterValue("OutlineColor1", _color1); _material.SetParameterValue("CustomDepth", customDepth); -#if FLAX_REVERSE_Z +#if REVERSE_Z _material.SetParameterValue("ViewInfo", new Float4(1.0f / projection.M11, 1.0f / projection.M22, -near / (far - near), (far * near) / (far - near) / far)); #else _material.SetParameterValue("ViewInfo", new Float4(1.0f / projection.M11, 1.0f / projection.M22, far / (far - near), -(far * near) / (far - near) / far)); diff --git a/Source/Editor/Viewport/EditorViewport.cs b/Source/Editor/Viewport/EditorViewport.cs index e6a1c436d..b8d0d8515 100644 --- a/Source/Editor/Viewport/EditorViewport.cs +++ b/Source/Editor/Viewport/EditorViewport.cs @@ -1498,7 +1498,7 @@ namespace FlaxEditor.Viewport ivp.Invert(); // Create near and far points, with device depth of 1 and 0 respectively -#if FLAX_REVERSE_Z +#if REVERSE_Z var nearPoint = new Vector3(mousePosition, 1.0f); var farPoint = new Vector3(mousePosition, 0.0f); #else diff --git a/Source/Engine/Core/Math/BoundingFrustum.cpp b/Source/Engine/Core/Math/BoundingFrustum.cpp index 091badd72..2eab04a40 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.cpp +++ b/Source/Engine/Core/Math/BoundingFrustum.cpp @@ -60,7 +60,7 @@ void BoundingFrustum::SetMatrix(const Matrix& matrix) _pFar.D = matrix.M44 - matrix.M43; _pFar.Normalize(); -#if FLAX_REVERSE_Z +#if REVERSE_Z // Swap far and near planes if reverse z Swap(_pFar, _pNear); #endif diff --git a/Source/Engine/Core/Math/BoundingFrustum.cs b/Source/Engine/Core/Math/BoundingFrustum.cs index aa2f09d53..0b295c7d5 100644 --- a/Source/Engine/Core/Math/BoundingFrustum.cs +++ b/Source/Engine/Core/Math/BoundingFrustum.cs @@ -244,7 +244,7 @@ namespace FlaxEngine far.D = matrix.M44 - matrix.M43; far.Normalize(); -#if FLAX_REVERSE_Z +#if REVERSE_Z // Swap far and near planes if reverse z (near, far) = (far, near); #endif diff --git a/Source/Engine/Core/Math/Matrix.cpp b/Source/Engine/Core/Math/Matrix.cpp index 9902e5bdd..f3e69df49 100644 --- a/Source/Engine/Core/Math/Matrix.cpp +++ b/Source/Engine/Core/Math/Matrix.cpp @@ -524,7 +524,7 @@ void Matrix::OrthoOffCenter(float left, float right, float bottom, float top, fl result.M22 = 2.0f / (top - bottom); result.M41 = (left + right) / (left - right); result.M42 = (top + bottom) / (bottom - top); -#if FLAX_REVERSE_Z +#if REVERSE_Z result.M33 = -zRange; result.M43 = zFar * zRange; #else @@ -554,7 +554,7 @@ void Matrix::PerspectiveOffCenter(float left, float right, float bottom, float t result.M31 = (left + right) / (left - right); result.M32 = (top + bottom) / (bottom - top); result.M34 = 1.0f; -#if FLAX_REVERSE_Z +#if REVERSE_Z result.M33 = -zNear * zRange; result.M43 = zFar * zNear * zRange; #else diff --git a/Source/Engine/Core/Math/Matrix.cs b/Source/Engine/Core/Math/Matrix.cs index fab146a9e..cbec2f119 100644 --- a/Source/Engine/Core/Math/Matrix.cs +++ b/Source/Engine/Core/Math/Matrix.cs @@ -2178,7 +2178,7 @@ namespace FlaxEngine result.M22 = 2.0f / (top - bottom); result.M41 = (left + right) / (left - right); result.M42 = (top + bottom) / (bottom - top); -#if FLAX_REVERSE_Z +#if REVERSE_Z result.M33 = -zRange; result.M43 = zfar * zRange; #else @@ -2249,7 +2249,7 @@ namespace FlaxEngine M11 = yScale / aspect, M22 = yScale, M34 = 1.0f, -#if FLAX_REVERSE_Z +#if REVERSE_Z M33 = -znear * zRange, M43 = znear * zfar * zRange, #else @@ -2293,7 +2293,7 @@ namespace FlaxEngine M31 = (left + right) / (left - right), M32 = (top + bottom) / (bottom - top), M34 = 1.0f, -#if FLAX_REVERSE_Z +#if REVERSE_Z M33 = -znear * zRange, M43 = znear * zfar * zRange, #else diff --git a/Source/Engine/Graphics/GPUContext.h b/Source/Engine/Graphics/GPUContext.h index 9a55957ce..db66d72f5 100644 --- a/Source/Engine/Graphics/GPUContext.h +++ b/Source/Engine/Graphics/GPUContext.h @@ -14,7 +14,7 @@ #undef MemoryBarrier #endif -#if FLAX_REVERSE_Z +#if REVERSE_Z #define GPU_DEPTH_MIN_VALUE 1.0f #define GPU_DEPTH_MAX_VALUE 0.0f #define GPU_DEPTH_BOUNDS_SWAP(min, max) max, min diff --git a/Source/Engine/Graphics/GPUDevice.cpp b/Source/Engine/Graphics/GPUDevice.cpp index fb59ee22b..c93eb86d7 100644 --- a/Source/Engine/Graphics/GPUDevice.cpp +++ b/Source/Engine/Graphics/GPUDevice.cpp @@ -160,7 +160,7 @@ GPUPipelineState::Description GPUPipelineState::Description::Default = true, // DepthWriteEnable true, // DepthClipEnable false, // DepthBoundsEnable -#if FLAX_REVERSE_Z +#if REVERSE_Z ComparisonFunc::Greater, // DepthFunc #else ComparisonFunc::Less, // DepthFunc @@ -189,7 +189,7 @@ GPUPipelineState::Description GPUPipelineState::Description::DefaultNoDepth = false, // DepthWriteEnable false, // DepthClipEnable false, // DepthBoundsEnable -#if FLAX_REVERSE_Z +#if REVERSE_Z ComparisonFunc::Greater, // DepthFunc #else ComparisonFunc::Less, // DepthFunc @@ -218,7 +218,7 @@ GPUPipelineState::Description GPUPipelineState::Description::DefaultFullscreenTr false, // DepthWriteEnable false, // DepthClipEnable false, // DepthBoundsEnable -#if FLAX_REVERSE_Z +#if REVERSE_Z ComparisonFunc::Greater, // DepthFunc #else ComparisonFunc::Less, // DepthFunc diff --git a/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp b/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp index 9dca94b87..cc4662576 100644 --- a/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/DeferredMaterialShader.cpp @@ -182,7 +182,7 @@ bool DeferredMaterialShader::Load() // Motion Vectors pass psDesc.DepthWriteEnable = false; psDesc.DepthEnable = true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::GreaterEqual; #else psDesc.DepthFunc = ComparisonFunc::LessEqual; @@ -204,7 +204,7 @@ bool DeferredMaterialShader::Load() psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; psDesc.DepthEnable = true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::Greater; #else psDesc.DepthFunc = ComparisonFunc::Less; diff --git a/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp b/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp index 77e3072a9..de19f51f0 100644 --- a/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/DeformableMaterialShader.cpp @@ -178,7 +178,7 @@ bool DeformableMaterialShader::Load() psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; psDesc.DepthEnable = true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::Greater; #else psDesc.DepthFunc = ComparisonFunc::Less; diff --git a/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp b/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp index a0c3e77a0..034061ef8 100644 --- a/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/ForwardMaterialShader.cpp @@ -185,7 +185,7 @@ bool ForwardMaterialShader::Load() psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; psDesc.DepthEnable = true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::Greater; #else psDesc.DepthFunc = ComparisonFunc::Less; diff --git a/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp b/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp index 7dd266596..557131b13 100644 --- a/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp +++ b/Source/Engine/Graphics/Materials/TerrainMaterialShader.cpp @@ -189,7 +189,7 @@ bool TerrainMaterialShader::Load() psDesc.DepthClipEnable = false; psDesc.DepthWriteEnable = true; psDesc.DepthEnable = true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::Greater; #else psDesc.DepthFunc = ComparisonFunc::Less; diff --git a/Source/Engine/Graphics/RenderTools.cpp b/Source/Engine/Graphics/RenderTools.cpp index d57c6b743..e1d94b1a9 100644 --- a/Source/Engine/Graphics/RenderTools.cpp +++ b/Source/Engine/Graphics/RenderTools.cpp @@ -684,7 +684,7 @@ float RenderTools::TemporalHalton(int32 index, int32 base) Float2 RenderTools::GetDepthBounds(const RenderView& view, const Float3& nearPoint, const Float3& farPoint) { -#if FLAX_REVERSE_Z +#if REVERSE_Z Float3 viewNearPoint = Float3::Transform(nearPoint, view.View); Float3 viewFarPoint = Float3::Transform(farPoint, view.View); @@ -727,7 +727,7 @@ Float2 RenderTools::GetDepthBounds(const RenderView& view, const BoundingSphere& Float2 RenderTools::GetDepthBounds(const RenderView& view, const Span& points) { -#if FLAX_REVERSE_Z +#if REVERSE_Z // Find min and max view depth range for list of points float nearDepth = view.Far, farDepth = view.Near; for (int32 i = 0; i < points.Length(); i++) @@ -781,7 +781,7 @@ Float2 RenderTools::GetDepthBounds(const RenderView& view, const OrientedBoundin float RenderTools::GetDepthBounds(const RenderView& view, const Float3& point, bool near) { -#if FLAX_REVERSE_Z +#if REVERSE_Z Float3 viewPoint = Float3::Transform(point, view.View); viewPoint.Z = Math::Clamp(viewPoint.Z, view.Near, view.Far); diff --git a/Source/Engine/Graphics/RenderTools.h b/Source/Engine/Graphics/RenderTools.h index 87880d084..58e867ba3 100644 --- a/Source/Engine/Graphics/RenderTools.h +++ b/Source/Engine/Graphics/RenderTools.h @@ -174,7 +174,7 @@ public: static float GetDepthBounds(const RenderView& view, const Float3& point, bool near); static float GetDepthBounds(const RenderView& view, float viewDistance, bool near); // Skip background/sky pixels from shading -#if FLAX_REVERSE_Z +#if REVERSE_Z static constexpr float DepthBoundMaxBackground = 0.0000001f; #else static constexpr float DepthBoundMaxBackground = 1.0f - 0.0000001f; diff --git a/Source/Engine/Graphics/RenderView.cpp b/Source/Engine/Graphics/RenderView.cpp index bdfe43882..697be453d 100644 --- a/Source/Engine/Graphics/RenderView.cpp +++ b/Source/Engine/Graphics/RenderView.cpp @@ -65,7 +65,7 @@ void RenderView::Prepare(RenderContext& renderContext) void RenderView::PrepareCache(const RenderContext& renderContext, float width, float height, const Float2& temporalAAJitter, const RenderView* mainView) { // The same format used by the Flax common shaders and postFx materials -#if FLAX_REVERSE_Z +#if REVERSE_Z ViewInfo = Float4(1.0f / Projection.M11, 1.0f / Projection.M22, -Near / (Far - Near), (Far * Near) / (Far - Near) / Far); #else ViewInfo = Float4(1.0f / Projection.M11, 1.0f / Projection.M22, Far / (Far - Near), -(Far * Near) / (Far - Near) / Far); diff --git a/Source/Engine/Level/Actors/Sky.cpp b/Source/Engine/Level/Actors/Sky.cpp index 5f5e34c29..fd95e61d0 100644 --- a/Source/Engine/Level/Actors/Sky.cpp +++ b/Source/Engine/Level/Actors/Sky.cpp @@ -103,7 +103,7 @@ void Sky::Draw(RenderContext& renderContext) psDesc.CullMode = CullMode::Inverted; psDesc.DepthWriteEnable = false; psDesc.DepthClipEnable = false; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::GreaterEqual; #else psDesc.DepthFunc = ComparisonFunc::LessEqual; diff --git a/Source/Engine/Renderer/DepthOfFieldPass.cpp b/Source/Engine/Renderer/DepthOfFieldPass.cpp index 29807d440..a015d8d82 100644 --- a/Source/Engine/Renderer/DepthOfFieldPass.cpp +++ b/Source/Engine/Renderer/DepthOfFieldPass.cpp @@ -271,7 +271,7 @@ void DepthOfFieldPass::Render(RenderContext& renderContext, GPUTexture*& frame, cbData.BokehTargetSize.Y = static_cast(bokehTargetHeight); // TODO: use projection matrix instead of this far and near stuff? -#if FLAX_REVERSE_Z +#if REVERSE_Z cbData.ProjectionAB.X = -nearPlane / (farPlane - nearPlane); cbData.ProjectionAB.Y = (farPlane * nearPlane) / (farPlane - nearPlane); #else diff --git a/Source/Engine/Renderer/LightPass.cpp b/Source/Engine/Renderer/LightPass.cpp index bde260423..5ddc93705 100644 --- a/Source/Engine/Renderer/LightPass.cpp +++ b/Source/Engine/Renderer/LightPass.cpp @@ -90,7 +90,7 @@ bool LightPass::setupResources() psDesc.CullMode = CullMode::Normal; if (_psLightLocal.Create(psDesc, shader, "PS_LocalLight")) return true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::Less; #else psDesc.DepthFunc = ComparisonFunc::Greater; @@ -111,7 +111,7 @@ bool LightPass::setupResources() psDesc.CullMode = CullMode::Normal; if (_psLightSky->Init(psDesc)) return true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::Less; #else psDesc.DepthFunc = ComparisonFunc::Greater; diff --git a/Source/Engine/Renderer/ShadowsPass.cpp b/Source/Engine/Renderer/ShadowsPass.cpp index ccdf2fff5..3c580afaf 100644 --- a/Source/Engine/Renderer/ShadowsPass.cpp +++ b/Source/Engine/Renderer/ShadowsPass.cpp @@ -536,7 +536,7 @@ bool ShadowsPass::setupResources() psDesc.CullMode = CullMode::Normal; if (_psShadowPoint.Create(psDesc, shader, psLocalLight)) return true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::Less; #else psDesc.DepthFunc = ComparisonFunc::Greater; @@ -555,7 +555,7 @@ bool ShadowsPass::setupResources() psDesc.CullMode = CullMode::Normal; if (_psShadowSpot.Create(psDesc, shader, psLocalLight, 8)) return true; -#if FLAX_REVERSE_Z +#if REVERSE_Z psDesc.DepthFunc = ComparisonFunc::Less; #else psDesc.DepthFunc = ComparisonFunc::Greater; diff --git a/Source/Engine/ShadersCompilation/ShaderCompiler.cpp b/Source/Engine/ShadersCompilation/ShaderCompiler.cpp index ec4c54b02..4b46a960f 100644 --- a/Source/Engine/ShadersCompilation/ShaderCompiler.cpp +++ b/Source/Engine/ShadersCompilation/ShaderCompiler.cpp @@ -249,8 +249,8 @@ 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"}); +#if REVERSE_Z + _globalMacros.Add({ "REVERSE_Z", "1"}); #endif return false; diff --git a/Source/Shaders/Common.hlsl b/Source/Shaders/Common.hlsl index b12cd4b71..ce606291a 100644 --- a/Source/Shaders/Common.hlsl +++ b/Source/Shaders/Common.hlsl @@ -20,8 +20,18 @@ #include "./FlaxPlatforms/PS5/Shaders/PS5Common.hlsl" #endif -#ifndef FLAX_REVERSE_Z -#define FLAX_REVERSE_Z 0 +// Reversed Z support +#ifndef REVERSE_Z +#define REVERSE_Z 0 +#endif +#if REVERSE_Z +#define DEPTH_MIN_VALUE 1 +#define DEPTH_MAX_VALUE 0 +//#define DEPTH_CMP(l, r) l > r +#else +#define DEPTH_MIN_VALUE 0 +#define DEPTH_MAX_VALUE 1 +//#define DEPTH_CMP(l, r) l < r #endif // Feature levels @@ -161,10 +171,11 @@ float4 LoadTextureWGSL(Texture2D tex, float2 uv) #else #define SAMPLE_RT_DEPTH(rt, texCoord) SAMPLE_RT(rt, texCoord).r #endif + +// General purpose constants #define HDR_CLAMP_MAX 65472.0 #define PI 3.1415926535897932 #define UNITS_TO_METERS_SCALE 0.01f -#define REVERSE_Z 0 // Structure that contains information about GBuffer struct GBufferData diff --git a/Source/Shaders/DebugDraw.shader b/Source/Shaders/DebugDraw.shader index 7dd52596d..ef3c855db 100644 --- a/Source/Shaders/DebugDraw.shader +++ b/Source/Shaders/DebugDraw.shader @@ -41,7 +41,7 @@ float4 PS(VS2PS input) : SV_Target { float sceneDepthDeviceZ = SceneDepthTexture.Load(int3(input.Position.xy, 0)).r; float interpolatedDeviceZ = input.Position.z; -#if FLAX_REVERSE_Z +#if REVERSE_Z clip(interpolatedDeviceZ - sceneDepthDeviceZ); #else clip(sceneDepthDeviceZ - interpolatedDeviceZ); diff --git a/Source/Shaders/ShadowsCommon.hlsl b/Source/Shaders/ShadowsCommon.hlsl index e5e896bd2..3e26f37ae 100644 --- a/Source/Shaders/ShadowsCommon.hlsl +++ b/Source/Shaders/ShadowsCommon.hlsl @@ -75,7 +75,7 @@ float3 GetShadowPositionOffset(float offsetScale, float NoL, float3 normal) float CalculateSubsurfaceOcclusion(float opacity, float sceneDepth, float shadowMapDepth) { // `sceneDepth` and `shadowMapDepth`are raw depths, so we have to flip them when reverse-z is enabled -#if FLAX_REVERSE_Z +#if REVERSE_Z float thickness = max(shadowMapDepth - sceneDepth, 0); #else float thickness = max(sceneDepth - shadowMapDepth, 0); @@ -83,7 +83,7 @@ float CalculateSubsurfaceOcclusion(float opacity, float sceneDepth, float shadow float occlusion = 1 - saturate(thickness * lerp(1.0f, 100.0f, opacity)); -#if FLAX_REVERSE_Z +#if REVERSE_Z return shadowMapDepth < 0.01f ? 1 : occlusion; #else return shadowMapDepth > 0.99f ? 1 : occlusion; diff --git a/Source/Tools/Flax.Build/Build/ProjectTarget.cs b/Source/Tools/Flax.Build/Build/ProjectTarget.cs index 1ee3a0973..42ff62924 100644 --- a/Source/Tools/Flax.Build/Build/ProjectTarget.cs +++ b/Source/Tools/Flax.Build/Build/ProjectTarget.cs @@ -88,12 +88,10 @@ namespace Flax.Build options.CompileEnv.PreprocessorDefinitions.Add("PLATFORM_SDL"); options.ScriptingAPI.Defines.Add("PLATFORM_SDL"); } - - if (!EngineConfiguration.WithTraditionalZ(options)) + if (EngineConfiguration.WithReverseZ(options)) { - // Add reverse-z definitions - options.CompileEnv.PreprocessorDefinitions.Add("FLAX_REVERSE_Z"); - options.ScriptingAPI.Defines.Add("FLAX_REVERSE_Z"); + options.CompileEnv.PreprocessorDefinitions.Add("REVERSE_Z"); + options.ScriptingAPI.Defines.Add("REVERSE_Z"); } // Add include paths for this and all referenced projects sources diff --git a/Source/Tools/Flax.Build/Configuration.cs b/Source/Tools/Flax.Build/Configuration.cs index 77ea2543f..e9da81cae 100644 --- a/Source/Tools/Flax.Build/Configuration.cs +++ b/Source/Tools/Flax.Build/Configuration.cs @@ -307,10 +307,10 @@ namespace Flax.Build public static bool UseLargeWorlds = false; /// - /// 1 to use traditional z buffer, or reversed z will be adopted by default. + /// 1 to use reversed Z Buffer, or traditional one. /// - [CommandLine("noReverseZ", "1 to use traditional z buffer, or reversed z will be adopted by default.")] - public static bool NoReverseZ = false; + [CommandLine("useReverseZ", "1 to use reversed Z Buffer, or traditional one.")] + public static bool UseReverseZ = false; /// /// True if managed C# scripting should be enabled, otherwise false. Engine without C# is partially supported and can be used when porting to a new platform before implementing C# runtime on it. @@ -349,10 +349,10 @@ namespace Flax.Build return UseLargeWorlds; } - public static bool WithTraditionalZ(NativeCpp.BuildOptions options) + public static bool WithReverseZ(NativeCpp.BuildOptions options) { - // Whether to use traditional z-buffer instead of reversed z - return NoReverseZ; + // Whether to use traditional z-buffer or reversed depth + return UseReverseZ; } public static bool WithDotNet(NativeCpp.BuildOptions options)