Skip to content

Commit

Permalink
[Port] [2021.3] Fixed the BlockNode to display the name using Display…
Browse files Browse the repository at this point in the history
…Name.

Jira: https://jira.unity3d.com/browse/UUM-76081

Added a displayName to AbstractMaterialNode to use when displaying it in the Graph Inspector. displayName defaults to name, and is overridden by BlockNode to create it using shaderStage and displayName.
![image](https://media.github.cds.internal.unity3d.com/user/761/files/74c417ea-4dc5-43e9-8637-65ecb678eb63)

The changed name looks like this:
<table>
<tr><th>Before</th><th>After</th></tr>
<tr><td>VertexDescription.Position Node</td><td>Vertex Position Node</td></tr>
<tr><td>VertexDescription.Normal Node</td><td>Vertex Normal Node</td></tr>
<tr><td>VertexDescription.Tangent Node</td><td>Vertex Tangent Node</td></tr>
<tr><td>SurfaceDescription.BaseColor Node</td><td>Fragment Base Color Node</td></tr>
<tr><td>SurfaceDescription.NormalTS Node</td><td>Fragment Normal (Tangent Space) Node</td></tr>
<tr><td>SurfaceDescription.Metalilc Node</td><td>Fragment Metallic Node</td></tr>
<tr><td>SurfaceDescription.Smoothness Node</td><td>Fragment Smoothness Node</td></tr>
<tr><td>SurfaceDescription.Emission Node</td><td>Fragment Emissiton Node</td></tr>
<tr><td>SurfaceDescription.Occlusion Node</td><td>Fragment Ambient Occlusion Node</td></tr>
</table>
  • Loading branch information
svc-reach-platform-support authored and Evergreen committed Sep 10, 2024
1 parent d18c90e commit b08c5f3
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ public string name
set { m_Name = value; }
}

public virtual string displayName => name;

public string[] synonyms;

protected virtual string documentationPage => name;
Expand Down
18 changes: 17 additions & 1 deletion Packages/com.unity.shadergraph/Editor/Data/Nodes/BlockNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,23 @@ class BlockNode : AbstractMaterialNode
[NonSerialized]
BlockFieldDescriptor m_Descriptor;

public override string displayName
{
get
{
string displayName = "";
if (m_Descriptor != null)
{
displayName = m_Descriptor.shaderStage.ToString();
if (!string.IsNullOrEmpty(displayName))
displayName += " ";
displayName += m_Descriptor.displayName;
}

return displayName;
}
}

public override bool canCutNode => false;
public override bool canCopyNode => false;

Expand Down Expand Up @@ -78,7 +95,6 @@ public void Init(BlockFieldDescriptor fieldDescriptor)
? $"{fieldDescriptor.tag}.{fieldDescriptor.name}"
: $"{BlockFields.VertexDescription.name}.{k_CustomBlockDefaultName}";


// TODO: This exposes the MaterialSlot API
// TODO: This needs to be removed but is currently required by HDRP for DiffusionProfileInputMaterialSlot
if (m_Descriptor is CustomSlotBlockFieldDescriptor customSlotDescriptor)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ internal virtual void AddCustomNodeProperties(VisualElement parentElement, Abstr
VisualElement CreateGUI(AbstractMaterialNode node, InspectableAttribute attribute, out VisualElement propertyVisualElement)
{
VisualElement nodeSettings = new VisualElement();
var nameLabel = PropertyDrawerUtils.CreateLabel($"{node.name} Node", 0, FontStyle.Bold);
var nameLabel = PropertyDrawerUtils.CreateLabel($"{node.displayName} Node", 0, FontStyle.Bold);
nodeSettings.Add(nameLabel);
if (node.sgVersion < node.latestVersion)
{
Expand Down

0 comments on commit b08c5f3

Please sign in to comment.