Skip to content

Commit

Permalink
Post Processing disabling in Universal Render Pipeline asset (Unity-T…
Browse files Browse the repository at this point in the history
…echnologies#1873)

* Changed PostProssingData to optional in ForwardRenderer and DeferredRenderer. Builds will no longer include post processing shaders and textures when it will be disabled. [case 1269524]

* Disabling dithering, stopNaN, aa if post processing is disabled in renderer

* Removing deferred renderer code path as it is no longer a renderer

* Adding conditional cleanup to m_FinalPostProcessPass and m_ColorGradingLutPass as they can be null

* Moved PostProcessData into Universal Render Pipeline asset and made it optional.

* Adding ReloadAllNullProperties method into Renderer2DData

* In ForwardRendererData.Create method ReloadAllNullProperties will not called when in play mode. It accidently code lost during refactoring.

* Adding small explanation why PostProcessData UI is conditional

* Some small UI changes

* Fixing some of the help box messages to more correct ones

* Deprecated ForwardRendererData.postProcessData

* Fixing post processing gray out spilling on other properties. Changing post processing property not to be disabled when warning is shown.

* Changing post process warning logic in base camera to reflect on each option

* Fixing correctly warning to show up for dithering

* Refactor

* Adding in upgrader dirty at the end to trigger changes on disk

* Adding post processing disabling in documentation manual

* Downscaling images to width 488 as it fits the rest of the images

* Edited texts and images.

Co-authored-by: Oleksandr Kokoshyn <oleksandr.kokoshyn@unity3d.com>
  • Loading branch information
lukaschod and oleks-k authored Dec 2, 2020
1 parent 865bc12 commit f617b06
Show file tree
Hide file tree
Showing 17 changed files with 220 additions and 72 deletions.
1 change: 1 addition & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Shader functions SampleSH9, SampleSHPixel, SampleSHVertex are now gamma corrected in gamma space. As result LightProbes are gamma corrected too.
- The maximum number of visible lights when using OpenGL ES 3.x on Android now depends on the minimum OpenGL ES 3.x version as configured in PlayerSettings.
- The default value of the HDR property of a newly created Universal Render Pipeline Asset, is now set to true.
- Moved `ForwardRendererData.postProcessData` into `UniversalRenderPipelineAsset.postProcessData` and made it optional. Builds do not include post-processing shaders and textures when `UniversalRenderPipelineAsset.postProcessData` is null.

### Fixed
- Fixed an issue where the CapturePass would not capture the post processing effects.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ This section allows you to fine-tune global post-processing settings.

| Property | Description |
| ---------------- | ------------------------------------------------------------ |
| __Post Processing__ | This check box turns post-processing on (check box selected) or off (check box cleared) for the current URP asset.<br/>If you clear this check box, Unity excludes post-processing shaders and textures from the build, unless one of the following conditions is true:<ul><li>Other assets in the build refer to the assets related to post-processing.</li><li>A different URP asset has the Post Processing property enabled.</li></ul> |
| __Post Process Data__ | The asset containing references to shaders and Textures that the Renderer uses for post-processing.<br/>**Note:** Changes to this property are necessary only for advanced customization use cases. |
| __Grading Mode__ | Select the [color grading](https://docs.unity3d.com/Manual/PostProcessing-ColorGrading.html) mode to use for the Project.<br />&#8226; __High Dynamic Range__: This mode works best for high precision grading similar to movie production workflows. Unity applies color grading before tonemapping.<br />&#8226; __Low Dynamic Range__: This mode follows a more classic workflow. Unity applies a limited range of color grading after tonemapping. |
| __LUT Size__ | Set the size of the internal and external [look-up textures (LUTs)](https://docs.unity3d.com/Manual/PostProcessing-ColorGrading.html) that the Universal Render Pipeline uses for color grading. Higher sizes provide more precision, but have a potential cost of performance and memory use. You cannot mix and match LUT sizes, so decide on a size before you start the color grading process.<br />The default value, **32**, provides a good balance of speed and quality. |

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,6 @@ This section describes the properties of the Forward Renderer asset.

![URP Forward Renderer](Images/urp-assets/urp-forward-renderer.png)

### Forward Renderer

This section contains properties for advanced customization use cases.

| Property | Description |
|:-|:-|
| Post Process Data | The asset containing references to shaders and Textures that the Renderer uses for post-processing.<br/>**Note:** This property is for advanced customization use cases. |

### Filtering

This section contains properties that define which layers the renderer draws.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ This section contains the overview of the new features in this release.

This section contains the overview of the major improvements in this release.

### TODO: Improvement 1
### You can disable Post Processing for a specific URP asset

The URP asset now has the Post Processing check box. This check box turns post-processing on (check box selected) or off (check box cleared) for the current URP asset.<br/>If you clear this check box, Unity excludes post-processing shaders and textures from the build, unless one of the following conditions is true:<ul><li>Other assets in the build refer to the assets related to post-processing.</li><li>A different URP asset has the Post Processing property enabled.</li></ul>

![Post processing properties](../Images/whats-new/urp-11/urp-asset-post-processing.png)<br/>*Post processing section in the URP asset.*

## Issues resolved

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ 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 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 All @@ -53,6 +54,7 @@ struct LightBlendStyleProps
SerializedProperty m_DefaultCustomMaterial;
SerializedProperty m_MaxLightRenderTextureCount;
SerializedProperty m_MaxShadowRenderTextureCount;
SerializedProperty m_PostProcessData;

SerializedProperty m_UseCameraSortingLayersTexture;
SerializedProperty m_CameraSortingLayersTextureBound;
Expand Down Expand Up @@ -92,6 +94,7 @@ void OnEnable()
m_LightBlendStyles = serializedObject.FindProperty("m_LightBlendStyles");
m_MaxLightRenderTextureCount = serializedObject.FindProperty("m_MaxLightRenderTextureCount");
m_MaxShadowRenderTextureCount = serializedObject.FindProperty("m_MaxShadowRenderTextureCount");
m_PostProcessData = serializedObject.FindProperty("m_PostProcessData");

m_CameraSortingLayersTextureBound = serializedObject.FindProperty("m_CameraSortingLayersTextureBound");
m_UseCameraSortingLayersTexture = serializedObject.FindProperty("m_UseCameraSortingLayersTexture");
Expand Down Expand Up @@ -202,6 +205,14 @@ 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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", "The asset containing references to shaders and Textures that the Renderer uses for post-processing.");
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 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 @@ -57,11 +57,18 @@ public override void OnInspectorGUI()
serializedObject.Update();

EditorGUILayout.Space();
EditorGUILayout.LabelField(Styles.RendererTitle, EditorStyles.boldLabel); // Title
EditorGUI.indentLevel++;
EditorGUILayout.PropertyField(m_PostProcessData, Styles.PostProcessLabel);
EditorGUI.indentLevel--;
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++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ 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 @@ -138,6 +140,7 @@ internal class Styles
SerializedProperty m_ShaderVariantLogLevel;

LightRenderingMode selectedLightRenderingMode;
SerializedProperty m_PostProcessData;
SerializedProperty m_ColorGradingMode;
SerializedProperty m_ColorGradingLutSize;
SerializedProperty m_UseFastSRGBLinearConversion;
Expand Down Expand Up @@ -213,6 +216,7 @@ 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 @@ -388,6 +392,49 @@ 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 @@ -398,6 +445,7 @@ 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
Loading

0 comments on commit f617b06

Please sign in to comment.