-
Notifications
You must be signed in to change notification settings - Fork 855
[ShaderGraph] [2022.1] [Ruby] Fixing Transform Node Issues #5770
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed. HDRP Shader Graph SRP Core Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did some local testing to verify no regressions:
- Created blackboard items of all property and keyword types and viewed them in Inspector to ensure property drawers all work as expected
- Tested undo/redo with changing property defaults/exposed flag
- Tested interacting with the graph settings and undo/redo of those options
Did find an unrelated bug with the inspector for when a property/keyword is selected and a graph setting change is undo/redo-ed, the inspector switches back to the node settings tab, will investigate and fix that in a separate PR
|
||
namespace UnityEditor.ShaderGraph.UnitTests | ||
{ | ||
class NodeTests : ShaderGraphTestRenderer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love these tests.
AssetDatabase.CreateFolder(parentPath, dir); | ||
} | ||
curpath = curpath + '/'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the commented out code just for reference? Or something we might need for anticipated test framework chnages?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I can delete this. Turns out there's a single function that can create an entire path all at once at the system level.. Don't really need this function. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl
Outdated
Show resolved
Hide resolved
com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl
Outdated
Show resolved
Hide resolved
com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl
Outdated
Show resolved
Hide resolved
com.unity.render-pipelines.core/ShaderLibrary/SpaceTransforms.hlsl
Outdated
Show resolved
Hide resolved
com.unity.shadergraph/Editor/Drawing/Inspector/InspectorView.cs
Outdated
Show resolved
Hide resolved
TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs
Outdated
Show resolved
Hide resolved
var pixels = temp.GetPixels32(0); | ||
foreach (var pixel in pixels) | ||
{ | ||
if ((pixel.r != value.r) || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this have numerical issues across different gpus by comparing exact pixel values instead of using an epsilon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's 8 bit values, so you get an espilon of at least ~(0.5/255) for free. The idea is that the shader is set up to return exact (1,0,0) i.e. (255,0,0) for correct results, which should be pretty darn stable across GPUs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(would not be true if you are comparing values in the middle of the range, like looking for (128,0,0) -- that would be subject to potential round off error unless you are very careful to center your values so they round correctly.)
TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs
Show resolved
Hide resolved
TestProjects/ShaderGraph/Assets/CommonAssets/Editor/ShaderGraphTestRenderer.cs
Outdated
Show resolved
Hide resolved
It's so awesome to see this getting cleaned up! Thank you Chris. I've focused on the functions related to tangent space mostly and what you did looks perfect.
else or alternatively skip sgn in the line with the transform and then only use sgn when doNormalize is true
So what's technically happening is if M is the mikkts matrix used to transform a normal (interpolated vertex tangent frame with various requirements) then conceptually we can think of M = (~A)^T. In other words we can think of the matrix M we are required to use as the transposed Anyway doing so will allow vectors to maintain their usual relationships to the normal in the new space (ie. preserving their dot product with the normal). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All main issues have been fixed or clarified. Looking good!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
Purpose of this PR
Fix for https://fogbugz.unity3d.com/f/cases/1368082/
Errors (and tests of fixes) recorded in this doc:
https://docs.google.com/spreadsheets/d/1P7Bc-2sSsrH40x_kEZDIRC9lQHQ-z2qBeCqxB-g4Rmg/edit#gid=0
Docs jira ticket: https://jira.unity3d.com/browse/GSG-602
This PR also adds user control over the normalization behavior of the direction transforms,


via an added "Normalize" control on the transform node.
When doing a position transform, the normalize control is not shown:
The changes are implemented as an upgrade on the node. Existing Transform nodes will now show up as "deprecated", with an update button to allow a manual user upgrade to the new behavior:

All newly created Transform nodes use the new behavior.
This PR also adds the missing "Normal" conversion type:

We expanded on the PropertyDrawer interface to allow teardown callbacks. This enables us to only show the normalize control when the user has selected a "Direction" transform, by registering with the node to be notified when it changes (and de-registering on teardown).
We split out the code that builds transforms between spaces into it's own helper utility, out of the Transform node. The code is also restructured to make it simpler and easier to build. This allows us to re-use the code to do arbitrary space transforms from any node. Some care was taken to ensure we have identical results from the new code when using version 0 and 1, and the "correct" results when using version 2.
// ignore
Fix for https://fogbugz.unity3d.com/f/cases/1346477/
Triplanar node is hardcoded to world space, is very difficult to adapt to work in object space.
With this change we introduce controls for the user to choose the input and output normal spaces.
Input space should be set to the space used by the input normal vector.
Output space should be set to the desired space for the output (post-triplanar-blend) normal.
// ignore
Testing status
Tested modifications to transform node by comparing new results to old results, for all possible transforms. Results verified in scene, in master preview, and on node previews:

Tested new V2 behavior:
Added Unit Tests for all of the above V2 behaviors, and V1 backwards compatibility.




A->B->C test:
Inverse test:
Legacy V1 behavior test:
Normalization test:
Yamato:
ShaderGraph PR: 🟢
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/sg%252Ffix%252F1346477/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_trunk/9151905/job/pipeline
master: 4e40e2a
https://yamato.cds.internal.unity3d.com/jobs/902-Graphics/tree/master/.yamato%252Fshadergraph-osx-metal.yml%2523ShaderGraph_OSX_Metal_playmode_mono_Linear_trunk/9110395/job
Comments to reviewers
@mmikk -- revew SpaceTransforms.hsll