Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 17 additions & 2 deletions com.unity.render-pipelines.core/Runtime/Volume/VolumeManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public sealed class VolumeManager
/// A reference to the main <see cref="VolumeStack"/>.
/// </summary>
/// <seealso cref="VolumeStack"/>
public VolumeStack stack { get; private set; }
public VolumeStack stack { get; set; }

/// <summary>
/// The current list of all available types that derive from <see cref="VolumeComponent"/>.
Expand Down Expand Up @@ -65,6 +65,11 @@ private set
// Recycled list used for volume traversal
readonly List<Collider> m_TempColliders;

// The default stack the volume manager uses.
// We cache this as users able to change the stack through code and
// we want to be able to switch to the default one through the ResetMainStack() function.
VolumeStack m_DefaultStack = null;

VolumeManager()
{
m_SortedVolumes = new Dictionary<int, List<Volume>>();
Expand All @@ -75,7 +80,8 @@ private set

ReloadBaseTypes();

stack = CreateStack();
m_DefaultStack = CreateStack();
stack = m_DefaultStack;
}

/// <summary>
Expand All @@ -92,6 +98,15 @@ public VolumeStack CreateStack()
return stack;
}

/// <summary>
/// Resets the main stack to be the default one.
/// Call this function if you've assigned the main stack to something other than the default one.
/// </summary>
public void ResetMainStack()
{
stack = m_DefaultStack;
}

/// <summary>
/// Destroy a Volume Stack
/// </summary>
Expand Down
3 changes: 3 additions & 0 deletions com.unity.render-pipelines.universal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [10.7.0] - 2021-07-02

### Added
- Added support for controlling Volume Framework Update Frequency in UI on Cameras and URP Asset as well as through scripting.

### Fixed
- Fixed terrain hole shadowing [case 1349305]
- Fixed artifacts in Speed Tree 8 billboard LODs due to SpeedTree LOD smoothing/crossfading [case 1348407]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ internal class Styles
public static GUIContent mixedLightingSupportLabel = EditorGUIUtility.TrTextContent("Mixed Lighting", "Makes the render pipeline include mixed-lighting Shader Variants in the build.");
public static GUIContent debugLevel = EditorGUIUtility.TrTextContent("Debug Level", "Controls the level of debug information generated by the render pipeline. When Profiling is selected, the pipeline provides detailed profiling tags.");
public static GUIContent shaderVariantLogLevel = EditorGUIUtility.TrTextContent("Shader Variant Log Level", "Controls the level logging in of shader variants information is outputted when a build is performed. Information will appear in the Unity console when the build finishes.");
public static GUIContent volumeFrameworkUpdateMode = EditorGUIUtility.TrTextContent("Volume Update Mode", "Select how Unity updates Volumes: every frame or when triggered via scripting. In the Editor, Unity updates Volumes every frame when not in the Play mode.");

// Adaptive performance settings
public static GUIContent useAdaptivePerformance = EditorGUIUtility.TrTextContent("Use adaptive performance", "Allows Adaptive Performance to adjust rendering quality during runtime");
Expand All @@ -86,6 +87,7 @@ internal class Styles

// Dropdown menu options
public static string[] mainLightOptions = { "Disabled", "Per Pixel" };
public static string[] volumeFrameworkUpdateOptions = { "Every Frame", "Via Scripting" };
public static string[] opaqueDownsamplingOptions = {"None", "2x (Bilinear)", "4x (Box)", "4x (Bilinear)"};
}

Expand Down Expand Up @@ -135,6 +137,7 @@ internal class Styles
SerializedProperty m_DebugLevelProp;

SerializedProperty m_ShaderVariantLogLevel;
SerializedProperty m_VolumeFrameworkUpdateModeProp;

LightRenderingMode selectedLightRenderingMode;
SerializedProperty m_ColorGradingMode;
Expand Down Expand Up @@ -210,6 +213,7 @@ void OnEnable()
m_DebugLevelProp = serializedObject.FindProperty("m_DebugLevel");

m_ShaderVariantLogLevel = serializedObject.FindProperty("m_ShaderVariantLogLevel");
m_VolumeFrameworkUpdateModeProp = serializedObject.FindProperty("m_VolumeFrameworkUpdateMode");

m_ColorGradingMode = serializedObject.FindProperty("m_ColorGradingMode");
m_ColorGradingLutSize = serializedObject.FindProperty("m_ColorGradingLutSize");
Expand Down Expand Up @@ -413,6 +417,7 @@ void DrawAdvancedSettings()
EditorGUILayout.PropertyField(m_MixedLightingSupportedProp, Styles.mixedLightingSupportLabel);
EditorGUILayout.PropertyField(m_DebugLevelProp, Styles.debugLevel);
EditorGUILayout.PropertyField(m_ShaderVariantLogLevel, Styles.shaderVariantLogLevel);
CoreEditorUtils.DrawPopup(Styles.volumeFrameworkUpdateMode, m_VolumeFrameworkUpdateModeProp, Styles.volumeFrameworkUpdateOptions);
EditorGUI.indentLevel--;
EditorGUILayout.Space();
EditorGUILayout.Space();
Expand Down Expand Up @@ -527,7 +532,7 @@ void DrawRendererListLayout(ReorderableList list, SerializedProperty prop)
UpdateDefaultRendererValue(index, newIndex);
};
}

void UpdateDefaultRendererValue(int index)
{
// If the index that is being removed is lower than the default renderer value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ static class Styles
public static GUIContent allowHDR = EditorGUIUtility.TrTextContent("HDR", "High Dynamic Range gives you a wider range of light intensities, so your lighting looks more realistic. With it, you can still see details and experience less saturation even with bright light.", (Texture) null);
public static GUIContent priority = EditorGUIUtility.TrTextContent("Priority", "A camera with a higher priority is drawn on top of a camera with a lower priority [ -100, 100 ].");
public static GUIContent clearDepth = EditorGUIUtility.TrTextContent("Clear Depth", "If enabled, depth from the previous camera will be cleared.");

public static GUIContent rendererType = EditorGUIUtility.TrTextContent("Renderer", "Controls which renderer this camera uses.");

public static GUIContent volumeLayerMask = EditorGUIUtility.TrTextContent("Volume Mask", "This camera will only be affected by volumes in the selected scene-layers.");
public static GUIContent volumeTrigger = EditorGUIUtility.TrTextContent("Volume Trigger", "A transform that will act as a trigger for volume blending. If none is set, the camera itself will act as a trigger.");
public static GUIContent volumesSettingsText = EditorGUIUtility.TrTextContent("Volumes", "These settings define how Volumes affect this Camera.");
public static GUIContent volumeLayerMask = EditorGUIUtility.TrTextContent("Mask", "This Camera is only affected by Volumes in the Layers that are assigned to the Camera.");
public static GUIContent volumeTrigger = EditorGUIUtility.TrTextContent("Trigger", "A Transform component that acts as a trigger for Volume blending. If none is set, the Camera itself acts as a trigger.");
public static GUIContent volumeUpdates = EditorGUIUtility.TrTextContent("Update Mode", "Select how Unity updates Volumes: every frame or when triggered via scripting. In the Editor, Unity updates Volumes every frame when not in the Play mode.");

public static GUIContent renderPostProcessing = EditorGUIUtility.TrTextContent("Post Processing", "Enable this to make this camera render post-processing effects.");
public static GUIContent antialiasing = EditorGUIUtility.TrTextContent("Anti-aliasing", "The anti-aliasing method to use.");
Expand Down Expand Up @@ -138,6 +139,7 @@ static class Styles
SerializedProperty m_AdditionalCameraDataCameras;
SerializedProperty m_AdditionalCameraDataVolumeLayerMask;
SerializedProperty m_AdditionalCameraDataVolumeTrigger;
SerializedProperty m_AdditionalCameraDataVolumeFrameworkUpdateMode;
SerializedProperty m_AdditionalCameraDataRenderPostProcessing;
SerializedProperty m_AdditionalCameraDataAntialiasing;
SerializedProperty m_AdditionalCameraDataAntialiasingQuality;
Expand Down Expand Up @@ -415,6 +417,7 @@ void init(List<Object> additionalCameraData)
m_AdditionalCameraDataRendererProp = m_AdditionalCameraDataSO.FindProperty("m_RendererIndex");
m_AdditionalCameraDataVolumeLayerMask = m_AdditionalCameraDataSO.FindProperty("m_VolumeLayerMask");
m_AdditionalCameraDataVolumeTrigger = m_AdditionalCameraDataSO.FindProperty("m_VolumeTrigger");
m_AdditionalCameraDataVolumeFrameworkUpdateMode = m_AdditionalCameraDataSO.FindProperty("m_VolumeFrameworkUpdateModeOption");
m_AdditionalCameraDataRenderPostProcessing = m_AdditionalCameraDataSO.FindProperty("m_RenderPostProcessing");
m_AdditionalCameraDataAntialiasing = m_AdditionalCameraDataSO.FindProperty("m_Antialiasing");
m_AdditionalCameraDataAntialiasingQuality = m_AdditionalCameraDataSO.FindProperty("m_AntialiasingQuality");
Expand Down Expand Up @@ -759,29 +762,30 @@ void DrawTargetTexture(UniversalRenderPipelineAsset rpAsset)

void DrawVolumes()
{
bool hasChanged = false;
LayerMask selectedVolumeLayerMask;
Transform selectedVolumeTrigger;
if (m_AdditionalCameraDataSO == null)
{
selectedVolumeLayerMask = 1; // "Default"
selectedVolumeTrigger = null;
}
else
{
selectedVolumeLayerMask = m_AdditionalCameraDataVolumeLayerMask.intValue;
selectedVolumeTrigger = (Transform)m_AdditionalCameraDataVolumeTrigger.objectReferenceValue;
}
// Display the Volume Update mode, LayerMask and Trigger
LayerMask selectedVolumeLayerMask = m_AdditionalCameraDataVolumeLayerMask.intValue;
Transform selectedVolumeTrigger = (Transform)m_AdditionalCameraDataVolumeTrigger.objectReferenceValue;

hasChanged |= DrawLayerMask(m_AdditionalCameraDataVolumeLayerMask, ref selectedVolumeLayerMask, Styles.volumeLayerMask);
hasChanged |= DrawObjectField(m_AdditionalCameraDataVolumeTrigger, ref selectedVolumeTrigger, Styles.volumeTrigger);
EditorGUILayout.LabelField(Styles.volumesSettingsText, EditorStyles.boldLabel);

if (hasChanged)
EditorGUI.indentLevel++;

EditorGUI.BeginChangeCheck();
DrawLayerMask(m_AdditionalCameraDataVolumeLayerMask, ref selectedVolumeLayerMask, Styles.volumeLayerMask);
DrawObjectField(m_AdditionalCameraDataVolumeTrigger, ref selectedVolumeTrigger, Styles.volumeTrigger);
EditorGUILayout.PropertyField(m_AdditionalCameraDataVolumeFrameworkUpdateMode, Styles.volumeUpdates);

if (EditorGUI.EndChangeCheck())
{
m_AdditionalCameraDataVolumeLayerMask.intValue = selectedVolumeLayerMask;
m_AdditionalCameraDataVolumeTrigger.objectReferenceValue = selectedVolumeTrigger;

VolumeFrameworkUpdateMode curVolumeUpdateMode = (VolumeFrameworkUpdateMode)m_AdditionalCameraDataVolumeFrameworkUpdateMode.intValue;
camera.SetVolumeFrameworkUpdateMode(curVolumeUpdateMode);

m_AdditionalCameraDataSO.ApplyModifiedProperties();
}
EditorGUI.indentLevel--;
}

void DrawRenderer(UniversalRenderPipelineAsset rpAsset)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ public enum ColorGradingMode
HighDynamicRange
}

/// <summary>
/// Defines the update frequency for the Volume Framework.
/// </summary>
public enum VolumeFrameworkUpdateMode
{
[InspectorName("Every Frame")]
EveryFrame = 0,
[InspectorName("Via Scripting")]
ViaScripting = 1,
[InspectorName("Use Pipeline Settings")]
UsePipelineSettings = 2,
}

[ExcludeFromPreset]
public partial class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerializationCallbackReceiver
{
Expand Down Expand Up @@ -168,6 +181,7 @@ public partial class UniversalRenderPipelineAsset : RenderPipelineAsset, ISerial
[SerializeField] ShadowResolution m_ShadowAtlasResolution = ShadowResolution._256;

[SerializeField] ShaderVariantLogLevel m_ShaderVariantLogLevel = ShaderVariantLogLevel.Disabled;
[SerializeField] VolumeFrameworkUpdateMode m_VolumeFrameworkUpdateMode = VolumeFrameworkUpdateMode.EveryFrame;

// Note: A lut size of 16^3 is barely usable with the HDR grading mode. 32 should be the
// minimum, the lut being encoded in log. Lower sizes would work better with an additional
Expand Down Expand Up @@ -659,6 +673,11 @@ public ShaderVariantLogLevel shaderVariantLogLevel
set { m_ShaderVariantLogLevel = value; }
}

/// <summary>
/// Returns the selected update mode for volumes.
/// </summary>
public VolumeFrameworkUpdateMode volumeFrameworkUpdateMode => m_VolumeFrameworkUpdateMode;

[Obsolete("PipelineDebugLevel is deprecated. Calling debugLevel is not necessary.", false)]
public PipelineDebugLevel debugLevel
{
Expand Down
Loading