diff --git a/Source/Engine/Level/Actors/EnvironmentProbe.cpp b/Source/Engine/Level/Actors/EnvironmentProbe.cpp
index 3c49611d4..71b403eb9 100644
--- a/Source/Engine/Level/Actors/EnvironmentProbe.cpp
+++ b/Source/Engine/Level/Actors/EnvironmentProbe.cpp
@@ -197,6 +197,7 @@ void EnvironmentProbe::Draw(RenderContext& renderContext)
data.Position = position;
data.Radius = radius;
data.Brightness = Brightness;
+ data.SortOrder = SortOrder;
data.HashID = GetHash(_id);
renderContext.List->EnvironmentProbes.Add(data);
}
@@ -234,6 +235,7 @@ void EnvironmentProbe::Serialize(SerializeStream& stream, const void* otherObj)
SERIALIZE_MEMBER(Radius, _radius);
SERIALIZE(CubemapResolution);
SERIALIZE(Brightness);
+ SERIALIZE(SortOrder);
SERIALIZE(UpdateMode);
SERIALIZE(CaptureNearPlane);
SERIALIZE_MEMBER(IsCustomProbe, _isUsingCustomProbe);
@@ -248,6 +250,7 @@ void EnvironmentProbe::Deserialize(DeserializeStream& stream, ISerializeModifier
DESERIALIZE_MEMBER(Radius, _radius);
DESERIALIZE(CubemapResolution);
DESERIALIZE(Brightness);
+ DESERIALIZE(SortOrder);
DESERIALIZE(UpdateMode);
DESERIALIZE(CaptureNearPlane);
DESERIALIZE_MEMBER(IsCustomProbe, _isUsingCustomProbe);
diff --git a/Source/Engine/Level/Actors/EnvironmentProbe.h b/Source/Engine/Level/Actors/EnvironmentProbe.h
index 7131dc0ba..09f771437 100644
--- a/Source/Engine/Level/Actors/EnvironmentProbe.h
+++ b/Source/Engine/Level/Actors/EnvironmentProbe.h
@@ -51,6 +51,12 @@ public:
API_FIELD(Attributes="EditorOrder(10), Limit(0, 1000, 0.01f), EditorDisplay(\"Probe\")")
float Brightness = 1.0f;
+ ///
+ /// The probe rendering order. The higher values are render later (on top).
+ ///
+ API_FIELD(Attributes = "EditorOrder(25), EditorDisplay(\"Probe\")")
+ int32 SortOrder = 0;
+
///
/// The probe update mode.
///
diff --git a/Source/Engine/Renderer/ReflectionsPass.cpp b/Source/Engine/Renderer/ReflectionsPass.cpp
index 3aa0ed6ee..631543010 100644
--- a/Source/Engine/Renderer/ReflectionsPass.cpp
+++ b/Source/Engine/Renderer/ReflectionsPass.cpp
@@ -335,12 +335,17 @@ void ReflectionsPass::Dispose()
bool SortProbes(RenderEnvironmentProbeData const& p1, RenderEnvironmentProbeData const& p2)
{
- // Compare by radius
- int32 res = static_cast(p2.Radius - p1.Radius);
+ // Compare by Sort Order
+ int32 res = p1.SortOrder - p2.SortOrder;
if (res == 0)
{
- // Compare by ID to prevent flickering
- res = p2.HashID - p1.HashID;
+ // Compare by radius
+ res = static_cast(p2.Radius - p1.Radius);
+ if (res == 0)
+ {
+ // Compare by ID to prevent flickering
+ res = p2.HashID - p1.HashID;
+ }
}
return res < 0;
}
diff --git a/Source/Engine/Renderer/RenderList.h b/Source/Engine/Renderer/RenderList.h
index 469bc2cdd..d5288e6ee 100644
--- a/Source/Engine/Renderer/RenderList.h
+++ b/Source/Engine/Renderer/RenderList.h
@@ -155,6 +155,7 @@ struct RenderEnvironmentProbeData
Float3 Position;
float Radius;
float Brightness;
+ int32 SortOrder;
uint32 HashID;
void SetShaderData(ShaderEnvProbeData& data) const;