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

Internal/2021.3/staging #8061

Merged
merged 6 commits into from
Apr 11, 2024
Merged

Conversation

UnityAljosha
Copy link
Collaborator

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

Why is this PR needed, what hard problem is it solving/fixing?


Testing status

Describe what manual/automated tests were performed for this PR


Comments to reviewers

Notes for the reviewers you have assigned.

lpledouxUnity and others added 6 commits March 28, 2024 11:17
Fix for a distorted viewport when using no intermediate texture in XR rendering. When activating dynamic resolution and using a scale of < 1, the image becomes distorted. This fixes this issue.
…rmal packing functions.

Fixes https://jira.unity3d.com/browse/UUM-62216, in which artifacts appear (looks like uninitialized memory) when using the accurate G-buffer normals feature when targeting mobile. This feature uses a pair for function for performing octrahedral encoding and decoding of normals.

The function misbehaves when targeting mobile, but not desktop. The main difference between mobile and desktop in shadercode is that desktop treats `half` as float, whereas on mobile `half` actually works. The functions for octahedral encoding take `float`'s as input, and are given `half`'s in the mobile path. In the function, we use `abs()` on the input and then negate it. This combination seems to cause a miscompilation of some sort, presumably because `abs` and negation are both input modifiers rather than real instructions - I'm not entirely sure, but it's some mix of those 3 things - half to float conversion, abs and negation.

The most minimal fix that worked was this:
```
float3 UnpackNormalOctQuadEncode(float2 f)
{
-   float3 n = float3(f.x, f.y, 1.0 - abs(f.x) - abs(f.y));
+   float3 n = float3(f.x, f.y, 1.0 - abs(real(f.x)) - abs(real(f.y)));
```
But I instead decided to change the functions to use `real` instead of `float` throughout, as it it seemed cleaner. `real` is just an alias for `half` on mobile and `float` on desktop.
Backport.
Make sure that shaders are reloaded after all shader import cases. This ensures that UsePass will always have up to date state and is not pointing to old data, which can cause rendering issues and even crashes.
- Bumped SRP packages from 12.1.14 to 12.1.15.
Backport to fix some of our shaderlab code gen so that it made half precision explicit in all circumstances, this makes it compile correctly for mobile devices.
@UnityAljosha UnityAljosha requested review from a team as code owners April 11, 2024 06:49
@UnityAljosha UnityAljosha merged commit 8a0673f into 2021.3/staging Apr 11, 2024
4 checks passed
Copy link

It appears that you made a non-draft PR!
Please convert your PR to draft (button on the right side of the page).
See the PR template for more information.
Thank you!

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

Successfully merging this pull request may close these issues.

5 participants