Settings tweaks for better performance
This commit is contained in:
@@ -297,12 +297,28 @@ void ATimeOfDayManager::RotateSun(const float &_rotator)
|
||||
{
|
||||
if (!enableTimeOfDay)
|
||||
return;
|
||||
if (!CurrentWeatherPreset || !CurrentWeatherPreset->SunRotationCurve)
|
||||
return;
|
||||
if (sunLight->IsValidLowLevel())
|
||||
{
|
||||
FVector currentRotInVectors = FVector(0.0f, CurrentWeatherPreset->SunRotationCurve->GetFloatValue(FloatMinutes),
|
||||
110.0f);
|
||||
FRotator currentSunRotation = FRotator(FRotator::MakeFromEuler(currentRotInVectors));
|
||||
sunLight->SetWorldRotation(currentSunRotation);
|
||||
|
||||
// The renderer only reuses its cached CSM shadow maps while the light matrix is bit-identical (the
|
||||
// cached shadow initializer is compared with == in the shadow setup), so re-orienting the light every
|
||||
// frame throws the whole cascade shadow map cache away every frame. Only move the light once the sun
|
||||
// actually travelled far enough to be worth the cache rebuild.
|
||||
const float PitchDelta = FMath::Abs(FMath::FindDeltaAngleDegrees(AppliedSunRotation.Pitch, currentSunRotation.Pitch));
|
||||
const float YawDelta = FMath::Abs(FMath::FindDeltaAngleDegrees(AppliedSunRotation.Yaw, currentSunRotation.Yaw));
|
||||
|
||||
if (bSunRotationDirty || SunRotationUpdateThreshold <= 0.0f || PitchDelta >= SunRotationUpdateThreshold ||
|
||||
YawDelta >= SunRotationUpdateThreshold)
|
||||
{
|
||||
sunLight->SetWorldRotation(currentSunRotation);
|
||||
AppliedSunRotation = currentSunRotation;
|
||||
bSunRotationDirty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -205,12 +205,29 @@ public:
|
||||
UPROPERTY(EditAnywhere, Category = "Time of Day - Lightning Setting")
|
||||
float daySpeed = 10.0f;
|
||||
|
||||
/** Minimum movement of the sun in degrees before the directional light is actually re-oriented.
|
||||
* The renderer only reuses its cached CSM shadow maps while the light matrix is completely unchanged
|
||||
* (the cached shadow initializer is compared with == in the shadow setup), so writing the light
|
||||
* transform every frame invalidates and releases the whole cascade shadow map cache every frame.
|
||||
* The light is re-oriented roughly every (SunRotationUpdateThreshold / sun degrees per second) seconds,
|
||||
* so the cache is reused for all the frames in between. 0 disables the throttle. */
|
||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Time of Day - Lightning Setting")
|
||||
float SunRotationUpdateThreshold = 0.1f;
|
||||
|
||||
UPROPERTY(EditAnywhere, Category = "Time of Day - Lightning Setting")
|
||||
FLinearColor SubsurfaceColorDay;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Category = "Time of Day - Info")
|
||||
float rotator;
|
||||
|
||||
/** Rotation that is currently applied to sunLight, used to throttle the per-frame SetWorldRotation. */
|
||||
UPROPERTY(VisibleAnywhere, Category = "Time of Day - Info")
|
||||
FRotator AppliedSunRotation;
|
||||
|
||||
/** True until the current sun rotation has been pushed into the light at least once. */
|
||||
UPROPERTY(VisibleAnywhere, Category = "Time of Day - Info")
|
||||
bool bSunRotationDirty = true;
|
||||
|
||||
UPROPERTY(VisibleAnywhere, Category = "Time of Day - Info")
|
||||
float CurrentWeaterFadeAlpha;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user