Add SortOrder to Environment Probe
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -51,6 +51,12 @@ public:
|
||||
API_FIELD(Attributes="EditorOrder(10), Limit(0, 1000, 0.01f), EditorDisplay(\"Probe\")")
|
||||
float Brightness = 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// The probe rendering order. The higher values are render later (on top).
|
||||
/// </summary>
|
||||
API_FIELD(Attributes = "EditorOrder(25), EditorDisplay(\"Probe\")")
|
||||
int32 SortOrder = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The probe update mode.
|
||||
/// </summary>
|
||||
|
||||
@@ -335,12 +335,17 @@ void ReflectionsPass::Dispose()
|
||||
|
||||
bool SortProbes(RenderEnvironmentProbeData const& p1, RenderEnvironmentProbeData const& p2)
|
||||
{
|
||||
// Compare by radius
|
||||
int32 res = static_cast<int32>(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<int32>(p2.Radius - p1.Radius);
|
||||
if (res == 0)
|
||||
{
|
||||
// Compare by ID to prevent flickering
|
||||
res = p2.HashID - p1.HashID;
|
||||
}
|
||||
}
|
||||
return res < 0;
|
||||
}
|
||||
|
||||
@@ -155,6 +155,7 @@ struct RenderEnvironmentProbeData
|
||||
Float3 Position;
|
||||
float Radius;
|
||||
float Brightness;
|
||||
int32 SortOrder;
|
||||
uint32 HashID;
|
||||
|
||||
void SetShaderData(ShaderEnvProbeData& data) const;
|
||||
|
||||
Reference in New Issue
Block a user