Skip to content

Conversation

@joshua-davis
Copy link
Contributor

@joshua-davis joshua-davis commented Jan 8, 2021

…orrect calculation.

Do not merge before #2752

Please read the Contributing guide before making a PR.

Checklist for PR maker

  • Have you added a backport label (if needed)? For example, the need-backport-* label. After you backport the PR, the label changes to backported-*.
  • Have you updated the changelog? Each package has a CHANGELOG.md file.
  • Have you updated or added the documentation for your PR? When you add a new feature, change a property name, or change the behavior of a feature, it's best practice to include related documentation changes in the same PR. If you do add documentation, make sure to add the relevant Graphics Docs team member as a reviewer of the PR. If you are not sure which person to add, see the Docs team contacts sheet.
  • Have you added a graphic test for your PR (if needed)? When you add a new feature, or discover a bug that tests don't cover, please add a graphic test.

Purpose of this PR

The calculation for the ViewNode in Tangent space used an old method that assumed the tangent space basis was orthonormal. The Transform node was updated but the view node wasn't.


Testing status

Tested the attached shader graph in the bug: https://fogbugz.unity3d.com/f/cases/1296788/


Comments to reviewers

Notes for the reviewers you have assigned.

@ghost ghost self-requested a review January 11, 2021 18:35
@joshua-davis joshua-davis changed the title bugfix for view direction node in tangent space being not using the c… [ShaderGraph] [master] [bugfix 1296788] Bugfix for view direction node in tangent space being not using the c… Jan 11, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

TransformWorldToTangent contains a normalization step, whereas the previous algorithm doesn't normalize. Can you remove the normalization step and see if the algorithm still works? This will allow us to backport it to versions where we don't plan on normalizing the view direction coming in from URP

@ghost ghost self-requested a review January 11, 2021 18:53
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Testing has confirmed that in some cases (speedtrees for example) tangent space is not orthogonal at the vertices, so the vertex templates need to be updates as well

@ghost ghost self-requested a review January 13, 2021 18:55
@joshua-davis
Copy link
Contributor Author

Testing has confirmed that in some cases (speedtrees for example) tangent space is not orthogonal at the vertices, so the vertex templates need to be updates as well

Updated

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Before and after fix to vertex templates (using the following shadergraph, which offsets position if the tangent space view dir code isn't fixed)
image
Before:
image
After
image

That should be everything.

Copy link

Choose a reason for hiding this comment

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

"Tanget" should be "Tangent"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nice catch. Fixed

@ghost ghost self-requested a review January 14, 2021 21:35
@joshua-davis joshua-davis marked this pull request as ready for review January 14, 2021 21:55
@joshua-davis joshua-davis requested a review from a team as a code owner January 14, 2021 21:55
@joshua-davis joshua-davis requested a review from a team January 14, 2021 21:55
@github-actions github-actions bot added the HDRP label Jan 14, 2021
Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

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

Typo fixed, reapproving

@joshua-davis joshua-davis requested a review from a team January 15, 2021 15:31
@ghost ghost removed their request for review January 15, 2021 20:32
@joshua-davis
Copy link
Contributor Author

Failures on HDRP match current state of master

@joshua-davis joshua-davis merged commit f529195 into master Feb 4, 2021
@joshua-davis joshua-davis deleted the SG/bugfix-1296788 branch February 4, 2021 21:08
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.

3 participants