Skip to content

[HDRP][Compositor] Fix issues with compositor's undo #3100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 52 commits into from
Jan 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
77bae01
Fixed Render Graph immediate mode. (#3033)
JulienIgnace-Unity Jan 8, 2021
47bd6c2
Fix issue with shadow mask and area lights (#3019)
FrancescoC-unity Jan 8, 2021
88daab3
Fix issue with capture callback (now includes post processing results…
pmavridis Jan 8, 2021
4313b48
[HDRP] Fix decal draw order for ShaderGraph decal materials (#3018)
alelievr Jan 8, 2021
a9c4c27
Fixed various Look Dev issues after exiting Playmode (#2956)
JulienIgnace-Unity Jan 11, 2021
d358740
Merge branch 'master' into hd/bugfix
sebastienlagarde Jan 11, 2021
11b5984
Merge branch 'master' into hd/bugfix
sebastienlagarde Jan 11, 2021
a22cfa4
StackLit: Fix SG surface option property block to only display energy…
slunity Jan 12, 2021
a3c36a5
Fixed missing BeginCameraRendering call for custom render mode of a C…
sebastienlagarde Jan 12, 2021
6cb6820
Implement custom drawer for layer mask parameters (#3066)
adrien-de-tocqueville Jan 12, 2021
ccf4f96
Adding mixed light baking shadowmask test (#3052)
remi-chapelain Jan 12, 2021
6149540
Changed the clamping approach for RTR and RTGI (in both perf and qual…
anisunity Jan 12, 2021
cf36177
Fixed the condition on temporal accumulation in the reflection denois…
anisunity Jan 12, 2021
5fecd49
Changed the warning message for ray traced area shadows (case 1303410…
anisunity Jan 12, 2021
55bb6ff
Disabled specular occlusion for what we consider medium and larger sc…
anisunity Jan 12, 2021
fd53759
Merge branch 'master' into hd/bugfix
sebastienlagarde Jan 12, 2021
f3699e8
Merge branch 'master' into hd/bugfix
sebastienlagarde Jan 13, 2021
fc057cd
Fix issues with compositor's undo
pmavridis Jan 13, 2021
c94bb6a
Add fail-safe call to clear teh camera cache
pmavridis Jan 13, 2021
52e6143
Merge remote-tracking branch 'origin/hd/bugfix' into HDRP/fix-composi…
pmavridis Jan 14, 2021
4deb26e
Fix bad merge
pmavridis Jan 14, 2021
b9da5fa
Hd/fix 1299116 tesselation cull (#3057)
kecho Jan 14, 2021
5b57f64
Change the source value for the ray tracing frame index iterator from…
anisunity Jan 14, 2021
b21345b
[HDRP] Added a RenderGraph pass that resets the camera size after the…
alelievr Jan 14, 2021
9581f38
Fix Light Intensity UI Prefab Override Application (1299563) (#3061)
johnpars Jan 14, 2021
525ebf5
Fix Undo/Redo Stability for Light Temperature (1304176, 1301076) (#3079)
johnpars Jan 14, 2021
8007c48
Fix labels style (#3046)
adrien-de-tocqueville Jan 14, 2021
2df0185
Fixed side effect on styles during compositor rendering. (#3081)
adrien-de-tocqueville Jan 14, 2021
bf833ce
[HDRP][Compositor] Fix size and spacing of compositor info boxes (#3101)
pmavridis Jan 14, 2021
7be5e6c
[HDRP][Compositor] Fix color picker UI glitch in the Graphics Composi…
pmavridis Jan 14, 2021
6413dc6
Fix 1299233 ies resize bug (#3094)
skhiat Jan 14, 2021
8998567
filter for xbone addded (#3116)
martint-unity Jan 15, 2021
027cb37
[Yamato] Enable cache server for standalone build jobs (#3106)
sophiaaar Jan 15, 2021
6429445
Fix undo redo on layered lit editor (#3059)
adrien-de-tocqueville Jan 15, 2021
d910dc8
Merge branch 'master' into hd/bugfix
sebastienlagarde Jan 15, 2021
9c216c8
[HDRP] Added Vulkan install in system requirements (#3122)
alelievr Jan 15, 2021
8dbde86
[HDRP] Fix issue with compositor related custom passes (#3055)
pmavridis Jan 15, 2021
a5a6590
Fixed some render texture leaks. (#3050)
JulienIgnace-Unity Jan 15, 2021
229f3e8
Hd/fix wizard runtime resources (#3123)
RSlysz Jan 15, 2021
0a42f9b
[HDRP] Fixed lookdev reload bug when viewing a scene object (#3108)
alelievr Jan 15, 2021
eb1d074
[HDRP] Fix error in Depth Of Field near radius blur calculation (#3131)
pmavridis Jan 15, 2021
22b5b7f
[HDRP] Fix GC allocs (#3136)
pmavridis Jan 15, 2021
8cd8fe6
Revert: Fix 1299233 ies resize bug (#3094)
sebastienlagarde Jan 15, 2021
9bcb75f
Merge branch 'master' into hd/bugfix
sebastienlagarde Jan 16, 2021
31defd2
Merge branch 'master' into hd/bugfix
sebastienlagarde Jan 16, 2021
6dffbc8
Hide light shadow near plane gizmo when shadows are disabled (#3114)
adrien-de-tocqueville Jan 16, 2021
c2262da
Merge remote-tracking branch 'origin/hd/bugfix' into HDRP/fix-composi…
pmavridis Jan 18, 2021
161f400
Fixed undo when adding/removing layers
pmavridis Jan 18, 2021
3ef5fce
Fix AOV crash
pmavridis Jan 19, 2021
9702e6e
Removed unnecessaryusing directives + changelog update
pmavridis Jan 19, 2021
78a0264
Do not change the selected layer after undo
pmavridis Jan 19, 2021
8007ed6
Merge branch 'master' into HDRP/fix-compositor-undo
sebastienlagarde Jan 19, 2021
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
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Fixed light gizmo showing shadow near plane when shadows are disabled.
- Fixed path tracing alpha channel support (case 1304187).
- Fixed shadow matte not working with ambient occlusion when MSAA is enabled
- Fixed issues with compositor's undo (cases 1305633, 1307170).

### Changed
- Change the source value for the ray tracing frame index iterator from m_FrameCount to the camera frame count (case 1301356).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,22 @@ static partial class Styles
public bool isDirty => m_IsEditorDirty;

public int defaultSelection = -1;
public int selectionIndex => m_layerList != null ? m_layerList.index : -1;
public int selectionIndex
{
get => m_layerList != null ? m_layerList.index : -1;
set
{
if (m_layerList != null) m_layerList.index = Math.Min(value, m_layerList.count - 1);
}
}


void AddLayerOfTypeCallback(object type)
{
Undo.RecordObject(m_compositionManager, "Add compositor sublayer");
m_compositionManager.AddNewLayer(m_layerList.index + 1, (CompositorLayer.LayerType)type);
m_SerializedProperties.layerList.serializedObject.Update();
m_compositionManager.DeleteLayerRTs();
m_compositionManager.UpdateLayerSetup();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ void OnGUI()
Undo.RegisterCreatedObjectUndo(compositor.outputCamera.gameObject, "Create Compositor");
Undo.RegisterCreatedObjectUndo(go, "Create Compositor");
}
else if (compositor)
else if (compositor && (compositor.enabled != enableCompositor))
{
string message = enableCompositor ? "Enable Compositor" : "Disable Compositor";
Undo.RecordObject(compositor, message);
compositor.enabled = enableCompositor;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This assignment was always creating an undo action, so we now do it only if necessary.

}
else
else if (!compositor)
{
return;
}
Expand Down Expand Up @@ -178,6 +178,9 @@ void OnGUI()
if (m_Editor)
{
m_Editor.OnInspectorGUI();

// Remember which layer was selected / drawn in the last draw call
s_SelectionIndex = m_Editor.selectionIndex;
}
}
GUILayout.EndScrollView();
Expand Down Expand Up @@ -214,7 +217,11 @@ void UndoCallback()

m_Editor.CacheSerializedObjects();
m_RequiresRedraw = true;
s_SelectionIndex = m_Editor.selectionIndex;

// After undo, set the selection index to the last shown layer, because the Unity Editor resets the value to the last layer in the list
m_Editor.defaultSelection = s_SelectionIndex;
m_Editor.selectionIndex = s_SelectionIndex;


CompositionManager compositor = CompositionManager.GetInstance();
// The compositor might be null even if the CompositionManagerEditor is not (in case the user switches from a scene with a compositor to a scene without one)
Expand All @@ -223,6 +230,10 @@ void UndoCallback()
// Some properties were changed, mark the profile as dirty so it can be saved if the user saves the scene
EditorUtility.SetDirty(compositor);
EditorUtility.SetDirty(compositor.profile);

// Clean-up existing cameras after undo, we will re-allocate the layer resources
CompositorCameraRegistry.GetInstance().CleanUpCameraOrphans(compositor.layers);
compositor.DeleteLayerRTs();
compositor.UpdateLayerSetup();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ public void Init(string layerID = "")
m_LayerCamera = newCameraGameObject.AddComponent<Camera>();
newCameraGameObject.AddComponent<HDAdditionalCameraData>();
CopyInternalCameraData();
CompositorCameraRegistry.GetInstance().RegisterInternalCamera(m_LayerCamera);

m_LayerCamera.name = "Compositor" + layerID;
m_LayerCamera.gameObject.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy | HideFlags.HideAndDontSave;
Expand Down Expand Up @@ -421,6 +422,7 @@ public void DestroyCameras()
CoreUtils.Destroy(cameraData);
}
m_LayerCamera.targetTexture = null;
CompositorCameraRegistry.GetInstance().UnregisterInternalCamera(m_LayerCamera);
CoreUtils.Destroy(m_LayerCamera);
m_LayerCamera = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,9 @@ void OnDestroy()
// We don't need the custom passes anymore
var hdPipeline = RenderPipelineManager.currentPipeline as HDRenderPipeline;
UnRegisterCustomPasses(hdPipeline);

// By now the s_CompositorManagedCameras should be empty, but clear it just to be safe
CompositorCameraRegistry.GetInstance().CleanUpCameraOrphans();
}

public void AddInputFilterAtLayer(CompositionFilter filter, int index)
Expand Down Expand Up @@ -962,5 +965,6 @@ static internal void UnRegisterCustomPasses(HDRenderPipeline hdPipeline)
hdPipeline.asset.beforePostProcessCustomPostProcesses.Remove(typeof(AlphaInjection).AssemblyQualifiedName);
}
}

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
using System.Collections.Generic;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;

namespace UnityEngine.Rendering.HighDefinition.Compositor
{
// Internal class to keep track of compositor allocated cameras.
// Required to properly manage cameras that are deleted or "ressurected" by undo/redo operations.
class CompositorCameraRegistry
{
static List<Camera> s_CompositorManagedCameras = new List<Camera>();
static private CompositorCameraRegistry s_CompositorCameraRegistry;
static public CompositorCameraRegistry GetInstance() =>
s_CompositorCameraRegistry ?? (s_CompositorCameraRegistry = new CompositorCameraRegistry());

// Keeps track of compositor allocated cameras
internal void RegisterInternalCamera(Camera camera)
{
s_CompositorManagedCameras.Add(camera);
}
internal void UnregisterInternalCamera(Camera camera)
{
s_CompositorManagedCameras.Remove(camera);
}

// Checks for any compositor allocated cameras that are now unused and frees their resources.
internal void CleanUpCameraOrphans(List<CompositorLayer> layers = null)
{
s_CompositorManagedCameras.RemoveAll(x => x == null);

for (int i = s_CompositorManagedCameras.Count - 1; i >= 0; i--)
{
bool found = false;
if (layers != null)
{
foreach (var layer in layers)
{
if (s_CompositorManagedCameras[i].Equals(layer.camera))
{
found = true;
break;
}
}
}

// If the camera is not used by any layer anymore, then destroy it
if (found == false && s_CompositorManagedCameras[i] != null)
{
var cameraData = s_CompositorManagedCameras[i].GetComponent<HDAdditionalCameraData>();
if (cameraData)
{
CoreUtils.Destroy(cameraData);
}
s_CompositorManagedCameras[i].targetTexture = null;
CoreUtils.Destroy(s_CompositorManagedCameras[i]);
s_CompositorManagedCameras.RemoveAt(i);
}
}

if (layers != null)
{
foreach (var layer in layers)
{
if (layer != null && !s_CompositorManagedCameras.Contains(layer.camera))
{
s_CompositorManagedCameras.Add(layer.camera);
}
}
}
}

internal void PrinCameraIDs()
{
for (int i = s_CompositorManagedCameras.Count - 1; i >= 0; i--)
{
var id = s_CompositorManagedCameras[i] ? s_CompositorManagedCameras[i].GetInstanceID() : 0;
}
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.