Skip to content
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

[ShaderGraph][2022.1] Fix direction transform from view to world space #5614

Merged
merged 6 commits into from
Sep 13, 2021

Conversation

jessebarker
Copy link
Contributor

@jessebarker jessebarker commented Sep 10, 2021

Purpose of this PR

This PR fixes https://fogbugz.unity3d.com/f/cases/1362034/

Transform direction from view to world was effectively doing a position transform rather than direction. This change fixes that.


Testing status

Manual testing according to the repro case in the bug (confirmed that the transform from world->view and then back from view->world yields vec3(0, 0, 0) when subtracted from the original vec3.

Screen Shot 2021-09-10 at 2 32 02 PM

Yamato details below.

Here are the built-in test results that got "erased" when the ShaderGraph test project reference images got updated (reference images from TestProjects/ShaderGraph have no impact on the two built-in target test projects):


Comments to reviewers

Notes for the reviewers you have assigned.

@github-actions
Copy link

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.
Link to Yamato: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics
Search for your PR branch using the sidebar on the left, then add the following segment(s) to the end of the URL (you may need multiple tabs depending on how many packages you change)

Shader Graph
/.yamato%252Fall-shadergraph.yml%2523PR_ShaderGraph_trunk
Depending on your PR, you may also want
/.yamato%252Fall-shadergraph_builtin_foundation.yml%2523PR_ShaderGraph_BuiltIn_Foundation_trunk
/.yamato%252Fall-shadergraph_builtin_lighting.yml%2523PR_ShaderGraph_BuiltIn_Lighting_trunk

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.

@jessebarker
Copy link
Contributor Author

Backports on this one? @marctem

@jessebarker jessebarker marked this pull request as ready for review September 11, 2021 01:36
@jessebarker jessebarker requested a review from a team as a code owner September 11, 2021 01:36
@jessebarker jessebarker changed the title [ShaderGraph][2021.1] Fix direction transform from view to world space [ShaderGraph][2022.1] Fix direction transform from view to world space Sep 11, 2021
@@ -189,7 +189,7 @@ public void GenerateNodeCode(ShaderStringBuilder sb, GenerationMode generationMo
{
if (conversion.to == CoordinateSpace.World)
{
transformString = string.Format("mul(UNITY_MATRIX_I_V, $precision4({0}, 1)).xyz", inputValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Won't this make TransformViewToWorld wrong for position? I believe this needs a conditional like the otehr cases (see ViewToObject below).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. Fixed. I think this also means the test images don't need to be updated, but I'm re-running to confirm.

Copy link
Contributor

@joshua-davis joshua-davis Sep 13, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, if the images don't need to be updated, this implies we don't have a test for both scenarios. Maybe adding new node tests might be good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants