Skip to content

Commit

Permalink
Moving post process data back to renderer (Unity-Technologies#2902)
Browse files Browse the repository at this point in the history
* Moving post process data back to renderer

* Removing nulling of post process data in renderer 2d
  • Loading branch information
lukaschod authored Dec 16, 2020
1 parent 4530da7 commit b88c1b3
Show file tree
Hide file tree
Showing 16 changed files with 83 additions and 114 deletions.
2 changes: 1 addition & 1 deletion com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Bloom in Gamma color-space now more closely matches Linear color-space, this will mean project using Bloom and Gamma color-space may need to adjust Bloom Intensity to match previous look.
- Autodesk Interactive Shader Graph files and folders containing them were renamed. The new file paths do not have spaces.
- Changed shader keywords of main light shadow from toggling to enumerating.
- Moved `ForwardRendererData.postProcessData` into `UniversalRenderPipelineAsset.postProcessData` and made it optional. Builds do not include post-processing shaders and textures when `UniversalRenderPipelineAsset.postProcessData` is null.
- Always use "High" quality normals, which normalizes the normal in pixel shader. "Low" quality normals looked too much like a bug.
- Re-enabled implicit MSAA resolve to backbuffer on Metal MacOS.
- Changed Post Process Data to bool. When it is no enabled all post processing is stripped from build, when it is enabled you can still override resources there.

### Fixed
- Fixed an issue where the 2D Renderer was incorrectly rendering transparency with normal maps on an empty background.
Expand Down
8 changes: 8 additions & 0 deletions com.unity.render-pipelines.universal/Custom.meta

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

Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class Styles
public static readonly GUIContent generalHeader = EditorGUIUtility.TrTextContent("General");
public static readonly GUIContent lightRenderTexturesHeader = EditorGUIUtility.TrTextContent("Light Render Textures");
public static readonly GUIContent lightBlendStylesHeader = EditorGUIUtility.TrTextContent("Light Blend Styles", "A Light Blend Style is a collection of properties that describe a particular way of applying lighting.");
public static readonly GUIContent postProcessHeader = EditorGUIUtility.TrTextContent("Post-processing");

public static readonly GUIContent transparencySortMode = EditorGUIUtility.TrTextContent("Transparency Sort Mode", "Default sorting mode used for transparent objects");
public static readonly GUIContent transparencySortAxis = EditorGUIUtility.TrTextContent("Transparency Sort Axis", "Axis used for custom axis sorting mode");
Expand All @@ -27,7 +28,8 @@ class Styles
public static readonly GUIContent maskTextureChannel = EditorGUIUtility.TrTextContent("Mask Texture Channel", "Which channel of the mask texture will affect this Light Blend Style.");
public static readonly GUIContent blendMode = EditorGUIUtility.TrTextContent("Blend Mode", "How the lighting should be blended with the main color of the objects.");
public static readonly GUIContent useDepthStencilBuffer = EditorGUIUtility.TrTextContent("Depth/Stencil Buffer", "Uncheck this when you are certain you don't use any feature that requires the depth/stencil buffer (e.g. Sprite Mask). Not using the depth/stencil buffer may improve performance, especially on mobile platforms.");
public static readonly GUIContent postProcessData = EditorGUIUtility.TrTextContent("Post Process Data (Deprecated)", "The asset containing references to shaders and Textures that the Renderer uses for post-processing.");
public static readonly GUIContent postProcessIncluded = EditorGUIUtility.TrTextContent("Enabled", "Turns post-processing on (check box selected) or off (check box cleared). If you clear this check box, Unity excludes post-processing render Passes, shaders, and textures from the build.");
public static readonly GUIContent postProcessData = EditorGUIUtility.TrTextContent("Data", "The asset containing references to shaders and Textures that the Renderer uses for post-processing.");

public static readonly GUIContent cameraSortingLayerTextureHeader = EditorGUIUtility.TrTextContent("Camera Sorting Layers Texture", "Layers from back most to selected bounds will be rendered to _CameraSortingLayersTexture");
public static readonly GUIContent cameraSortingLayerTextureBound = EditorGUIUtility.TrTextContent("Bound", "Layers from back most to selected bounds will be rendered to _CameraSortingLayersTexture");
Expand Down Expand Up @@ -64,6 +66,7 @@ struct LightBlendStyleProps
SavedBool m_LightRenderTexturesFoldout;
SavedBool m_LightBlendStylesFoldout;
SavedBool m_CameraSortingLayerTextureFoldout;
SavedBool m_PostProcessingFoldout;

Analytics.Renderer2DAnalytics m_Analytics = Analytics.Renderer2DAnalytics.instance;
Renderer2DData m_Renderer2DData;
Expand Down Expand Up @@ -128,6 +131,7 @@ void OnEnable()
m_LightRenderTexturesFoldout = new SavedBool($"{target.GetType()}.LightRenderTexturesFoldout", true);
m_LightBlendStylesFoldout = new SavedBool($"{target.GetType()}.LightBlendStylesFoldout", true);
m_CameraSortingLayerTextureFoldout = new SavedBool($"{target.GetType()}.CameraSortingLayerTextureFoldout", true);
m_PostProcessingFoldout = new SavedBool($"{target.GetType()}.PostProcessingFoldout", true);
}

private void OnDestroy()
Expand All @@ -143,6 +147,7 @@ public override void OnInspectorGUI()
DrawLightRenderTextures();
DrawLightBlendStyles();
DrawCameraSortingLayerTexture();
DrawPostProcessing();

m_WasModified |= serializedObject.hasModifiedProperties;
serializedObject.ApplyModifiedProperties();
Expand Down Expand Up @@ -205,14 +210,6 @@ private void DrawGeneral()
if (EditorGUI.EndChangeCheck() && m_HDREmulationScale.floatValue < 1.0f)
m_HDREmulationScale.floatValue = 1.0f;

// PostProcessData was moved into Universal Render Pipeline asset.
// We keep this for backward compatibility if user still has PostProcessData in Renderer.
if (m_PostProcessData.objectReferenceValue != null)
{
EditorGUILayout.PropertyField(m_PostProcessData, Styles.postProcessData);
EditorGUILayout.HelpBox("The Post Processing Data property is moved to the Render Pipeline asset.", MessageType.Warning);
}

EditorGUILayout.Space();
}

Expand Down Expand Up @@ -252,5 +249,25 @@ private void DrawLightBlendStyles()

EditorGUILayout.Space();
}

private void DrawPostProcessing()
{
CoreEditorUtils.DrawSplitter();
m_PostProcessingFoldout.value = CoreEditorUtils.DrawHeaderFoldout(Styles.postProcessHeader, m_PostProcessingFoldout.value);
if (!m_PostProcessingFoldout.value)
return;

EditorGUI.BeginChangeCheck();
var postProcessIncluded = EditorGUILayout.Toggle(Styles.postProcessIncluded, m_PostProcessData.objectReferenceValue != null);
if (EditorGUI.EndChangeCheck())
{
m_PostProcessData.objectReferenceValue = postProcessIncluded ? UnityEngine.Rendering.Universal.PostProcessData.GetDefaultPostProcessData() : null;
}
if (postProcessIncluded)
{
EditorGUILayout.PropertyField(m_PostProcessData, Styles.postProcessData);
}
EditorGUILayout.Space();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Create2DRendererDataAsset : EndNameEditAction
public override void Action(int instanceId, string pathName, string resourceFile)
{
var instance = CreateInstance<Renderer2DData>();
instance.postProcessData = PostProcessData.GetDefaultPostProcessData();
AssetDatabase.CreateAsset(instance, pathName);
Selection.activeObject = instance;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ namespace UnityEditor.Rendering.Universal
private static class Styles
{
public static readonly GUIContent RendererTitle = new GUIContent("Forward Renderer", "Custom Forward Renderer for Universal RP.");
public static readonly GUIContent PostProcessLabel = new GUIContent("Post Process Data (Deprecated)", "The asset containing references to shaders and Textures that the Renderer uses for post-processing.");
public static readonly GUIContent PostProcessIncluded = EditorGUIUtility.TrTextContent("Enabled", "Turns post-processing on (check box selected) or off (check box cleared). If you clear this check box, Unity excludes post-processing render Passes, shaders, and textures from the build.");
public static readonly GUIContent PostProcessLabel = new GUIContent("Data", "The asset containing references to shaders and Textures that the Renderer uses for post-processing.");
public static readonly GUIContent FilteringLabel = new GUIContent("Filtering", "Controls filter rendering settings for this renderer.");
public static readonly GUIContent OpaqueMask = new GUIContent("Opaque Layer Mask", "Controls which opaque layers this renderer draws.");
public static readonly GUIContent TransparentMask = new GUIContent("Transparent Layer Mask", "Controls which transparent layers this renderer draws.");
Expand Down Expand Up @@ -58,18 +59,6 @@ public override void OnInspectorGUI()

EditorGUILayout.Space();

// PostProcessData was moved into Universal Render Pipeline asset.
// We keep this for backward compatibility if user still has PostProcessData in Renderer.
if (m_PostProcessData.objectReferenceValue != null)
{
EditorGUILayout.LabelField(Styles.RendererTitle, EditorStyles.boldLabel); // Title
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_PostProcessData, Styles.PostProcessLabel);
EditorGUILayout.HelpBox("The Post Processing Data property is moved to the Render Pipeline asset.", MessageType.Warning);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
}

EditorGUILayout.LabelField(Styles.FilteringLabel, EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_OpaqueLayerMask, Styles.OpaqueMask);
Expand Down Expand Up @@ -97,6 +86,22 @@ public override void OnInspectorGUI()
EditorGUI.indentLevel--;
EditorGUILayout.Space();

EditorGUILayout.LabelField("Post-processing", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
var postProcessIncluded = EditorGUILayout.Toggle(Styles.PostProcessIncluded, m_PostProcessData.objectReferenceValue != null);
if (EditorGUI.EndChangeCheck())
{
m_PostProcessData.objectReferenceValue = postProcessIncluded ? PostProcessData.GetDefaultPostProcessData() : null;
}
if (postProcessIncluded)
{
EditorGUILayout.PropertyField(m_PostProcessData, Styles.PostProcessLabel);
}
//m_PostProcessData.objectReferenceValue = PostProcessData.GetDefaultPostProcessData();
EditorGUI.indentLevel--;
EditorGUILayout.Space();

EditorGUILayout.LabelField("Overrides", EditorStyles.boldLabel);
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_DefaultStencilState, Styles.defaultStencilStateLabel, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ internal class Styles
public static GUIContent supportsSoftShadows = EditorGUIUtility.TrTextContent("Soft Shadows", "If enabled pipeline will perform shadow filtering. Otherwise all lights that cast shadows will fallback to perform a single shadow sample.");

// Post-processing
public static GUIContent postProcessLabel = EditorGUIUtility.TrTextContent("Post Process Data", "The asset containing references to shaders and Textures that the Renderer uses for post-processing.");
public static GUIContent postProcessIncluded = EditorGUIUtility.TrTextContent("Post Processing", "Turns post-processing on (check box selected) or off (check box cleared). If you clear this check box, Unity excludes post-processing render Passes, shaders, and textures from the build.");
public static GUIContent colorGradingMode = EditorGUIUtility.TrTextContent("Grading Mode", "Defines how color grading will be applied. Operators will react differently depending on the mode.");
public static GUIContent colorGradingLutSize = EditorGUIUtility.TrTextContent("LUT size", "Sets the size of the internal and external color grading lookup textures (LUTs).");
public static GUIContent useFastSRGBLinearConversion = EditorGUIUtility.TrTextContent("Fast sRGB/Linear conversions", "Use faster, but less accurate approximation functions when converting between the sRGB and Linear color spaces.");
Expand Down Expand Up @@ -151,7 +149,6 @@ internal class Styles
SerializedProperty m_ShaderVariantLogLevel;

LightRenderingMode selectedLightRenderingMode;
SerializedProperty m_PostProcessData;
SerializedProperty m_ColorGradingMode;
SerializedProperty m_ColorGradingLutSize;
SerializedProperty m_UseFastSRGBLinearConversion;
Expand Down Expand Up @@ -231,7 +228,6 @@ void OnEnable()

m_ShaderVariantLogLevel = serializedObject.FindProperty("m_ShaderVariantLogLevel");

m_PostProcessData = serializedObject.FindProperty("m_PostProcessData");
m_ColorGradingMode = serializedObject.FindProperty("m_ColorGradingMode");
m_ColorGradingLutSize = serializedObject.FindProperty("m_ColorGradingLutSize");

Expand Down Expand Up @@ -446,49 +442,6 @@ void DrawPostProcessingSettings()

EditorGUI.indentLevel++;

#pragma warning disable 618 // Obsolete warning
bool renderersUsePostProcessData = false;
for (int i = 0; i < m_RendererDataProp.arraySize; i++)
{
var rendererData = m_RendererDataProp.GetArrayElementAtIndex(i).objectReferenceValue as ScriptableRendererData;

var forwardRendererData = rendererData as ForwardRendererData;
if (forwardRendererData != null && forwardRendererData.postProcessData != null)
{
renderersUsePostProcessData = true;
break;
}

var renderer2DData = rendererData as UnityEngine.Experimental.Rendering.Universal.Renderer2DData;
if (renderer2DData != null && renderer2DData.postProcessData != null)
{
renderersUsePostProcessData = true;
break;
}
}
#pragma warning restore 618 // Obsolete warning

GUI.enabled = !renderersUsePostProcessData;
EditorGUI.BeginChangeCheck();
var postProcessIncluded = EditorGUILayout.Toggle(Styles.postProcessIncluded, m_PostProcessData.objectReferenceValue != null);
if (EditorGUI.EndChangeCheck())
{
m_PostProcessData.objectReferenceValue = postProcessIncluded ? PostProcessData.GetDefaultPostProcessData() : null;
}
if (postProcessIncluded)
{
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_PostProcessData, Styles.postProcessLabel);
EditorGUI.indentLevel--;
}
GUI.enabled = true;

if (renderersUsePostProcessData)
{
EditorGUILayout.HelpBox("The URP asset contains Renderers that use custom Post Processing data, this check box has no effect.", MessageType.Warning);
}

GUI.enabled = postProcessIncluded || renderersUsePostProcessData;
EditorGUILayout.PropertyField(m_ColorGradingMode, Styles.colorGradingMode);
if (!isHdrOn && m_ColorGradingMode.intValue == (int)ColorGradingMode.HighDynamicRange)
EditorGUILayout.HelpBox(Styles.colorGradingModeWarning, MessageType.Warning);
Expand All @@ -499,7 +452,6 @@ void DrawPostProcessingSettings()
m_ColorGradingLutSize.intValue = Mathf.Clamp(m_ColorGradingLutSize.intValue, UniversalRenderPipelineAsset.k_MinLutSize, UniversalRenderPipelineAsset.k_MaxLutSize);
if (isHdrOn && m_ColorGradingMode.intValue == (int)ColorGradingMode.HighDynamicRange && m_ColorGradingLutSize.intValue < 32)
EditorGUILayout.HelpBox(Styles.colorGradingLutSizeWarning, MessageType.Warning);
GUI.enabled = true;

EditorGUILayout.PropertyField(m_UseFastSRGBLinearConversion, Styles.useFastSRGBLinearConversion);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static class Styles

public static readonly string missingRendererWarning = "The currently selected Renderer is missing from the Universal Render Pipeline asset.";
public static readonly string noRendererError = "There are no valid Renderers available on the Universal Render Pipeline asset.";
public static readonly string disabledPostprocessing = "Post Processing is currently disabled on the current Universal Render Pipeline asset.";
public static readonly string disabledPostprocessing = "Post Processing is currently disabled on the current Universal Render Pipeline renderer.";

public static GUIContent[] cameraBackgroundType =
{
Expand Down Expand Up @@ -620,9 +620,29 @@ void DrawRenderingSettings(CameraRenderType camType, UniversalRenderPipelineAsse
EditorGUILayout.EndFoldoutHeaderGroup();
}

private bool IsAnyRendererHasPostProcessingEnabled(UniversalRenderPipelineAsset rpAsset)
{
int selectedRendererOption = m_AdditionalCameraDataRendererProp.intValue;

if (selectedRendererOption < -1 || selectedRendererOption > rpAsset.m_RendererDataList.Length || m_AdditionalCameraDataRendererProp.hasMultipleDifferentValues)
return false;

var rendererData = selectedRendererOption == -1 ? rpAsset.m_RendererData : rpAsset.m_RendererDataList[selectedRendererOption];

var fowardRendererData = rendererData as ForwardRendererData;
if (fowardRendererData != null && fowardRendererData.postProcessData == null)
return true;

var fenderer2DData = rendererData as UnityEngine.Experimental.Rendering.Universal.Renderer2DData;
if (fenderer2DData != null && fenderer2DData.postProcessData == null)
return true;

return false;
}

void DrawPostProcessingOverlay(UniversalRenderPipelineAsset rpAsset)
{
bool isPostProcessingEnabled = rpAsset.postProcessData == null && m_AdditionalCameraDataRenderPostProcessing.boolValue;
bool isPostProcessingEnabled = IsAnyRendererHasPostProcessingEnabled(rpAsset) && m_AdditionalCameraDataRenderPostProcessing.boolValue;

EditorGUILayout.PropertyField(m_AdditionalCameraDataRenderPostProcessing, Styles.renderPostProcessing);

Expand Down Expand Up @@ -829,7 +849,7 @@ void DrawPostProcessing(UniversalRenderPipelineAsset rpAsset)
{
// We want to show post processing warning only once and below the first option
// This way we will avoid cluttering the camera UI
bool showPostProcessWarning = rpAsset.postProcessData == null;
bool showPostProcessWarning = IsAnyRendererHasPostProcessingEnabled(rpAsset);

EditorGUILayout.PropertyField(m_AdditionalCameraDataRenderPostProcessing, Styles.renderPostProcessing);
showPostProcessWarning &= !ShowPostProcessingWarning(showPostProcessWarning && m_AdditionalCameraDataRenderPostProcessing.boolValue);
Expand Down
Loading

0 comments on commit b88c1b3

Please sign in to comment.