Skip to content

Commit 4ab10ca

Browse files
fredericv-unity3dsebastienlagarde
authored andcommitted
Find the appropriate default frame settings per editor (case 1247631) #1129
1 parent c01d193 commit 4ab10ca

File tree

4 files changed

+37
-13
lines changed

4 files changed

+37
-13
lines changed

com.unity.render-pipelines.high-definition/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1111
- Appropriately constraint blend distance of reflection probe while editing with the inspector (case 1248931)
1212
- Fixed fallback for ray tracing and light layers (1258837).
1313
- Fixed Sorting Priority not displayed correctly in the DrawRenderers custom pass UI.
14-
14+
- Fixed default frame settings MSAA toggle for reflection probes (case 1247631)
15+
1516
### Changed
1617
- The `CustomPassLoadCameraColor` and `CustomPassSampleCameraColor` functions now returns the correct color buffer when used in after post process instead of the color pyramid (which didn't had post processes).
1718

com.unity.render-pipelines.high-definition/Editor/Lighting/Reflection/HDProbeEditor.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ interface IHDProbeEditor
1616
bool showChromeGizmo { get; set; }
1717
}
1818

19-
abstract class HDProbeEditor<TProvider, TSerialized> : Editor, IHDProbeEditor
19+
abstract class HDProbeEditor<TProvider, TSerialized> : Editor, IHDProbeEditor, IDefaultFrameSettingsType
2020
where TProvider : struct, HDProbeUI.IProbeUISettingsProvider, InfluenceVolumeUI.IInfluenceUISettingsProvider
2121
where TSerialized : SerializedHDProbe
2222
{
@@ -142,5 +142,10 @@ static Func<float> ComputeCapturePointPreviewSizeGetter()
142142
}
143143
internal static float capturePointPreviewSize
144144
{ get { return s_CapturePointPreviewSizeGetter(); } }
145+
146+
public FrameSettingsRenderType GetFrameSettingsType()
147+
=> GetTarget(target).mode == ProbeSettings.Mode.Realtime
148+
? FrameSettingsRenderType.RealtimeReflection
149+
: FrameSettingsRenderType.CustomOrBakedReflection;
145150
}
146151
}

com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/DefaultSettingsPanel.cs

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,27 @@ public static SettingsProvider CreateSettingsProvider()
2222
keywords = SettingsProvider.GetSearchKeywordsFromGUIContentProperties<HDRenderPipelineUI.Styles.GeneralSection>()
2323
.Concat(SettingsProvider.GetSearchKeywordsFromGUIContentProperties<DefaultSettingsPanelIMGUI.Styles>())
2424
.Concat(OverridableFrameSettingsArea.frameSettingsKeywords).ToArray(),
25-
guiHandler = s_IMGUIImpl.OnGUI,
25+
guiHandler = s_IMGUIImpl.DoGUI,
2626
};
2727
}
2828

2929
class DefaultSettingsPanelIMGUI
3030
{
31+
// A wrapper for CoreEditorDrawers
32+
class CoreEditorDrawerEditorWrapper : Editor, IDefaultFrameSettingsType
33+
{
34+
public FrameSettingsRenderType GetFrameSettingsType()
35+
{
36+
switch (HDRenderPipelineUI.selectedFrameSettings)
37+
{
38+
case HDRenderPipelineUI.SelectedFrameSettings.Camera: return FrameSettingsRenderType.Camera;
39+
case HDRenderPipelineUI.SelectedFrameSettings.RealtimeReflection: return FrameSettingsRenderType.RealtimeReflection;
40+
case HDRenderPipelineUI.SelectedFrameSettings.BakedOrCustomReflection: return FrameSettingsRenderType.CustomOrBakedReflection;
41+
}
42+
throw new Exception("unreachable");
43+
}
44+
}
45+
3146
public class Styles
3247
{
3348
public const int labelWidth = 220;
@@ -46,8 +61,9 @@ public class Styles
4661
ReorderableList m_BeforePostProcessCustomPostProcesses;
4762
ReorderableList m_AfterPostProcessCustomPostProcesses;
4863
int m_CurrentVolumeProfileInstanceID;
64+
private Editor m_Cache;
4965

50-
public void OnGUI(string searchContext)
66+
public void DoGUI(string searchContext)
5167
{
5268
m_ScrollViewPosition = GUILayout.BeginScrollView(m_ScrollViewPosition, EditorStyles.largeLabel);
5369
Draw_GeneralSettings();
@@ -268,7 +284,9 @@ void Draw_DefaultFrameSettings()
268284
var serializedObject = new SerializedObject(hdrpAsset);
269285
var serializedHDRPAsset = new SerializedHDRenderPipelineAsset(serializedObject);
270286

271-
HDRenderPipelineUI.FrameSettingsSection.Draw(serializedHDRPAsset, null);
287+
Editor.CreateCachedEditor(hdrpAsset, typeof(CoreEditorDrawerEditorWrapper), ref m_Cache);
288+
289+
HDRenderPipelineUI.FrameSettingsSection.Draw(serializedHDRPAsset, m_Cache);
272290
serializedObject.ApplyModifiedProperties();
273291
}
274292
}

com.unity.render-pipelines.high-definition/Editor/RenderPipeline/Settings/FrameSettingsUI.Drawers.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ public static MaterialQualityMode Into(this MaterialQuality quality)
4545
}
4646
}
4747

48+
interface IDefaultFrameSettingsType
49+
{
50+
FrameSettingsRenderType GetFrameSettingsType();
51+
}
52+
4853
partial class FrameSettingsUI
4954
{
5055
enum Expandable
@@ -132,14 +137,9 @@ static HDRenderPipelineAsset GetHDRPAssetFor(Editor owner)
132137
static FrameSettings GetDefaultFrameSettingsFor(Editor owner)
133138
{
134139
HDRenderPipelineAsset hdrpAsset = GetHDRPAssetFor(owner);
135-
if (owner is IHDProbeEditor)
136-
{
137-
if ((owner as IHDProbeEditor).GetTarget(owner.target).mode == ProbeSettings.Mode.Realtime)
138-
return hdrpAsset.GetDefaultFrameSettings(FrameSettingsRenderType.RealtimeReflection);
139-
else
140-
return hdrpAsset.GetDefaultFrameSettings(FrameSettingsRenderType.CustomOrBakedReflection);
141-
}
142-
return hdrpAsset.GetDefaultFrameSettings(FrameSettingsRenderType.Camera);
140+
return owner is IDefaultFrameSettingsType getType
141+
? hdrpAsset.GetDefaultFrameSettings(getType.GetFrameSettingsType())
142+
: hdrpAsset.GetDefaultFrameSettings(FrameSettingsRenderType.Camera);
143143
}
144144

145145
static void Drawer_SectionRenderingSettings(SerializedFrameSettings serialized, Editor owner, bool withOverride)

0 commit comments

Comments
 (0)