New functionality that supports compile time branching based on user created dropdowns.#4137
Conversation
Fix undo for dropdowns. Limit dropdowns to subgraphs. Reordering dropdowns does not affect subgraph node selection. Fix id assignment for keywords (should find unused id, not use current list index). Fix default dropdown name. Fix searcher for dropdowns.
… into sg/surfgrad/dropdowns # Conflicts: # com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardFieldView.cs # com.unity.shadergraph/Editor/Drawing/Blackboard/BlackboardProvider.cs # com.unity.shadergraph/Editor/Drawing/Inspector/PropertyDrawers/ShaderInputPropertyDrawer.cs # com.unity.shadergraph/Editor/Drawing/Views/MaterialGraphView.cs
… into sg/surfgrad/dropdowns
… into sg/surfgrad/dropdowns # Conflicts: # com.unity.shadergraph/CHANGELOG.md
joshua-davis
left a comment
There was a problem hiding this comment.
One other small note: When you re-order the items in the keywords the Default value seems to point to whatever's at the index, not the item by name. That is if you have:
{ItemA, ItemB, ItemC} and the default is currently ItemB and you then reorder to {ItemA, ItemC, ItemB} then the default will now be ItemC (both index 1). Is this intended? Not a big deal either way, just something I noticed.
Fix for preventing default dropdown value changing when reordering dropdown entries. Add default else to dropdown code gen.
| } | ||
|
|
||
| { | ||
| sb.AppendLine("{"); |
There was a problem hiding this comment.
nit: you could use sb.BlockScope here to clean this up a bit. In particular this becomes:
using(sb.BlockScope())
{
var value = GetSlotValue(GetSlotIdForPermutation(new KeyValuePair<ShaderDropdown, int>(dropdown, i)), generationMode);
sb.AppendLine(string.Format($"{GetVariableNameForSlot(OutputSlotId)} = {value};"));
}
Something I just noticed that I didn't before.
joshua-davis
left a comment
There was a problem hiding this comment.
Small nit, but otherwise looks good
ghost
left a comment
There was a problem hiding this comment.
All issues found during my testing were addressed.
… into sg/surfgrad/dropdowns
… into sg/surfgrad/dropdowns
… into sg/surfgrad/dropdowns # Conflicts: # com.unity.shadergraph/CHANGELOG.md
|
This one has already had a full green test panel on Shader Graph ABV with the changes specific to this branch: |
… into sg/surfgrad/dropdowns # Conflicts: # com.unity.shadergraph/CHANGELOG.md
|
ScriptableRenderPipelinePrivate console passes for this PR: https://yamato.cds.internal.unity3d.com/jobs/339-ScriptableRenderPipelinePrivate/tree/sg%252Fsurfgrad%252Fdropdowns/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_trunk/6557856/job/pipeline PR to land changes to ScriptableRenderPipelinePrivate: https://github.cds.internal.unity3d.com/unity/ScriptableRenderPipelinePrivate/pull/168 |
cdxntchou
left a comment
There was a problem hiding this comment.
Should probably remove the unnecessary versioning changes. The rest looks good!
| keywordGuidMap[input0.m_Guid.m_GuidSerialized] = keyword; | ||
| } | ||
|
|
||
| foreach (var serializedDropdown in graphData0.m_SerializedDropdowns) |
There was a problem hiding this comment.
Do we need to handle dropdowns in old master node graphs coming in? Are we backporting dropdowns to master nodes?
There was a problem hiding this comment.
This is a good question, should definitely get clarity on that flow.
There was a problem hiding this comment.
If we are not (which I would hope at this point tbh), then all the graphdata0 or abstractmaterialnode0 stuff should be unnecessary
There was a problem hiding this comment.
Cheers, I have removed this now.
|
|
||
| public string m_KeywordGuidSerialized; | ||
|
|
||
| public string m_DropdownGuidSerialized; |
There was a problem hiding this comment.
again, will dropdowns be ported to old master nodes? If no, not needed
There was a problem hiding this comment.
Also removed, cheers.
|
|
||
| public List<SerializationHelper.JSONSerializedElement> m_SerializedKeywords; | ||
|
|
||
| public List<SerializationHelper.JSONSerializedElement> m_SerializedDropdowns; |
There was a problem hiding this comment.
if not backporting, unnecessary
… into sg/surfgrad/dropdowns
|
All test have now passed. I will only pull to resolve the Changelog conflict. |
… into sg/surfgrad/dropdowns # Conflicts: # com.unity.shadergraph/CHANGELOG.md
… into sg/surfgrad/dropdowns # Conflicts: # com.unity.shadergraph/CHANGELOG.md
Please read the Contributing guide before making a PR.
Checklist for PR maker
need-backport-*label. After you backport the PR, the label changes tobackported-*.CHANGELOG.mdfile.Purpose of this PR
This PR adds support for branching based on user created dropdowns.
Motivation for work: https://docs.google.com/document/d/1XeUfc2MauivBYx82V68c_u2aQBZJxt2h9VRVu9yemGY/edit
The workflow, and UI for creating dropdowns is very similar to the behavior for working with keyword enums. Dropdowns are a new type of blackboard property, where the user can specify a list of options, and a default. All of the scoping, and keyword specific controls are stripped down, so it is simpler than keywords. The user can drag a dropdown property out onto the graph canvas, which will create a corresponding branch node, with slots for each option.
The key distinction for dropdowns - dropdowns are exposed on the UI of subgraph node instances, where those subgraphs have defined dropdowns. This allows the user to pick the desired branch per subgraph instance from the parent graph. This is all resolved at compile time.
https://jira.unity3d.com/browse/GSG-354
Testing status
Manual testing:
Utilized in Surface Gradient example "Sphere Dropdown And Connection Testing":
https://github.cds.internal.unity3d.com/unity/surfgrad-examples
Automated tests:
Graphics/TestProjects/ShaderGraph/UtilityNodes.unity : Dropdowns
https://jira.unity3d.com/browse/GSG-396
Comments to reviewers
Basic video of this in action:
SubgraphDropdown.zip
For testing, use instructions here for getting the compatible build: https://github.cds.internal.unity3d.com/unity/surfgrad-examples/blob/master/README.md
IMPORTANT - you cannot create more than dropdown using the conventional + via the blackboard. If you do this, any secondarily created properties will not be visible, and the graph will break. You MUST make new properties by duplicating the first dropdown using Ctrl-D, until this bug has been addressed. The issue also affects keyword enums, and will be addressed by a separate PR as it is common to both.
I will merge in latest of master periodically to get ready for final merge.
Version numbers of serialized data will need bumping between landing of PRs.