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
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ bool GeneratesWithShaderGraph()
shaderGraphOutput.GetOrRefreshShaderGraphObject().generatesWithShaderGraph;
}

public override bool supportsMaterialOffset
public override bool supportsSortingPriority
{
get
{
Expand Down Expand Up @@ -147,18 +147,18 @@ public override string GetRenderQueueStr()
private int GetRenderQueueOffset()
{
var renderQueueType = GetRenderQueueType();
var materialOffset = GetMaterialOffset();
var materialSortingPriority = GetMaterialSortingPriority();
return owner is VFXDecalHDRPOutput ?
HDRenderQueue.Clamps(k_RenderQueue_AllOpaque, ChangeType(renderQueueType, 0, owner.hasAlphaClipping) + materialOffset) :
ChangeType(renderQueueType, materialOffset, owner.hasAlphaClipping);
HDRenderQueue.Clamps(k_RenderQueue_AllOpaque, ChangeType(renderQueueType, 0, owner.hasAlphaClipping) + materialSortingPriority) :
ChangeType(renderQueueType, materialSortingPriority, owner.hasAlphaClipping);
}

private int GetMaterialOffset()
private int GetMaterialSortingPriority()
{
if (supportsMaterialOffset)
if (supportsSortingPriority)
{
int rawMaterialOffset = owner.GetMaterialOffset();
return ClampsTransparentRangePriority(rawMaterialOffset);
int rawMaterialSortingPriority = owner.GetMaterialSortingPriority();
return ClampsTransparentRangePriority(rawMaterialSortingPriority);
}
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Prevent VFX Graph compilation each time a property's min/max value is changed
- Prevent vfx re-compilation in some cases when a value has not changed
- Eye dropper in the color fields kept updating after pressing the Esc key
- Rename "Material Offset" to "Sorting Priority" in output render state settings [Case 1365257](https://issuetracker.unity3d.com/product/unity/issues/guid/1365257/)

## [12.0.0] - 2021-01-11
### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ All outputs share these settings and property ports. The only exception is the S
| --------------------------- | -------- | ------------------------------------------------------------ |
| **Blend Mode** | Enum | Specifies the blending method for the system and determines how to use the alpha. The options are :<br/>&#8226; **Opaque**: Does not use the alpha value and renders the output in the opaque pass. This also writes to the depth buffer.<br/>&#8226; **Alpha**: Uses the [standard alpha blend](https://docs.unity3d.com/Manual/SL-Blend.html) mode and renders the output in the transparent pass. By default, this enables GPU sorting for particle outputs (which you can override using the **Sort** setting).<br/>&#8226; **Premultiplied Alpha**: Uses the [premultiplied alpha blend mode](https://docs.unity3d.com/Manual/SL-Blend.html) and renders the output in the transparent pass. By default, this enables GPU sorting for particle outputs (which you can override using the **Sort** setting).<br/>&#8226; **Additive**: Uses the [additive blend mode](https://docs.unity3d.com/Manual/SL-Blend.html) for alpha and renders the output in the transparent pass. |
| **Use Alpha Clipping** | Bool | Indicates whether the system uses alpha clipping and discards pixels under a certain alpha threshold. If you enable this property, use the **Alpha Threshold** input to set the alpha value below which the system discards pixels. |
| **Material Offset** | Int | **(Inspector)** An offset Unity applies to the rendering order. This setting corresponds to the Material [Sorting Priority](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?subfolder=/manual/Renderer-And-Material-Priority.html) in HDRP and Material [Priority](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest?subfolder=/manual/simple-lit-shader.html) in URP. It is equivalent to modifying the [Material.renderQueue](https://docs.unity3d.com/ScriptReference/Material-renderQueue.html) property. This value can be negative or positive. URP clamps this value between -50 and 50, and HDRP clamps this value between -100 and 100. |
| **Sorting Priority** | Int | **(Inspector)** An offset Unity applies to the rendering order. This setting corresponds to the Material [Sorting Priority](https://docs.unity3d.com/Packages/com.unity.render-pipelines.high-definition@latest?subfolder=/manual/Renderer-And-Material-Priority.html) in HDRP and Material [Sorting Priority](https://docs.unity3d.com/Packages/com.unity.render-pipelines.universal@latest?subfolder=/manual/simple-lit-shader.html) in URP. It is equivalent to modifying the [Material.renderQueue](https://docs.unity3d.com/ScriptReference/Material-renderQueue.html) property. This value can be negative or positive. HDRP and URP clamps this value between -50 and 50. |
| **Generate Motion Vectors** | Bool | **(Inspector)** Indicates whether particles in the system write motion vectors and thus whether the System generates a motion vector pass. This is useful when you want temporal effects, like temporal anti-aliasing or motion blur, to take the output into account. Not all outputs can generate motion vectors and in that case, this setting is not visible.<br/>If you enable this setting with a transparent output, an **Alpha Threshold** input port appears. Use this port to specify the minimum alpha the system requires a pixel to have to write motion vectors for it. This is because motion vectors cannot be blended. |
| **Exclude From TAA** | Bool | **(Inspector)** Indicates whether the render pipeline excludes particles from temporal anti-aliasing (TAA). This is useful when particles look blurry when TAA is enabled and especially useful for fast moving particles. Not all outputs can exclude TAA and in that case, this setting is not visible. |
| **Cast Shadows** | Bool | **(Inspector)** Indicates whether particles in the system cast shadows and thus whether the System generates a shadow pass.<br/>If you enable this settings with a transparent output, an **Alpha Threshold** port appears. Use this port to specify the minimum alpha the system requires a pixel to have to write it to the shadow pass. This is because shadows cannot be transparent. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ void OnReorder(ReorderableList list)
{
for (int i = 0; i < m_OutputContexts.Count(); ++i)
{
m_OutputContexts[i].sortPriority = i;
m_OutputContexts[i].vfxSystemSortPriority = i;
}
}

Expand Down Expand Up @@ -184,7 +184,7 @@ void OnEnable()
{
m_CurrentGraph = resource.GetOrCreateGraph();
m_CurrentGraph.systemNames.Sync(m_CurrentGraph);
m_OutputContexts.AddRange(m_CurrentGraph.children.OfType<IVFXSubRenderer>().OrderBy(t => t.sortPriority));
m_OutputContexts.AddRange(m_CurrentGraph.children.OfType<IVFXSubRenderer>().OrderBy(t => t.vfxSystemSortPriority));
}

m_ReorderableList = new ReorderableList(m_OutputContexts, typeof(IVFXSubRenderer));
Expand Down Expand Up @@ -647,7 +647,7 @@ public override void OnInspectorGUI()
VisualEffectResource resource = asset.GetResource();

m_OutputContexts.Clear();
m_OutputContexts.AddRange(resource.GetOrCreateGraph().children.OfType<IVFXSubRenderer>().OrderBy(t => t.sortPriority));
m_OutputContexts.AddRange(resource.GetOrCreateGraph().children.OfType<IVFXSubRenderer>().OrderBy(t => t.vfxSystemSortPriority));

m_ReorderableList.DoLayoutList();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ public virtual SerializedProperty DoInspectorGUI()
{
var fieldInfo = prop.Key.field;
EditorGUI.BeginChangeCheck();
var attrs = fieldInfo.GetCustomAttributes(typeof(StringProviderAttribute), true);
if (attrs.Length > 0)
var stringAttribute = fieldInfo.GetCustomAttributes<StringProviderAttribute>(true);
var rangeAttribute = fieldInfo.GetCustomAttributes<RangeAttribute>(false).FirstOrDefault();
if (stringAttribute.Any())
{
var strings = StringPropertyRM.FindStringProvider(attrs)();
var strings = StringPropertyRM.FindStringProvider(stringAttribute.ToArray())();

int selected = prop.Value.hasMultipleDifferentValues ? -1 : System.Array.IndexOf(strings, prop.Value.stringValue);
int result = EditorGUILayout.Popup(ObjectNames.NicifyVariableName(prop.Value.name), selected, strings);
Expand Down Expand Up @@ -109,6 +110,19 @@ public virtual SerializedProperty DoInspectorGUI()

EditorGUILayout.IntPopup(prop.Value, enumNames, enumValues);
}
else if (fieldInfo.FieldType == typeof(int)
&& rangeAttribute != null
&& fieldInfo.GetCustomAttributes<DelayedAttribute>().Any())
{
//Workaround: Range & Delayed attribute are incompatible, avoid the slider usage to keep the delayed behavior
var newValue = EditorGUILayout.DelayedIntField(ObjectNames.NicifyVariableName(prop.Value.name), prop.Value.intValue);
if (EditorGUI.EndChangeCheck())
{
newValue = Mathf.Clamp(newValue, (int)rangeAttribute.min, (int)rangeAttribute.max);
prop.Value.intValue = newValue;
modifiedSetting = prop.Value;
}
}
else
{
bool visibleChildren = EditorGUILayout.PropertyField(prop.Value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface IVFXSubRenderer
bool hasShadowCasting { get; }
bool hasMotionVector { get; }
// TODO Add other per output rendering settings here
int sortPriority { get; set; }
int vfxSystemSortPriority { get; set; }

// Allow to setup material generated during import
void SetupMaterial(Material material);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@ protected enum FlipbookLayout
[VFXSetting, SerializeField, Tooltip("When enabled, transparent particles fade out when near the surface of objects writing into the depth buffer (e.g. when intersecting with solid objects in the level).")]
protected bool useSoftParticle = false;

[VFXSetting(VFXSettingAttribute.VisibleFlags.None), SerializeField, Header("Rendering Options"), Tooltip("")]
protected int sortPriority = 0;
[VFXSetting(VFXSettingAttribute.VisibleFlags.None), FormerlySerializedAs("sortPriority"), SerializeField, Header("Rendering Options"), Tooltip("")]
protected int vfxSystemSortPriority = 0;

[VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), SerializeField, Tooltip("Specifies whether to use GPU sorting for transparent particles.")]
protected SortMode sort = SortMode.Auto;
Expand Down Expand Up @@ -148,17 +148,17 @@ public virtual VFXOutputUpdate.Features outputUpdateFeatures
}
}

int IVFXSubRenderer.sortPriority
int IVFXSubRenderer.vfxSystemSortPriority
{
get
{
return sortPriority;
return vfxSystemSortPriority;
}
set
{
if (sortPriority != value)
if (vfxSystemSortPriority != value)
{
sortPriority = value;
vfxSystemSortPriority = value;
Invalidate(InvalidationCause.kSettingChanged);
}
}
Expand Down Expand Up @@ -573,7 +573,7 @@ public override IEnumerable<VFXMapping> additionalMappings
{
get
{
yield return new VFXMapping("sortPriority", sortPriority);
yield return new VFXMapping("sortPriority", vfxSystemSortPriority);
if (HasIndirectDraw())
{
yield return new VFXMapping("indirectDraw", 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Reflection;
using UnityEditor;
using UnityEngine;
using UnityEngine.Serialization;

namespace UnityEditor.VFX
{
Expand Down Expand Up @@ -31,12 +32,12 @@ public enum BlendMode

public virtual bool isBlendModeOpaque { get { return blendMode == BlendMode.Opaque; } }

[VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), Delayed, SerializeField, Tooltip("Specifies an offset applied to the material render queue.")]
protected int materialOffset = 0;
[VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), Range(-50, 50), FormerlySerializedAs("materialOffset"), Delayed, SerializeField, Tooltip("Specifies an offset applied to the material render queue.")]
protected int sortingPriority = 0;

public virtual int GetMaterialOffset()
public virtual int GetMaterialSortingPriority()
{
return materialOffset;
return sortingPriority;
}

public virtual bool hasMotionVector
Expand Down Expand Up @@ -70,8 +71,8 @@ protected override IEnumerable<string> filteredOutSettings
foreach (var setting in base.filteredOutSettings)
yield return setting;

if (!subOutput.supportsMaterialOffset)
yield return nameof(materialOffset);
if (!subOutput.supportsSortingPriority)
yield return nameof(sortingPriority);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using UnityEditor.VFX;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Serialization;
using UnityEngine.VFX;

namespace UnityEditor.VFX
Expand All @@ -13,8 +14,8 @@ class VFXStaticMeshOutput : VFXContext, IVFXSubRenderer
[VFXSetting, Tooltip("Specifies the shader with which the mesh output is rendered.")]
private Shader shader; // not serialized here but in VFXDataMesh

[VFXSetting(VFXSettingAttribute.VisibleFlags.None), SerializeField, Header("Rendering Options")]
protected int sortPriority = 0;
[VFXSetting(VFXSettingAttribute.VisibleFlags.None), FormerlySerializedAs("sortPriority"), SerializeField, Header("Rendering Options")]
protected int vfxSystemSortPriority = 0;

[VFXSetting(VFXSettingAttribute.VisibleFlags.InInspector), SerializeField, Tooltip("When enabled, the mesh output will cast shadows.")]
protected bool castShadows = false;
Expand All @@ -25,17 +26,17 @@ class VFXStaticMeshOutput : VFXContext, IVFXSubRenderer

public virtual bool hasMotionVector { get { return false; } } //TODO

int IVFXSubRenderer.sortPriority
int IVFXSubRenderer.vfxSystemSortPriority
{
get
{
return sortPriority;
return vfxSystemSortPriority;
}
set
{
if (sortPriority != value)
if (vfxSystemSortPriority != value)
{
sortPriority = value;
vfxSystemSortPriority = value;
Invalidate(InvalidationCause.kSettingChanged);
}
}
Expand Down Expand Up @@ -233,7 +234,7 @@ public override IEnumerable<VFXMapping> additionalMappings
{
get
{
yield return new VFXMapping("sortPriority", sortPriority);
yield return new VFXMapping("sortPriority", vfxSystemSortPriority);
yield return new VFXMapping("castShadows", castShadows ? 1 : 0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public void Init(VFXAbstractRenderedOutput owner)
public virtual bool supportsExposure { get { return false; } }
public virtual bool supportsMotionVector { get { return false; } }
public virtual bool supportsExcludeFromTAA { get { return false; } }
public virtual bool supportsMaterialOffset { get { return true; } }
public virtual bool supportsSortingPriority { get { return true; } }

// Sealed override as SRP suboutputs cannot have dependencies
public sealed override void CollectDependencies(HashSet<ScriptableObject> objs, bool ownedOnly = true) { }
Expand Down Expand Up @@ -65,9 +65,9 @@ public virtual string GetRenderQueueStr()
throw new NotImplementedException("Unknown blend mode");
}

int rawMaterialOffset = owner.GetMaterialOffset();
int materialOffset = Mathf.Clamp(rawMaterialOffset, -50, +50);
return baseRenderQueue + materialOffset.ToString("+#;-#;+0");
int rawMaterialSortingPriority = owner.GetMaterialSortingPriority();
int queueOffset = Mathf.Clamp(rawMaterialSortingPriority, -50, +50);
return baseRenderQueue + queueOffset.ToString("+#;-#;+0");
}

public virtual IEnumerable<KeyValuePair<string, VFXShaderWriter>> GetStencilStateOverridesStr()
Expand Down
Loading