diff --git a/HDRP-DefaultVolumeProject-2020.3/Assets/SampleSceneAssets/Settings/Volumes/VolumeGlobal.asset b/HDRP-DefaultVolumeProject-2020.3/Assets/SampleSceneAssets/Settings/Volumes/VolumeGlobal.asset index efb3870d5..4cc8777f8 100644 --- a/HDRP-DefaultVolumeProject-2020.3/Assets/SampleSceneAssets/Settings/Volumes/VolumeGlobal.asset +++ b/HDRP-DefaultVolumeProject-2020.3/Assets/SampleSceneAssets/Settings/Volumes/VolumeGlobal.asset @@ -264,7 +264,6 @@ MonoBehaviour: - {fileID: -3969488579639410846} - {fileID: 747098994415714109} - {fileID: 4566301752631259820} - - {fileID: 7457958283880787788} --- !u!114 &747098994415714109 MonoBehaviour: m_ObjectHideFlags: 3 @@ -778,182 +777,6 @@ MonoBehaviour: m_OverrideState: 1 m_Value: 1 min: 0 ---- !u!114 &7457958283880787788 -MonoBehaviour: - m_ObjectHideFlags: 3 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 0} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: db8edd5c572b6e648974dac4815d5619, type: 3} - m_Name: ToonEvAdjustmentCurve - m_EditorClassIdentifier: - active: 1 - m_AdvancedMode: 0 - m_ExposureAdjustmnt: 0 - m_ExposureArray: - - -10 - - -9.99932 - - -9.99729 - - -9.993922 - - -9.989231 - - -9.983231 - - -9.975934 - - -9.967355 - - -9.957506 - - -9.946403 - - -9.934056 - - -9.920483 - - -9.905694 - - -9.889706 - - -9.872529 - - -9.854178 - - -9.834667 - - -9.814011 - - -9.79222 - - -9.769311 - - -9.745296 - - -9.720188 - - -9.694003 - - -9.666752 - - -9.63845 - - -9.60911 - - -9.578747 - - -9.547372 - - -9.515 - - -9.481646 - - -9.447322 - - -9.412041 - - -9.375818 - - -9.338666 - - -9.300599 - - -9.261631 - - -9.221773 - - -9.181043 - - -9.13945 - - -9.097011 - - -9.053738 - - -9.0096445 - - -8.964745 - - -8.919052 - - -8.872581 - - -8.825343 - - -8.777354 - - -8.728626 - - -8.679173 - - -8.629009 - - -8.578148 - - -8.526603 - - -8.474386 - - -8.421514 - - -8.367998 - - -8.313852 - - -8.25909 - - -8.203727 - - -8.147775 - - -8.091246 - - -8.034157 - - -7.9765196 - - -7.9183474 - - -7.859655 - - -7.800455 - - -7.7407618 - - -7.680588 - - -7.619949 - - -7.558856 - - -7.497325 - - -7.4353676 - - -7.372998 - - -7.310231 - - -7.247079 - - -7.1835556 - - -7.1196747 - - -7.0554504 - - -6.9908957 - - -6.9260235 - - -6.860849 - - -6.795385 - - -6.729644 - - -6.6636415 - - -6.5973907 - - -6.530905 - - -6.464196 - - -6.3972807 - - -6.330171 - - -6.2628803 - - -6.195422 - - -6.1278114 - - -6.0600605 - - -5.992183 - - -5.9241934 - - -5.8561044 - - -5.78793 - - -5.7196836 - - -5.651379 - - -5.58303 - - -5.51465 - - -5.446253 - - -5.3778505 - - -5.309459 - - -5.241091 - - -5.17276 - - -5.1044793 - - -5.036263 - - -4.968125 - - -4.9000773 - - -4.8321347 - - -4.764311 - - -4.696619 - - -4.629074 - - -4.561688 - - -4.494475 - - -4.4274483 - - -4.360622 - - -4.29401 - - -4.2276244 - - -4.1614804 - - -4.0955915 - - -4.0299706 - - -3.9646316 - - -3.899588 - - -3.8348532 - - -3.7704415 - - -3.7063656 - - -3.6426396 - m_Max: -1.9296192 - m_Min: -10 - m_DebugUI: 0 - hiCutFilter: - m_OverrideState: 0 - m_Value: 0 - curveMap: - m_OverrideState: 1 - m_Value: - serializedVersion: 2 - m_Curve: - - serializedVersion: 3 - time: -10 - value: -10 - inSlope: 0 - outSlope: 0 - tangentMode: 0 - weightedMode: 0 - inWeight: 0 - outWeight: 0 - - serializedVersion: 3 - time: -1.9296192 - value: -3.6426396 - inSlope: 1 - outSlope: 1 - tangentMode: 0 - weightedMode: 0 - inWeight: 0 - outWeight: 0 - m_PreInfinity: 2 - m_PostInfinity: 2 - m_RotationOrder: 4 --- !u!114 &8049981929359091865 MonoBehaviour: m_ObjectHideFlags: 3 diff --git a/HDRP-DefaultVolumeProject-2020.3/Assets/Scenes/SampleScene.unity b/HDRP-DefaultVolumeProject-2020.3/Assets/Scenes/SampleScene.unity index a96226b41..8fd483b2b 100644 --- a/HDRP-DefaultVolumeProject-2020.3/Assets/Scenes/SampleScene.unity +++ b/HDRP-DefaultVolumeProject-2020.3/Assets/Scenes/SampleScene.unity @@ -132,6 +132,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1377783} + - component: {fileID: 1377784} m_Layer: 0 m_Name: Lighting m_TagString: Untagged @@ -159,6 +160,177 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &1377784 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1377782} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: db8edd5c572b6e648974dac4815d5619, type: 3} + m_Name: + m_EditorClassIdentifier: + m_ToonLightHiCutFilter: 0 + m_ExposureAdjustmnt: 0 + m_HighCutFilter: 1000000 + m_AnimationCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: -10 + value: -10 + inSlope: 0 + outSlope: 1 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: -1.32 + value: -1.32 + inSlope: 1 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_ExposureArray: + - -10 + - -9.931654 + - -9.863307 + - -9.794961 + - -9.726614 + - -9.658268 + - -9.589921 + - -9.521575 + - -9.453228 + - -9.384882 + - -9.316535 + - -9.248189 + - -9.179843 + - -9.111496 + - -9.04315 + - -8.974803 + - -8.906457 + - -8.83811 + - -8.769764 + - -8.701417 + - -8.633071 + - -8.564724 + - -8.496378 + - -8.428032 + - -8.359685 + - -8.291339 + - -8.222992 + - -8.154646 + - -8.086299 + - -8.017953 + - -7.9496064 + - -7.88126 + - -7.8129134 + - -7.744567 + - -7.6762204 + - -7.607874 + - -7.5395274 + - -7.471181 + - -7.402835 + - -7.3344884 + - -7.266142 + - -7.1977954 + - -7.129449 + - -7.0611024 + - -6.992756 + - -6.9244094 + - -6.856063 + - -6.7877164 + - -6.71937 + - -6.651024 + - -6.5826774 + - -6.514331 + - -6.4459844 + - -6.377638 + - -6.3092914 + - -6.240945 + - -6.1725984 + - -6.104252 + - -6.0359054 + - -5.9675593 + - -5.899213 + - -5.8308663 + - -5.76252 + - -5.6941733 + - -5.625827 + - -5.5574803 + - -5.489134 + - -5.4207873 + - -5.352441 + - -5.2840943 + - -5.2157483 + - -5.147402 + - -5.0790553 + - -5.010709 + - -4.9423623 + - -4.874016 + - -4.8056693 + - -4.737323 + - -4.6689763 + - -4.60063 + - -4.532284 + - -4.4639373 + - -4.395591 + - -4.3272443 + - -4.258898 + - -4.1905513 + - -4.122205 + - -4.0538583 + - -3.9855118 + - -3.9171658 + - -3.8488188 + - -3.7804728 + - -3.7121258 + - -3.6437798 + - -3.5754333 + - -3.5070868 + - -3.4387403 + - -3.3703938 + - -3.3020473 + - -3.2337008 + - -3.1653547 + - -3.0970078 + - -3.0286617 + - -2.9603148 + - -2.8919687 + - -2.8236222 + - -2.7552757 + - -2.6869292 + - -2.6185827 + - -2.5502362 + - -2.4818897 + - -2.4135437 + - -2.3451967 + - -2.2768507 + - -2.2085037 + - -2.1401577 + - -2.0718112 + - -2.0034647 + - -1.9351177 + - -1.8667717 + - -1.7984257 + - -1.7300787 + - -1.6617327 + - -1.5933857 + - -1.5250397 + - -1.4566927 + - -1.3883467 + - -1.3199997 + m_Max: -1.32 + m_Min: -10 + m_DebugUI: 0 --- !u!1 &23481561 GameObject: m_ObjectHideFlags: 0 @@ -6647,6 +6819,208 @@ Transform: m_CorrespondingSourceObject: {fileID: 8110425016416769263, guid: dd7bc729052fb0349850831c3c596d60, type: 3} m_PrefabInstance: {fileID: 553938282} m_PrefabAsset: {fileID: 0} +--- !u!1 &561912584 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 561912586} + - component: {fileID: 561912585} + m_Layer: 0 + m_Name: Toon Ev Adjustment Curve + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &561912585 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 561912584} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: db8edd5c572b6e648974dac4815d5619, type: 3} + m_Name: + m_EditorClassIdentifier: + m_ToonLightHiCutFilter: 0 + m_ExposureAdjustmnt: 1 + m_HighCutFilter: 1000000 + m_AnimationCurve: + serializedVersion: 2 + m_Curve: + - serializedVersion: 3 + time: -10 + value: -10 + inSlope: 0 + outSlope: 1 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + - serializedVersion: 3 + time: -1.32 + value: -1.32 + inSlope: 1 + outSlope: 0 + tangentMode: 0 + weightedMode: 0 + inWeight: 0 + outWeight: 0 + m_PreInfinity: 2 + m_PostInfinity: 2 + m_RotationOrder: 4 + m_ExposureArray: + - -10 + - -9.931654 + - -9.863307 + - -9.794961 + - -9.726614 + - -9.658268 + - -9.589921 + - -9.521575 + - -9.453228 + - -9.384882 + - -9.316535 + - -9.248189 + - -9.179843 + - -9.111496 + - -9.04315 + - -8.974803 + - -8.906457 + - -8.83811 + - -8.769764 + - -8.701417 + - -8.633071 + - -8.564724 + - -8.496378 + - -8.428032 + - -8.359685 + - -8.291339 + - -8.222992 + - -8.154646 + - -8.086299 + - -8.017953 + - -7.9496064 + - -7.88126 + - -7.8129134 + - -7.744567 + - -7.6762204 + - -7.607874 + - -7.5395274 + - -7.471181 + - -7.402835 + - -7.3344884 + - -7.266142 + - -7.1977954 + - -7.129449 + - -7.0611024 + - -6.992756 + - -6.9244094 + - -6.856063 + - -6.7877164 + - -6.71937 + - -6.651024 + - -6.5826774 + - -6.514331 + - -6.4459844 + - -6.377638 + - -6.3092914 + - -6.240945 + - -6.1725984 + - -6.104252 + - -6.0359054 + - -5.9675593 + - -5.899213 + - -5.8308663 + - -5.76252 + - -5.6941733 + - -5.625827 + - -5.5574803 + - -5.489134 + - -5.4207873 + - -5.352441 + - -5.2840943 + - -5.2157483 + - -5.147402 + - -5.0790553 + - -5.010709 + - -4.9423623 + - -4.874016 + - -4.8056693 + - -4.737323 + - -4.6689763 + - -4.60063 + - -4.532284 + - -4.4639373 + - -4.395591 + - -4.3272443 + - -4.258898 + - -4.1905513 + - -4.122205 + - -4.0538583 + - -3.9855118 + - -3.9171658 + - -3.8488188 + - -3.7804728 + - -3.7121258 + - -3.6437798 + - -3.5754333 + - -3.5070868 + - -3.4387403 + - -3.3703938 + - -3.3020473 + - -3.2337008 + - -3.1653547 + - -3.0970078 + - -3.0286617 + - -2.9603148 + - -2.8919687 + - -2.8236222 + - -2.7552757 + - -2.6869292 + - -2.6185827 + - -2.5502362 + - -2.4818897 + - -2.4135437 + - -2.3451967 + - -2.2768507 + - -2.2085037 + - -2.1401577 + - -2.0718112 + - -2.0034647 + - -1.9351177 + - -1.8667717 + - -1.7984257 + - -1.7300787 + - -1.6617327 + - -1.5933857 + - -1.5250397 + - -1.4566927 + - -1.3883467 + - -1.3199997 + m_Max: -1.32 + m_Min: -10 + m_DebugUI: 0 +--- !u!4 &561912586 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 561912584} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 20 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &566695218 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/TestProjects/HDRPUTS_GraphicsTest-2020.3/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/005_LightAndShadows(HDRP).png b/TestProjects/HDRPUTS_GraphicsTest-2020.3/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/005_LightAndShadows(HDRP).png index fc970d57e..c91f4bfaf 100644 Binary files a/TestProjects/HDRPUTS_GraphicsTest-2020.3/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/005_LightAndShadows(HDRP).png and b/TestProjects/HDRPUTS_GraphicsTest-2020.3/Assets/ReferenceImages/Linear/WindowsEditor/Vulkan/None/005_LightAndShadows(HDRP).png differ diff --git a/com.unity.toonshader/CHANGELOG.md b/com.unity.toonshader/CHANGELOG.md index acfde8961..f6a841693 100644 --- a/com.unity.toonshader/CHANGELOG.md +++ b/com.unity.toonshader/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [0.2.0-preview] - 2021-08-15 -* HDRP: Toon EV adjutment curve as a SRP VolumeComponent. +## [0.2.0-preview] - 2021-08-17 +* HDRP: Toon EV adjutment curve as a Mono-behavior. * Legacy, Universal and HDRP: Some texture samplers,such as _MainTex, _NormalMap, _1st_ShadeMap and _2nd_ShadeMap, are shared by 1 sampler, sampler_MainTex, in order to avoid sampler number exceeding errors. * Integrated Textures feature is removed from all the render pipeline versions instead of above. * HDRP and URP are compatible with SRP Batcher. diff --git a/com.unity.toonshader/Editor/ToonEvAdjustmentCurveInspector.cs b/com.unity.toonshader/Editor/ToonEvAdjustmentCurveInspector.cs new file mode 100644 index 000000000..dc25c1376 --- /dev/null +++ b/com.unity.toonshader/Editor/ToonEvAdjustmentCurveInspector.cs @@ -0,0 +1,112 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; +using Unity.Rendering.Toon; +namespace UnityEditor.Rendering.Toon +{ + [CustomEditor(typeof(ToonEvAdjustmentCurve))] + + public class ToonEvAdjustmentCurveCurveInspector : Editor + { + SerializedObject m_SerializedObject; +#if ADJUSTMENT_CURVE_DEBUG_UI + string numberString = "1"; +#endif // + public override void OnInspectorGUI() + { + const string labelLightAdjustment = "Toon EV Adjustment"; + const string labelLightAdjustmentCurve = "Curve"; + const string labelLightHighCutFilter = "Light High-Cult Filter"; +#if ADJUSTMENT_CURVE_DEBUG_UI + const string labelExposureMin = "Min:"; + const string labelExposureMax = "Max:"; +#endif + bool isChanged = false; + + var obj = target as ToonEvAdjustmentCurve; + // hi cut filter + EditorGUI.BeginChangeCheck(); + + bool lightFilterr = EditorGUILayout.Toggle(labelLightHighCutFilter, obj.m_ToonLightHiCutFilter); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(target, "Changed Light Hi Cut Filter"); + obj.m_ToonLightHiCutFilter = lightFilterr; + isChanged = true; + } + + + if (isChanged) + { + // at leaset 2020.3.12f1, not neccessary. but, from which version?? + EditorApplication.QueuePlayerLoopUpdate(); + } + + + // curve + EditorGUI.BeginChangeCheck(); + bool exposureAdjustment = EditorGUILayout.Toggle(labelLightAdjustment, obj.m_ExposureAdjustmnt); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(target, "Changed Expsure Adjustment"); + obj.m_ExposureAdjustmnt = exposureAdjustment; + isChanged = true; + } + + EditorGUI.BeginDisabledGroup(!obj.m_ExposureAdjustmnt); + { + EditorGUI.indentLevel++; + EditorGUI.BeginChangeCheck(); + // var ranges = new Rect(-10, -10, 20, 20); + // var curve = EditorGUILayout.CurveField(labelExposureCurave, obj.m_AnimationCurve, Color.green,ranges); + var curve = EditorGUILayout.CurveField(labelLightAdjustmentCurve, obj.m_AnimationCurve); + if (EditorGUI.EndChangeCheck()) + { + Undo.RecordObject(target, "Changed Curve"); + obj.m_AnimationCurve = curve; + isChanged = true; + } + var rangeMinLux = ConvertFromEV100(obj.m_Min); + var rangeMaxLux = ConvertFromEV100(obj.m_Max); + EditorGUILayout.BeginHorizontal(); + EditorGUILayout.LabelField("rangeMin:" + rangeMinLux.ToString()); + EditorGUILayout.LabelField("rangeMax:" + rangeMaxLux.ToString()); + EditorGUILayout.EndHorizontal(); + + + EditorGUI.indentLevel--; + } + EditorGUI.EndDisabledGroup(); + + + + + + } + + + float ConvertFromEV100(float EV100) + { + + float val = Mathf.Pow(2, EV100) * 2.5f; + return val; + + } + + float ConvertToEV100(float val) + { + + return Mathf.Log(val * 0.4f, 2.0f); + + } + [MenuItem("GameObject/Toon Shader/Create Toon Ev Adjustment Curve", false, 9999)] + static void CreateToonEvAdjustmentCurveGameObject() + { + var go = new GameObject(); + go.name = "Toon Ev Adjustment Curve"; + go.AddComponent(); + Undo.RegisterCreatedObjectUndo(go, "Create Toon Ev Adjustment Curve"); + } + } +} \ No newline at end of file diff --git a/com.unity.toonshader/Editor/ToonEvAdjustmentCurveInspector.cs.meta b/com.unity.toonshader/Editor/ToonEvAdjustmentCurveInspector.cs.meta new file mode 100644 index 000000000..b07e22053 --- /dev/null +++ b/com.unity.toonshader/Editor/ToonEvAdjustmentCurveInspector.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 8b14e960611699a419bcf9456e76bef6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/com.unity.toonshader/Runtime/ToonEvAdjustmentCurve.cs b/com.unity.toonshader/Runtime/ToonEvAdjustmentCurve.cs index da7cce9d9..b7d6314ac 100644 --- a/com.unity.toonshader/Runtime/ToonEvAdjustmentCurve.cs +++ b/com.unity.toonshader/Runtime/ToonEvAdjustmentCurve.cs @@ -7,16 +7,11 @@ using UnityEngine.Rendering; using UnityEngine.Experimental.Rendering; using UnityObject = UnityEngine.Object; -using System; - -#if SRPCORE_IS_INSTALLED_FOR_UTS namespace Unity.Rendering.Toon { - /// - /// A volume component that holds settings for the Toon Ev Adjustment Curve. - /// - [Serializable, VolumeComponentMenu("Toon/EV Adjustment Curve")] - public sealed class ToonEvAdjustmentCurve : VolumeComponent + [ExecuteAlways] + [DisallowMultipleComponent] + public class ToonEvAdjustmentCurve : MonoBehaviour { // flags bool m_initialized = false; @@ -31,12 +26,15 @@ public sealed class ToonEvAdjustmentCurve : VolumeComponent const string kExposureMaxPropName = "_ToonEvAdjustmentValueMax"; const string kToonLightFilterPropName = "_ToonLightHiCutFilter"; - + [SerializeField] + internal bool m_ToonLightHiCutFilter= false; [SerializeField] internal bool m_ExposureAdjustmnt = false; - - + [SerializeField] + public int m_HighCutFilter = 1000000; + [SerializeField] + internal AnimationCurve m_AnimationCurve = DefaultAnimationCurve(); [SerializeField] internal float[] m_ExposureArray; [SerializeField] @@ -49,35 +47,26 @@ public sealed class ToonEvAdjustmentCurve : VolumeComponent bool m_isCompiling = false; #endif - /// - /// Specifies the method that Toon Shader uses hiCutFilter. - /// This parameter is only used when is set. - /// - [Tooltip("Specifies the method that Toon Shader uses hiCutFilter.")] - public BoolParameter hiCutFilter = new BoolParameter(false); - - /// - /// Specifies a curve that remaps the Toon exposure on the x-axis to the EV you want on the y-axis. - /// This parameter is only used when is set. - /// - [Tooltip("Specifies a curve that remaps the Toon EV on the x-axis to the EV you want on the y-axis.")] - public AnimationCurveParameter curveMap = new AnimationCurveParameter(AnimationCurve.Linear(-10f, -10f, -1.32f, -1.32f)); // TODO: Use TextureCurve instead? - - - - + void Reset() + { + OnDisable(); + OnEnable(); + DefaultAnimationCurve(); + } + static AnimationCurve DefaultAnimationCurve() + { + return AnimationCurve.Linear(-10f, -10f, -1.32f, -1.32f); + } void Update() { - if (!m_initialized) - { - return; - } + + Initialize(); // Fail safe in case the curve is deleted / has 0 point - var curve = curveMap.value; + var curve = m_AnimationCurve; if (curve == null || curve.length == 0) @@ -105,7 +94,7 @@ void Update() { // on compile begin m_isCompiling = true; - ReleaseToonEvAdjustmentCurve(); + Release(); } else if (!EditorApplication.isCompiling && m_isCompiling) { @@ -113,12 +102,11 @@ void Update() m_isCompiling = false; } #endif - Shader.SetGlobalFloatArray(kExposureArrayPropName, m_ExposureArray); Shader.SetGlobalFloat(kExposureMinPropName, m_Min); Shader.SetGlobalFloat(kExposureMaxPropName, m_Max); - Shader.SetGlobalInt(kExposureAdjustmentPorpName, curveMap.overrideState ? 1 : 0); - Shader.SetGlobalInt(kToonLightFilterPropName, hiCutFilter.overrideState && hiCutFilter.value ? 1 : 0); + Shader.SetGlobalInt(kExposureAdjustmentPorpName, m_ExposureAdjustmnt ? 1 : 0); + Shader.SetGlobalInt(kToonLightFilterPropName, m_ToonLightHiCutFilter ? 1 : 0); } @@ -128,8 +116,6 @@ void EnableSrpCallbacks() if (!m_srpCallbackInitialized) { - RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering; - RenderPipelineManager.endCameraRendering += OnEndCameraRendering; m_srpCallbackInitialized = true; } } @@ -138,15 +124,11 @@ void DisableSrpCallbacks() if (m_srpCallbackInitialized) { m_srpCallbackInitialized = false; - RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering; - RenderPipelineManager.endCameraRendering -= OnEndCameraRendering; - m_srpCallbackInitialized = false; } } - protected override void OnEnable() + void OnEnable() { - base.OnEnable(); Initialize(); @@ -154,12 +136,11 @@ protected override void OnEnable() } - protected override void OnDisable() + void OnDisable() { DisableSrpCallbacks(); - ReleaseToonEvAdjustmentCurve(); - base.OnDisable(); + Release(); } void Initialize() @@ -183,94 +164,35 @@ void Initialize() } - void ReleaseToonEvAdjustmentCurve() + void Release() { - if (m_initialized) { m_ExposureArray = null; Shader.SetGlobalInt(kExposureAdjustmentPorpName, 0); Shader.SetGlobalInt(kToonLightFilterPropName, 0); - } m_initialized = false; - base.Release(); - } - void OnBeginCameraRendering(ScriptableRenderContext context, Camera camera) - { - Update(); } - - void OnEndCameraRendering(ScriptableRenderContext context, Camera camera) +/* + public static void DestroyUnityObject(UnityObject obj) { - // Finish(); + if (obj != null) + { +#if UNITY_EDITOR + if (Application.isPlaying) + UnityObject.Destroy(obj); + else + UnityObject.DestroyImmediate(obj); +#else + UnityObject.Destroy(obj); +#endif + } } +*/ } - - - /// - /// Methods that HDRP uses to change the exposure when the Camera moves from dark to light and vice versa. - /// - /// - public enum ToonEVAdjustmentMode - { - /// - /// No Adjustment - /// - NoAdjustment, - - /// - /// The EV changes correspond with the curve. - /// - CurveAdjustment - } - - /// - /// Methods that HDRP uses to change the exposure when the Camera moves from dark to light and vice versa. - /// - /// - public enum ToonHiCutFilter - { - /// - /// No Adjustment - /// - Disable, - - /// - /// The EV changes correspond with the curve. - /// - Enable - } - - /// - /// A that holds a value. - /// - [Serializable] - public sealed class ToonEVAdjustmentModeParamater : VolumeParameter - { - /// - /// Creates a new instance. - /// - /// The initial value to store in the parameter. - /// The initial override state for the parameter. - public ToonEVAdjustmentModeParamater(ToonEVAdjustmentMode value, bool overrideState = false) : base(value, overrideState) { } - } - /// - /// A that holds a value. - /// - [Serializable] - public sealed class ToonHiCutFiltereParamater : VolumeParameter - { - /// - /// Creates a new instance. - /// - /// The initial value to store in the parameter. - /// The initial override state for the parameter. - public ToonHiCutFiltereParamater(ToonHiCutFilter value, bool overrideState = false) : base(value, overrideState) { } - } } -#endif //SRPCORE_IS_INSTALLED_FOR_UTS \ No newline at end of file