Aaron/addoverridingforsensors (#7665)

* Add functioanlity to override postprocess in sensors

* Use if condition
This commit is contained in:
Blyron 2024-05-16 15:03:38 +02:00 committed by GitHub
parent 9132aec752
commit 298d44b31b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 86 additions and 1 deletions

View File

@ -8,6 +8,7 @@
#include "Carla.h"
#include "Carla/Game/CarlaStatics.h"
#include "Actor/ActorBlueprintFunctionLibrary.h"
#include "Engine/PostProcessVolume.h"
#include <mutex>
#include <atomic>
@ -448,6 +449,88 @@ float ASceneCaptureSensor::GetChromAberrOffset() const
return CaptureComponent2D->PostProcessSettings.ChromaticAberrationStartOffset;
}
bool ASceneCaptureSensor::ApplyPostProcessVolumeToSensor(APostProcessVolume* Origin, ASceneCaptureSensor* Dest, bool bOverrideCurrentCamera)
{
if(!IsValid(Origin) || !IsValid(Dest))
{
return false;
}
if(!bOverrideCurrentCamera)
{
//Cache postprocesssettings
float CacheGamma = Dest->GetTargetGamma();
EAutoExposureMethod CacheAutoExposureMethod = Dest->GetExposureMethod();
float CacheEC = Dest->GetExposureCompensation();
float CacheSS = Dest->GetShutterSpeed();
float CacheISO = Dest->GetISO();
float CacheA = Dest->GetAperture();
float CacheFD = Dest->GetFocalDistance();
float CacheDBA = Dest->GetDepthBlurAmount();
float CacheDBR = Dest->GetDepthBlurRadius();
float CacheBC = Dest->GetBladeCount();
float CacheDFMinFStop = Dest->GetDepthOfFieldMinFstop();
float CacheFS = Dest->GetFilmSlope();
float CacheFT = Dest->GetFilmToe();
float CacheFShoulder = Dest->GetFilmShoulder();
float CacheFBC = Dest->GetFilmBlackClip();
float CacheFWC = Dest->GetFilmWhiteClip();
float CacheEMinB = Dest->GetExposureMinBrightness();
float CacheEMaxB = Dest->GetExposureMaxBrightness();
float CacheESDown = Dest->GetExposureSpeedDown();
float CacheESUp = Dest->GetExposureSpeedUp();
float CacheCC = Dest->GetExposureCalibrationConstant();
float CacheMBI = Dest->GetMotionBlurIntensity();
float CacheMBMaxD = Dest->GetMotionBlurMaxDistortion();
float CacheMBMinOSS = Dest->GetMotionBlurMinObjectScreenSize();
float CacheLFI = Dest->GetLensFlareIntensity();
float CacheBI = Dest->GetBloomIntensity();
float CacheWTemp = Dest->GetWhiteTemp();
float CacheWTint = Dest->GetWhiteTint();
float CacheCAI = Dest->GetChromAberrIntensity();
float CacheCAO = Dest->GetChromAberrOffset();
Dest->CaptureComponent2D->PostProcessSettings = Origin->Settings;
Dest->SetTargetGamma(CacheGamma);
Dest->SetExposureMethod(CacheAutoExposureMethod);
Dest->SetExposureCompensation(CacheEC);
Dest->SetShutterSpeed(CacheSS);
Dest->SetISO(CacheISO);
Dest->SetAperture(CacheA);
Dest->SetFocalDistance(CacheFD);
Dest->SetDepthBlurAmount(CacheDBA);
Dest->SetDepthBlurRadius(CacheDBR);
Dest->SetBladeCount(CacheBC);
Dest->SetDepthOfFieldMinFstop(CacheDFMinFStop);
Dest->SetFilmSlope(CacheFS);
Dest->SetFilmToe(CacheFT);
Dest->SetFilmShoulder(CacheFShoulder);
Dest->SetFilmBlackClip(CacheFBC);
Dest->SetFilmWhiteClip(CacheFWC);
Dest->SetExposureMinBrightness(CacheEMinB);
Dest->SetExposureMaxBrightness(CacheEMaxB);
Dest->SetExposureSpeedDown(CacheESDown);
Dest->SetExposureSpeedUp(CacheESUp);
Dest->SetExposureCalibrationConstant(CacheCC);
Dest->SetMotionBlurIntensity(CacheMBI);
Dest->SetMotionBlurMaxDistortion(CacheMBMaxD);
Dest->SetMotionBlurMinObjectScreenSize(CacheMBMinOSS);
Dest->SetLensFlareIntensity(CacheLFI);
Dest->SetBloomIntensity(CacheBI);
Dest->SetWhiteTemp(CacheWTemp);
Dest->SetWhiteTint(CacheWTint);
Dest->SetChromAberrIntensity(CacheCAI);
Dest->SetChromAberrOffset(CacheCAO);
}
else
{
Dest->CaptureComponent2D->PostProcessSettings = Origin->Settings;
}
return true;
}
void ASceneCaptureSensor::EnqueueRenderSceneImmediate() {
TRACE_CPUPROFILER_EVENT_SCOPE(ASceneCaptureSensor::EnqueueRenderSceneImmediate);
// Creates an snapshot of the scene, requieres bCaptureEveryFrame = false.

View File

@ -27,7 +27,7 @@
class UDrawFrustumComponent;
class UStaticMeshComponent;
class UTextureRenderTarget2D;
class APostProcessVolume;
struct FCameraGBufferUint8
@ -423,6 +423,8 @@ public:
FCameraGBufferUint8 CustomStencil;
} CameraGBuffers;
UFUNCTION(BlueprintCallable)
static bool ApplyPostProcessVolumeToSensor(APostProcessVolume* Origin, ASceneCaptureSensor* Dest, bool bOverrideCurrentCamera = false);
protected:
void CaptureSceneExtended();