diff --git a/Assets/AWSIM/Scripts/Editor/Sensors/CameraSensorFeatureManagerEditor.cs b/Assets/AWSIM/Scripts/Editor/Sensors/CameraSensorFeatureManagerEditor.cs index 3bf801faa..9824a45be 100644 --- a/Assets/AWSIM/Scripts/Editor/Sensors/CameraSensorFeatureManagerEditor.cs +++ b/Assets/AWSIM/Scripts/Editor/Sensors/CameraSensorFeatureManagerEditor.cs @@ -3,50 +3,55 @@ namespace AWSIM { - + /// + /// Editor extension for camera sensor feature manager class. + /// [CustomEditor(typeof(CameraSensorFeatureManager))] public class CameraSensorFeatureManagerEditor : Editor { - - private CameraSensorFeatureManager manager; + private bool debugMode = false; private SerializedProperty hueProperty; private SerializedProperty saturationProperty; private SerializedProperty contrastProperty; private SerializedProperty postExposureProperty; + private SerializedProperty sharpnessProperty; private SerializedProperty exposureModeProperty; private SerializedProperty bloomEffectProperty; private SerializedProperty chromaticAberrationProperty; private SerializedProperty depthOfFieldProperty; - private SerializedProperty motionBlurProperty; private void OnEnable() { - manager = (CameraSensorFeatureManager)target; - hueProperty = serializedObject.FindProperty("hue"); saturationProperty = serializedObject.FindProperty("saturation"); contrastProperty = serializedObject.FindProperty("contrast"); postExposureProperty =serializedObject.FindProperty("postExposure"); + sharpnessProperty = serializedObject.FindProperty("sharpness"); exposureModeProperty = serializedObject.FindProperty("exposureMode"); bloomEffectProperty = serializedObject.FindProperty("bloomEffect"); chromaticAberrationProperty = serializedObject.FindProperty("chromaticAberration"); depthOfFieldProperty = serializedObject.FindProperty("depthOfField"); - motionBlurProperty = serializedObject.FindProperty("motionBlur"); } public override void OnInspectorGUI() { // ------ Components ------- // - EditorGUILayout.PropertyField(serializedObject.FindProperty("camera"), true); - EditorGUILayout.PropertyField(serializedObject.FindProperty("cameraSensor"), true); - EditorGUILayout.PropertyField(serializedObject.FindProperty("volume"), true); - EditorGUILayout.PropertyField(serializedObject.FindProperty("profile"), true); + + debugMode = GUILayout.Toggle(debugMode, new GUIContent("Show Components", "Debug mode to see the references to the required components"), "Button"); + + if(debugMode) + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("camera"), true); + EditorGUILayout.PropertyField(serializedObject.FindProperty("cameraSensor"), true); + EditorGUILayout.PropertyField(serializedObject.FindProperty("volume"), true); + EditorGUILayout.PropertyField(serializedObject.FindProperty("profile"), true); + } // ------ Image Adjustment ------- // EditorGUILayout.PropertyField(serializedObject.FindProperty("hue"), true); @@ -73,6 +78,12 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(serializedObject.FindProperty("postExposureValue"), true); } + EditorGUILayout.PropertyField(serializedObject.FindProperty("sharpness"), true); + if(sharpnessProperty.boolValue) + { + EditorGUILayout.PropertyField(serializedObject.FindProperty("sharpnessValue"), true); + } + // ------ Exposure Settings ------- // EditorGUILayout.PropertyField(serializedObject.FindProperty("exposureMode"), true); if(exposureModeProperty.enumValueIndex != 0) @@ -82,9 +93,10 @@ public override void OnInspectorGUI() EditorGUILayout.PropertyField(serializedObject.FindProperty("aperture"), true); } - - // ------ Additonal Effect ------- // + // ------ Distortion Correction ------- // + EditorGUILayout.PropertyField(serializedObject.FindProperty("distortionCorrection"), true); + // ------ Additonal Effect ------- // EditorGUILayout.PropertyField(serializedObject.FindProperty("bloomEffect"), true); if(bloomEffectProperty.boolValue) { diff --git a/Assets/AWSIM/Scripts/Sensors/Camera/CameraSensor.cs b/Assets/AWSIM/Scripts/Sensors/Camera/CameraSensor.cs index 37b41a865..8a146666b 100644 --- a/Assets/AWSIM/Scripts/Sensors/Camera/CameraSensor.cs +++ b/Assets/AWSIM/Scripts/Sensors/Camera/CameraSensor.cs @@ -147,6 +147,12 @@ public class ImageOnGui [SerializeField] Camera cameraObject; [SerializeField] bool enableLensDistortionCorrection = false; + public bool EnableLensDistortionCorrection + { + get => enableLensDistortionCorrection; + set => enableLensDistortionCorrection = value; + } + [Range(0.0f, 1.0f)] public float sharpeningStrength = 0.0f; RenderTexture targetRenderTexture; diff --git a/Assets/AWSIM/Scripts/Sensors/Camera/CameraSensorFeatureManager.cs b/Assets/AWSIM/Scripts/Sensors/Camera/CameraSensorFeatureManager.cs index 99e794785..011ab21de 100644 --- a/Assets/AWSIM/Scripts/Sensors/Camera/CameraSensorFeatureManager.cs +++ b/Assets/AWSIM/Scripts/Sensors/Camera/CameraSensorFeatureManager.cs @@ -1,15 +1,12 @@ -using System.Collections; -using System.Collections.Generic; -using System.Runtime.CompilerServices; -using Unity.VisualScripting; -using UnityEditor; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; namespace AWSIM { - + /// + /// Camera sensor feature manager class, serves as a user interface for configuring parameters related to camera features. + /// public class CameraSensorFeatureManager : MonoBehaviour { private enum CameraExposureMode @@ -46,18 +43,39 @@ private enum CameraExposureMode [SerializeField] private bool postExposure = false; [Range(-10f, 10f)] [SerializeField] private float postExposureValue = 0f; + + [SerializeField] private bool sharpness = false; + [Range(0f, 1f)] + [SerializeField] private float sharpnessValue = 0f; #endregion + #region [Exposure Settings] + [Header("Exposure Settings")] [SerializeField] private CameraExposureMode exposureMode = CameraExposureMode.MANUAL; + + [Range(1f, 12800f)] [SerializeField] private int ISO = 200; + + [Range(0.001f, 10000f)] [SerializeField] private float shutterSpeed = 125; + + [Range(0.7f, 32f)] [SerializeField] private float aperture = 16; - - [Header("Additonal Effect")] + #endregion + + #region [Distortion Correction] + + [Header("Lens Distortion Correction")] + [SerializeField] private bool distortionCorrection = false; + #endregion + + #region [Additonal Effect] + + [Header("Additonal Effect")] [SerializeField] private bool bloomEffect = false; [Range(0f, 1f)] [SerializeField] private float bloomValue = 0f; @@ -72,12 +90,12 @@ private enum CameraExposureMode [SerializeField] private bool motionBlur = false; + #endregion #region [Effects Component] private ColorAdjustments colorAdjustmentsComponent = default; private Exposure exposureComponent = default; - private Bloom bloomComponent = default; private ChromaticAberration chromaticAberrationComponent = default; private DepthOfField depthOfFieldComponent = default; @@ -91,35 +109,33 @@ private void Awake() { if(!profile.TryGet(out colorAdjustmentsComponent)) { - + Debug.LogWarning("The required Color Adjustment property is not found in camera volume profile."); } if(!profile.TryGet(out exposureComponent)) { - + Debug.LogWarning("The required Exposure property is not found in camera volume profile."); } - if(!profile.TryGet(out bloomComponent)) { - + Debug.LogWarning("The required Bloom property is not found in camera volume profile."); } if(!profile.TryGet(out chromaticAberrationComponent)) { - + Debug.LogWarning("The required ChromaticAberration property is not found in camera volume profile."); } if(!profile.TryGet(out depthOfFieldComponent)) { - + Debug.LogWarning("The required DepthOfField property is not found in camera volume profile."); } if(!profile.TryGet(out motionBlurComponent)) { - + Debug.LogWarning("The required MotionBlur property is not found in camera volume profile."); } - } private void Start() @@ -134,6 +150,8 @@ private void Start() cameraObjectActive = false; } + camera.gameObject.SetActive(cameraObjectActive); + // exposure mode if(exposureComponent != null) { @@ -153,6 +171,12 @@ private void Start() // image adjustments ApplyImageAdjustments(); + // sharpness + ApplySharpness(); + + // lens distortion correction + ApplyLensDistortionCorrection(); + // bloom effect ApplyBloom(); @@ -164,9 +188,6 @@ private void Start() // motion blur ApplyMotionBlur(); - - - camera.gameObject.SetActive(cameraObjectActive); } private void ApplyExposureSettings() @@ -205,6 +226,33 @@ private void ApplyImageAdjustments() colorAdjustmentsComponent.postExposure.value = postExposureValue; } + private void ApplySharpness() + { + if(cameraSensor == null) + { + return; + } + + if(sharpness) + { + cameraSensor.sharpeningStrength = sharpnessValue; + } + else + { + cameraSensor.sharpeningStrength = 0f; + } + } + + private void ApplyLensDistortionCorrection() + { + if(cameraSensor == null) + { + return; + } + + cameraSensor.EnableLensDistortionCorrection = distortionCorrection; + } + private void ApplyBloom() { if(bloomComponent != null)