From b505660b63edd9c3e46b972c02a2f300bfe38c1d Mon Sep 17 00:00:00 2001 From: Marc Garcia Puig Date: Fri, 24 Jul 2020 11:43:38 +0200 Subject: [PATCH] Exposed camera bloom and lens flare effect --- .../Actor/ActorBlueprintFunctionLibrary.cpp | 20 ++++++++++++++++ .../Carla/Sensor/SceneCaptureSensor.cpp | 24 +++++++++++++++++++ .../Source/Carla/Sensor/SceneCaptureSensor.h | 12 ++++++++++ 3 files changed, 56 insertions(+) diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorBlueprintFunctionLibrary.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorBlueprintFunctionLibrary.cpp index da687dba0..d12931317 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorBlueprintFunctionLibrary.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Actor/ActorBlueprintFunctionLibrary.cpp @@ -405,6 +405,20 @@ void UActorBlueprintFunctionLibrary::MakeCameraDefinition( MBMinObjectScreenSize.RecommendedValues = { TEXT("0.1") }; MBMinObjectScreenSize.bRestrictToRecommended = false; + // Lens Flare + FActorVariation LensFlareIntensity; + LensFlareIntensity.Id = TEXT("lens_flare_intensity"); + LensFlareIntensity.Type = EActorAttributeType::Float; + LensFlareIntensity.RecommendedValues = { TEXT("0.1") }; + LensFlareIntensity.bRestrictToRecommended = false; + + // Bloom + FActorVariation BloomIntensity; + BloomIntensity.Id = TEXT("bloom_intensity"); + BloomIntensity.Type = EActorAttributeType::Float; + BloomIntensity.RecommendedValues = { TEXT("0.675") }; + BloomIntensity.bRestrictToRecommended = false; + // More info at: // https://docs.unrealengine.com/en-US/Engine/Rendering/PostProcessEffects/AutomaticExposure/index.html // https://docs.unrealengine.com/en-US/Engine/Rendering/PostProcessEffects/DepthOfField/CinematicDOFMethods/index.html @@ -605,6 +619,8 @@ void UActorBlueprintFunctionLibrary::MakeCameraDefinition( Gamma, MBIntesity, MBMaxDistortion, + LensFlareIntensity, + BloomIntensity, MBMinObjectScreenSize, ExposureMinBright, ExposureMaxBright, @@ -1361,6 +1377,10 @@ void UActorBlueprintFunctionLibrary::SetCamera( RetrieveActorAttributeToFloat("motion_blur_max_distortion", Description.Variations, 5.0f)); Camera->SetMotionBlurMinObjectScreenSize( RetrieveActorAttributeToFloat("motion_blur_min_object_screen_size", Description.Variations, 0.5f)); + Camera->SetLensFlareIntensity( + RetrieveActorAttributeToFloat("lens_flare_intensity", Description.Variations, 0.1f)); + Camera->SetBloomIntensity( + RetrieveActorAttributeToFloat("bloom_intensity", Description.Variations, 0.675f)); // Exposure if (RetrieveActorAttributeToString("exposure_mode", Description.Variations, "manual") == "histogram") { diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp index 325841efa..18cc0e9ed 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.cpp @@ -366,6 +366,30 @@ float ASceneCaptureSensor::GetMotionBlurMinObjectScreenSize() const return CaptureComponent2D->PostProcessSettings.MotionBlurPerObjectSize; } +void ASceneCaptureSensor::SetLensFlareIntensity(float Intensity) +{ + check(CaptureComponent2D != nullptr); + CaptureComponent2D->PostProcessSettings.LensFlareIntensity = Intensity; +} + +float ASceneCaptureSensor::GetLensFlareIntensity() const +{ + check(CaptureComponent2D != nullptr); + return CaptureComponent2D->PostProcessSettings.LensFlareIntensity; +} + +void ASceneCaptureSensor::SetBloomIntensity(float Intensity) +{ + check(CaptureComponent2D != nullptr); + CaptureComponent2D->PostProcessSettings.BloomIntensity = Intensity; +} + +float ASceneCaptureSensor::GetBloomIntensity() const +{ + check(CaptureComponent2D != nullptr); + return CaptureComponent2D->PostProcessSettings.BloomIntensity; +} + void ASceneCaptureSensor::SetWhiteTemp(float Temp) { check(CaptureComponent2D != nullptr); diff --git a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h index 40678d7e0..dbf49170a 100644 --- a/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h +++ b/Unreal/CarlaUE4/Plugins/Carla/Source/Carla/Sensor/SceneCaptureSensor.h @@ -217,6 +217,18 @@ public: UFUNCTION(BlueprintCallable) float GetMotionBlurMinObjectScreenSize() const; + UFUNCTION(BlueprintCallable) + void SetLensFlareIntensity(float Intensity); + + UFUNCTION(BlueprintCallable) + float GetLensFlareIntensity() const; + + UFUNCTION(BlueprintCallable) + void SetBloomIntensity(float Intensity); + + UFUNCTION(BlueprintCallable) + float GetBloomIntensity() const; + UFUNCTION(BlueprintCallable) void SetWhiteTemp(float Temp);