Expose partition mode, and cascade spacing.

This commit is contained in:
Menotdan
2023-12-31 15:09:07 -05:00
parent 4e34524a08
commit bf6cb90a78
6 changed files with 91 additions and 12 deletions

View File

@@ -41,6 +41,12 @@ void DirectionalLight::Draw(RenderContext& renderContext)
data.RenderedVolumetricFog = 0;
data.ShadowsMode = ShadowsMode;
data.CascadeCount = CascadeCount;
data.Cascade1Spacing = Cascade1Spacing;
data.Cascade2Spacing = Cascade2Spacing;
data.Cascade3Spacing = Cascade3Spacing;
data.Cascade4Spacing = Cascade4Spacing;
data.PartitionMode = PartitionMode;
data.ContactShadowsLength = ContactShadowsLength;
data.StaticFlags = GetStaticFlags();
data.ID = GetID();
@@ -56,6 +62,12 @@ void DirectionalLight::Serialize(SerializeStream& stream, const void* otherObj)
SERIALIZE_GET_OTHER_OBJ(DirectionalLight);
SERIALIZE(CascadeCount);
SERIALIZE(Cascade1Spacing);
SERIALIZE(Cascade2Spacing);
SERIALIZE(Cascade3Spacing);
SERIALIZE(Cascade4Spacing);
SERIALIZE(PartitionMode);
}
void DirectionalLight::Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
@@ -64,6 +76,12 @@ void DirectionalLight::Deserialize(DeserializeStream& stream, ISerializeModifier
LightWithShadow::Deserialize(stream, modifier);
DESERIALIZE(CascadeCount);
DESERIALIZE(Cascade1Spacing);
DESERIALIZE(Cascade2Spacing);
DESERIALIZE(Cascade3Spacing);
DESERIALIZE(Cascade4Spacing);
DESERIALIZE(PartitionMode);
}
bool DirectionalLight::IntersectsItself(const Ray& ray, Real& distance, Vector3& normal)

View File

@@ -12,12 +12,42 @@ class FLAXENGINE_API DirectionalLight : public LightWithShadow
{
DECLARE_SCENE_OBJECT(DirectionalLight);
public:
/// <summary>
/// The partitioning mode for the shadow cascades.
/// </summary>
API_FIELD(Attributes = "EditorOrder(64), DefaultValue(PartitionMode.Manual), EditorDisplay(\"Shadow\")")
PartitionMode PartitionMode = PartitionMode::Manual;
/// <summary>
/// The number of cascades used for slicing the range of depth covered by the light during shadow rendering. Values are 1, 2 or 4 cascades; a typical scene uses 4 cascades.
/// </summary>
API_FIELD(Attributes="EditorOrder(65), DefaultValue(4), Limit(1, 4), EditorDisplay(\"Shadow\")")
int32 CascadeCount = 4;
/// <summary>
/// Percentage of the shadow distance used by the first cascade.
/// </summary>
API_FIELD(Attributes = "EditorOrder(66), DefaultValue(0.05f), VisibleIf(nameof(ShowCascade1)), Limit(0, 1, 0.001f), EditorDisplay(\"Shadow\")")
float Cascade1Spacing = 0.05f;
/// <summary>
/// Percentage of the shadow distance used by the second cascade.
/// </summary>
API_FIELD(Attributes = "EditorOrder(67), DefaultValue(0.15f), VisibleIf(nameof(ShowCascade2)), Limit(0, 1, 0.001f), EditorDisplay(\"Shadow\")")
float Cascade2Spacing = 0.15f;
/// <summary>
/// Percentage of the shadow distance used by the third cascade.
/// </summary>
API_FIELD(Attributes = "EditorOrder(68), DefaultValue(0.50f), VisibleIf(nameof(ShowCascade3)), Limit(0, 1, 0.001f), EditorDisplay(\"Shadow\")")
float Cascade3Spacing = 0.50f;
/// <summary>
/// Percentage of the shadow distance used by the fourth cascade.
/// </summary>
API_FIELD(Attributes = "EditorOrder(69), DefaultValue(1.0f), VisibleIf(nameof(ShowCascade4)), Limit(0, 1, 0.001f), EditorDisplay(\"Shadow\")")
float Cascade4Spacing = 1.0f;
public:
// [LightWithShadow]
void Draw(RenderContext& renderContext) override;