Skip to content
This repository has been archived by the owner on Nov 30, 2020. It is now read-only.

Fixed ReloadBaseTypes being called 2 times when entering play mode #832

Open
wants to merge 37 commits into
base: v2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
743602d
Fix issue with MultiScaleVO and Single Pass Stereo
bgolus Jun 4, 2019
7cba7a0
Fixed method ReloadBaseTypes being called 2 times when entering play …
PierreGac Jul 8, 2019
110f53a
Merge remote-tracking branch 'https://github.com/bgolus/PostProcessin…
Sep 6, 2019
dff4cfe
Added "PostProcessLayer resets camera projection matrix in OnPreCull"…
Sep 6, 2019
501a84a
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Sep 11, 2019
24e911c
Added more pull requests
Sep 27, 2019
1106e30
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Oct 18, 2019
e583b56
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Oct 23, 2019
a51dcc4
Added Assembly optimizations from https://github.com/devsisters/PostP…
Nov 9, 2019
3c0983e
Added legacy blur
Nov 9, 2019
a786964
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Dec 5, 2019
7d9ca0f
Merge remote-tracking branch 'remotes/upstream/xr/multipass-legacy-fi…
Dec 5, 2019
2576b32
Added legacy blur
Mar 3, 2020
57811f4
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Mar 12, 2020
e71cf8b
Added changes from https://github.com/Tspk91/PostProcessing/commit/ff…
Mar 12, 2020
0e7189c
Added changes from https://github.com/KokkuGames/PostProcessing/commi…
Mar 12, 2020
faf370b
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Apr 18, 2020
ea3f7dd
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Aug 7, 2020
f4d1f0d
Fixed package name : switched from unity to pgac
Aug 7, 2020
fd4bf3b
Added preprocessor instruction for missing mipmap in Unity < 2019
Aug 24, 2020
9a5c4b8
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Aug 25, 2020
864f0bb
Merge remote-tracking branch 'remotes/upstream/v2' into v2
Oct 2, 2020
42a80b7
Added changes made by https://github.com/Tspk91/PostProcessing/commit…
Feb 1, 2021
7382c10
Added Graphics repo fixes :
Mar 2, 2021
73e5dc9
Added changes from https://github.com/Unity-Technologies/Graphics/com…
Mar 3, 2021
bee651a
Added changes from : https://github.com/Unity-Technologies/Graphics/c…
Aug 23, 2021
7369163
Added changes from : https://github.com/Unity-Technologies/Graphics/c…
Aug 23, 2021
847daa7
Added changes from : https://github.com/Unity-Technologies/Graphics/c…
Aug 23, 2021
ab5cfb4
Attempt to fix an issue with the bloom by including the alpha fix fro…
Aug 23, 2021
3b7d65a
https://github.com/SSS135/PostProcessing/commit/c52794b99652a30f8c93f…
Aug 23, 2021
92fe2b1
Added the following commits :
Dec 22, 2021
de9682e
Added pull request : https://github.com/Unity-Technologies/Graphics/p…
Sep 12, 2022
6302ec7
Fixed an issue causing MSVO not working when having a VR camera (head…
Oct 26, 2022
7168bb5
Added https://github.com/Unity-Technologies/Graphics/commit/2b3474f4a…
May 23, 2023
5f930ae
Added commits from Graphics
Dec 5, 2023
c24fcdd
https://github.com/Unity-Technologies/Graphics/commit/e2ea3fd467f0445…
Dec 5, 2023
1a021bd
Added https://github.com/Unity-Technologies/Graphics/commit/54427d252…
Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
## Unity ##

*.cs diff=csharp text eol=crlf
*.cginc text
*.shader text


*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
*.physicsMaterial2D merge=unityyamlmerge eol=lf
*.physicsMaterial merge=unityyamlmerge eol=lf
*.asset merge=unityyamlmerge eol=lf
*.meta merge=unityyamlmerge eol=lf
*.controller merge=unityyamlmerge eol=lf
17 changes: 14 additions & 3 deletions PostProcessing/Editor/Effects/AmbientOcclusionEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ internal sealed class AmbientOcclusionEditor : PostProcessEffectEditor<AmbientOc
SerializedParameterOverride m_Color;
SerializedParameterOverride m_AmbientOnly;
SerializedParameterOverride m_ThicknessModifier;
SerializedParameterOverride m_ZBias;
SerializedParameterOverride m_disableOnVRCameras;
SerializedParameterOverride m_DirectLightingStrength;
SerializedParameterOverride m_Quality;
SerializedParameterOverride m_Radius;
Expand All @@ -22,6 +24,8 @@ public override void OnEnable()
m_Color = FindParameterOverride(x => x.color);
m_AmbientOnly = FindParameterOverride(x => x.ambientOnly);
m_ThicknessModifier = FindParameterOverride(x => x.thicknessModifier);
m_ZBias = FindParameterOverride(x => x.zBias);
m_disableOnVRCameras = FindParameterOverride(x => x.disableOnVRCameras);
m_DirectLightingStrength = FindParameterOverride(x => x.directLightingStrength);
m_Quality = FindParameterOverride(x => x.quality);
m_Radius = FindParameterOverride(x => x.radius);
Expand All @@ -47,13 +51,20 @@ public override void OnInspectorGUI()
}
else if (aoMode == (int)AmbientOcclusionMode.MultiScaleVolumetricObscurance)
{
if (!SystemInfo.supportsComputeShaders)
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support.", MessageType.Warning);
if (!SystemInfo.supportsComputeShaders || EditorUtilities.isTargetingWebGL)
{
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support which is not available on this platform.", MessageType.Error);
}
else if(EditorUtilities.isTargetingAndroid)
{
EditorGUILayout.HelpBox("Multi-scale volumetric obscurance requires compute shader support (Vulkan) when running on Android.", MessageType.Warning);
}

PropertyField(m_ThicknessModifier);

PropertyField(m_ZBias);
if (RuntimeUtilities.scriptableRenderPipelineActive)
PropertyField(m_DirectLightingStrength);
PropertyField(m_disableOnVRCameras);
}

PropertyField(m_Color);
Expand Down
10 changes: 8 additions & 2 deletions PostProcessing/Editor/Effects/AutoExposureEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,14 @@ public override void OnEnable()

public override void OnInspectorGUI()
{
if (!SystemInfo.supportsComputeShaders)
EditorGUILayout.HelpBox("Auto exposure requires compute shader support.", MessageType.Warning);
if (!SystemInfo.supportsComputeShaders || EditorUtilities.isTargetingWebGL)
{
EditorGUILayout.HelpBox("Auto exposure requires compute shader support which is not available on this platform.", MessageType.Error);
}
else if (EditorUtilities.isTargetingAndroid)
{
EditorGUILayout.HelpBox("Auto exposure requires compute shader support (Vulkan) when running on Android.", MessageType.Warning);
}

EditorUtilities.DrawHeaderLabel("Exposure");

Expand Down
2 changes: 1 addition & 1 deletion PostProcessing/Editor/Effects/BloomEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public override void OnInspectorGUI()
PropertyField(m_DirtTexture);
PropertyField(m_DirtIntensity);

if (RuntimeUtilities.isVREnabled)
if (EditorUtilities.isVREnabled)
{
if ((m_DirtIntensity.overrideState.boolValue && m_DirtIntensity.value.floatValue > 0f)
|| (m_DirtTexture.overrideState.boolValue && m_DirtTexture.value.objectReferenceValue != null))
Expand Down
4 changes: 2 additions & 2 deletions PostProcessing/Editor/Effects/ColorGradingEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ void DoCurvesGUI(bool hdr)

for (int i = 1; i < hLines; i++)
{
var offset = i * Vector2.right * gridOffset;
var offset = gridOffset * i * Vector2.right;
offset.x += gridPadding;
Handles.DrawLine(innerRect.position + offset, new Vector2(innerRect.x, innerRect.yMax - 1) + offset);
}
Expand All @@ -642,7 +642,7 @@ void DoCurvesGUI(bool hdr)

for (int i = 1; i < vLines; i++)
{
var offset = i * Vector2.up * gridOffset;
var offset = gridOffset * i * Vector2.up;
offset.y += gridPadding;
Handles.DrawLine(innerRect.position + offset, new Vector2(innerRect.xMax - 1, innerRect.y) + offset);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ public override void OnEnable()

var fields = target.GetType()
.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)
.Where(t => t.FieldType.IsSubclassOf(typeof(ParameterOverride)) && t.Name != "enabled")
.Where(t =>
(t.IsPublic && t.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0)
|| (t.GetCustomAttributes(typeof(UnityEngine.SerializeField), false).Length > 0)
)
.Where(t => t.FieldType.IsSubclassOf(typeof(ParameterOverride)) && t.Name != "enabled" && ((t.IsPublic && t.GetCustomAttributes(typeof(NonSerializedAttribute), false).Length == 0)
|| (t.GetCustomAttributes(typeof(UnityEngine.SerializeField), false).Length > 0))
)
.ToList();

foreach (var field in fields)
Expand Down
2 changes: 1 addition & 1 deletion PostProcessing/Editor/Effects/LensDistortionEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal sealed class LensDistortionEditor : DefaultPostProcessEffectEditor
{
public override void OnInspectorGUI()
{
if (RuntimeUtilities.isVREnabled)
if (EditorUtilities.isVREnabled)
EditorGUILayout.HelpBox("Lens Distortion is available only for non-stereo cameras.", MessageType.Warning);

base.OnInspectorGUI();
Expand Down
2 changes: 1 addition & 1 deletion PostProcessing/Editor/Effects/MotionBlurEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ internal sealed class MotionBlurEditor : DefaultPostProcessEffectEditor
{
public override void OnInspectorGUI()
{
if (RuntimeUtilities.isVREnabled)
if (EditorUtilities.isVREnabled)
EditorGUILayout.HelpBox("Motion Blur is available only for non-stereo cameras.", MessageType.Warning);

base.OnInspectorGUI();
Expand Down
2 changes: 1 addition & 1 deletion PostProcessing/Editor/PostProcessLayerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ void DoAntialiasing()
EditorGUILayout.HelpBox("TAA requires Unity 2017.3+ for Single-pass stereo rendering support.", MessageType.Warning);
#endif
#if UNITY_2017_3_OR_NEWER
if (m_TargetCameraComponent != null && m_TargetCameraComponent.allowDynamicResolution)
if (m_TargetCameraComponent != null && RuntimeUtilities.IsDynamicResolutionEnabled(m_TargetCameraComponent))
EditorGUILayout.HelpBox("TAA is not supported with Dynamic Resolution.", MessageType.Warning);
#endif

Expand Down
16 changes: 14 additions & 2 deletions PostProcessing/Editor/Tools/DefineSetter.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
using System;
using System.Linq;
#if UNITY_2021_3_OR_NEWER
using UnityEditor.Build;
#endif

namespace UnityEditor.Rendering.PostProcessing
{
[InitializeOnLoad]
sealed class DefineSetter
{
const string k_Define = "UNITY_POST_PROCESSING_STACK_V2";

static DefineSetter()
{
var targets = Enum.GetValues(typeof(BuildTargetGroup))
Expand All @@ -17,7 +20,12 @@ static DefineSetter()

foreach (var target in targets)
{
#if UNITY_2021_3_OR_NEWER
var namedTarget = NamedBuildTarget.FromBuildTargetGroup(target);
var defines = PlayerSettings.GetScriptingDefineSymbols(namedTarget).Trim();
#else
var defines = PlayerSettings.GetScriptingDefineSymbolsForGroup(target).Trim();
#endif

var list = defines.Split(';', ' ')
.Where(x => !string.IsNullOrEmpty(x))
Expand All @@ -29,7 +37,11 @@ static DefineSetter()
list.Add(k_Define);
defines = list.Aggregate((a, b) => a + ";" + b);

#if UNITY_2021_3_OR_NEWER
PlayerSettings.SetScriptingDefineSymbols(namedTarget, defines);
#else
PlayerSettings.SetScriptingDefineSymbolsForGroup(target, defines);
#endif
}
}

Expand All @@ -42,4 +54,4 @@ static bool IsObsolete(BuildTargetGroup group)
return attrs != null && attrs.Length > 0;
}
}
}
}
10 changes: 7 additions & 3 deletions PostProcessing/Editor/Unity.Postprocessing.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "Unity.Postprocessing.Editor",
"rootNamespace": "",
"references": [
"Unity.Postprocessing.Runtime"
"Unity.Postprocessing.Runtime",
"Unity.XR.Management",
"Unity.XR.Management.Editor"
],
"optionalUnityReferences": [],
"includePlatforms": [
"Editor"
],
Expand All @@ -12,5 +14,7 @@
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": []
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
71 changes: 69 additions & 2 deletions PostProcessing/Editor/Utils/EditorUtilities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
using UnityEngine.Assertions;
using UnityEngine.Rendering.PostProcessing;

#if XR_MANAGEMENT_4_0_1_OR_NEWER
using UnityEditor.XR.Management;
#endif

namespace UnityEditor.Rendering.PostProcessing
{
/// <summary>
Expand All @@ -26,7 +30,14 @@ public static bool isTargetingConsoles
{
var t = EditorUserBuildSettings.activeBuildTarget;
return t == BuildTarget.PS4
#if UNITY_PS5
|| t == BuildTarget.PS5
#endif
|| t == BuildTarget.XboxOne
#if UNITY_GAMECORE
|| t == BuildTarget.GameCoreXboxSeries
|| t == BuildTarget.GameCoreXboxOne
#endif
|| t == BuildTarget.Switch;
}
}
Expand All @@ -53,6 +64,30 @@ public static bool isTargetingMobiles
}
}

/// <summary>
/// Returns <c>true</c> if the current target is Android, <c>false</c> otherwise.
/// </summary>
public static bool isTargetingAndroid
{
get
{
var t = EditorUserBuildSettings.activeBuildTarget;
return t == BuildTarget.Android;
}
}

/// <summary>
/// Returns <c>true</c> if the current target is WebGL, <c>false</c> otherwise.
/// </summary>
public static bool isTargetingWebGL
{
get
{
var t = EditorUserBuildSettings.activeBuildTarget;
return t == BuildTarget.WebGL;
}
}

/// <summary>
/// Returns <c>true</c> if the current target is a console or a mobile, <c>false</c>
/// otherwise.
Expand All @@ -78,14 +113,23 @@ static void OnEditorReload()
static void ReloadDecoratorTypes()
{
s_AttributeDecorators.Clear();

/*
// Look for all the valid attribute decorators
var types = RuntimeUtilities.GetAllTypesDerivedFrom<AttributeDecorator>()
.Where(
t => t.IsDefined(typeof(DecoratorAttribute), false)
&& !t.IsAbstract
);

*/
Type[] types = new[]
{
typeof(UnityEditor.Rendering.PostProcessing.RangeDecorator),
typeof(UnityEditor.Rendering.PostProcessing.MinDecorator),
typeof(UnityEditor.Rendering.PostProcessing.MaxDecorator),
typeof(UnityEditor.Rendering.PostProcessing.MinMaxDecorator),
typeof(UnityEditor.Rendering.PostProcessing.ColorUsageDecorator),
typeof(UnityEditor.Rendering.PostProcessing.TrackballDecorator),
};
// Store them
foreach (var type in types)
{
Expand Down Expand Up @@ -353,5 +397,28 @@ static bool CanPaste(PostProcessEffectSettings target)
return s_ClipboardContent != null
&& s_ClipboardContent.GetType() == target.GetType();
}

internal static bool isVREnabled
{
get
{
#if ENABLE_VR_MODULE && ENABLE_VR
#if ENABLE_XR_MODULE && XR_MANAGEMENT_4_0_1_OR_NEWER
// If XR manager extension is available, we can query it to know if any XR extension is currently active
var buildTargetSettings = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Standalone);
return (buildTargetSettings != null && buildTargetSettings.AssignedSettings != null &&
buildTargetSettings.AssignedSettings.activeLoaders.Count > 0);
#elif !UNITY_2020_1_OR_NEWER
// This will only work with 2019.3 and older since it rely on the old VR module
return UnityEditorInternal.VR.VREditor.GetVREnabledOnTargetGroup(BuildPipeline.GetBuildTargetGroup(EditorUserBuildSettings.activeBuildTarget));
#else
// If we reach this code-path, it means we can't really detect if VR/XR is active in the Editor, so return false
return false;
#endif
#else
return false;
#endif
}
}
}
}
Loading