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/2022.3/staging #7969

Merged
merged 19 commits into from
Oct 9, 2023
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.

RobJessop and others added 19 commits September 26, 2023 11:31
Regular docs sync to main.
…ow preference

Jira: https://jira.unity3d.com/browse/UUM-26418

How to reproduce:
1. Open the user’s attached “ObjectSelectorTest.zip” project
2. Open “VFX.vfx” Visual Effects Graph
3. Press the select button of “Main Texture”
4. Observe the Search window

**Actual**
![](https://jira.unity3d.com/secure/attachment/679065/Actual.png)
**Expected**
![](https://jira.unity3d.com/secure/attachment/679066/Expected.png)
Expected result: Search Engine is classic
Actual result: Search Engine is advanced

Reproducible with: 13.1.1 (2022.1.0a16), 14.0.6 (2022.2.5f1), 15.0.4 (2023.1.0b2)
Not reproducible with: 10.10.1 (2020.3.44f1), 12.1.10 (2021.3.18f1), 13.1.0 (2022.1.0a15)

Reproduced on: macOS 12.4 (Intel)

Note: Search Engine is set in Preferences > Search > Search Engines > Object Selector
… VFXView

Jira: https://jira.unity3d.com/browse/UUM-28528

Steps to reproduce:
- Open the VFX "No Asset" window (menu `Window`->`Visual Effects`->`Visual Effect Graph`)
- If the blackboard is not opened, open an existing VFX (or create a new one) and open the blackboard, then close and reopen the "No Asset" window.
- Click on the [+] button in the blackboard
<img width="902" alt="Unity_BOeC0iinDa" src="https://media.github.cds.internal.unity3d.com/user/4003/files/60fd3daf-99c9-499a-a652-ebdface369e5">
=> An error is thrown in the console

The fix for this issue is to disable the [+] button for the "No Asset" window.
<img width="670" alt="Unity_leeT7chM2m" src="https://media.github.cds.internal.unity3d.com/user/4003/files/b9cd40fd-dcb7-4587-ad82-50d3cd5ae8b6">

### 🎁 Gift improvement
Looking at the screenshots above I noticed that the "Create new Visual Effect Graph" button was squashed when the window is too small. So I did a few changes to fix that. See the videos below.
**Before**
![Unity_GP4bVeUqzN](https://media.github.cds.internal.unity3d.com/user/4003/files/13642625-3f18-4942-a871-3014df0b589d)
**After**
![Unity_Y0k41vtIWt](https://media.github.cds.internal.unity3d.com/user/4003/files/1e5770cc-1916-480d-818d-1886e54af830)
…lighted border after click

Repo steps:

Open unity scene (HDRP)
Right click project window > Create > Visual Effects > Visual Effect Graph
Create a graph and name is anything 
Click the Question mark icon on the top left of the viewport
The documentation page should open, navigate back to the unity project and notice the button is still selected by indication of the blue light
Expected result: No selection left on button

Actual result: Blue selection indicator on button

Reproducible with: 2022.2.13f1, 2023.1.0b15, 2023.2.0a14
Cannot test with: 2020.3.46f1, 2021.3.21f1 (Due to functionality not existing) 

Platforms tested: Win 11
![screenshot](https://jira.unity3d.com/secure/attachment/875249/UI%20Questionmark%20bug%20.png)
This PR is a backoprt of: https://github.cds.internal.unity3d.com/unity/unity/pull/26221 (see trunk PR for a more detailed description of changes)

The backport was created using the following steps (in the specified order):
1. Updating the state of FullScreenPassRendererFeature.cs to match what is looked like on trunk before the trunk PR being backported (difference were some minor changes that had not been backported)
2. Cherry picked all non-testing code changes
3. Removed the rendergraph path and use of the unavailable RasterCommanBuffer API
4. Cherry-picked and also manually added the test changes
5. Added new base reference images for the 4 added tests
6. Ran Yamato to retrieve and the remaining/more accurate platform ref images and updated the test thresholds
Fixed [UUM-3984](https://jira.unity3d.com/browse/UUM-3984) @soufiane-khiat:
Graphics: Lens Flare does not perform Occlusion with a certain Occlusion Offset value when the Camera is facing Light
JIRA ticket: https://jira.unity3d.com/browse/UUM-49158

- I was able to reproduce the issue on Windows, `2022.3` (latest) only. It already works well on 2023 (all versions).
- It's working in 2023 due to this PR: https://github.cds.internal.unity3d.com/unity/unity/pull/17689
- This PR is backporting the previous fix (partially, since Rendering Layer's tech has not been backported in 2022) from the previous PR to 2022.3.X

Here's a screenshot of the scene working after the fix:
![image](https://media.github.cds.internal.unity3d.com/user/1911/files/d05f0eca-6879-4a66-89af-80631a7faa9a)
Bump SRP packages to 14.0.9
Fix rendering issue with WebGL on Apple M1/2 processors (Macbook, iPhone) when URP Depth Priming is enabled.

Because Depth Priming is questionable on WebGL, due to that WebGL builds can run on both desktop and mobile, it seems reasonable to just disable depth priming all together for WebGL.
This PR aims to optimize the BatchRendererGroup shader variant code, especially for low-end platforms such as Android. Specifically, I've been running with Quest 2 on my side. The PR mainly adds two optimizations. 

### Caching instanced property loads
This one attempts to fix the shader code-gen by caching some property loads. With BRG shader variants, we override material properties such as `_BaseColor` like this:
`#define _BaseColor  UNITY_ACCESS_DOTS_INSTANCED_PROP_WITH_DEFAULT(float4, _BaseColor)`

This macro is expanded to a function which is going to branch and either load the property directly from the material cbuffer, or run some ALU operations to compute a buffer address based on the current instanceID + property metadata. It then loads the property from this buffer. 

This computation is not free, and it seems that using for example `_BaseColor` multiple times in the shader will results in this function being run multiple times. It looks like the compiler is unable to optimize this case by itself. 

This PR tries to fix the problem by calling this function only once per property (if ever used) at the beginning of the shader, and then store the result in a static value. The macro is then defined directly as `#define _BaseColor MyStaticValue` so that there is no risk for the loading computation to be regenerated. 

This optimization improved GPU time by ~10% on Quest 2 with the URPLitProperties scene. FPS counter also went from 50 to 55 with this setup.

### Static branch for instanced property loads
The second optimization is about turning the dynamic branch in the instanced property loading code to a static branch when possible. Loading a property such as the `_BaseColor` can be done either from the material cbuffer, or from the big raw buffer. Selecting from where the data must be loaded is done dynamically by checking the metadata high-bit in the shader. 

The cost of this branch has been negligible on high/mid-end platforms, but for low-end platforms it has a pretty big impact. The thing is that not all properties usually need to be instanced in the game. You might want to instantiate the `_BaseColor` but not the `_Smoothness` for example. It depends entirely on the game and this is something users need to be able to control so that they don't pay the cost of the expensive dynamic branch for a feature they do not use. 

Ideally we would have a nice UI for this, but multiple discussions suggest that there is a lot of technical problem with that. So the goal here is to provide some simple utilities allowing users to control which properties they want to instantiate by modifying the shader themselves. It's not ideal UX wise, but at least it's something we can do now. 

This PR introduces 4 new macros:
- `UNITY_DOTS_INSTANCED_PROP_OVERRIDE_DISABLED`
- `UNITY_DOTS_INSTANCED_PROP_OVERRIDE_ENABLED`
- `UNITY_DOTS_INSTANCED_PROP_OVERRIDE_REQUIRED`
- `UNITY_DOTS_INSTANCED_PROP_OVERRIDE_DISABLED_BY_DEFAULT`

The three first ones allow you to specify in the metadata cbuffer definition which properties can or must be overridden per instance. The last one is a config define that allows you to change how the default `UNITY_DOTS_INSTANCED_PROP` macro behaves. So for example we could imagine a cbuffer definition like this one:
```
UNITY_DOTS_INSTANCING_START(MaterialPropertyMetadata)
    UNITY_DOTS_INSTANCED_PROP_OVERRIDE_ENABLED(float4, _BaseColor)
    UNITY_DOTS_INSTANCED_PROP_OVERRIDE_DISABLED(float4, _SpecColor)
    UNITY_DOTS_INSTANCED_PROP_OVERRIDE_REQUIRED(float4, _EmissionColor)
    UNITY_DOTS_INSTANCED_PROP(float , _Cutoff)
UNITY_DOTS_INSTANCING_END(MaterialPropertyMetadata)
```
Here is what this declaration means:
- The `_BaseColor` property can be either instanced or not. A dynamic branch will be emitted so that the shader is able to fetch the data from the material cbuffer or the `unity_DOTSInstanceData` buffer depending on the metadata high-bit value.
- The ` _SpecColor` property is not instantiable. The property will always be loaded from the material cbuffer, and no dynamic branch is emitted in the code.
- The `_EmissionColor` property **must** be instanced. The property will always be loaded from the `unity_DOTSInstanceData` buffer, and no dynamic branch is emitted in the code.
- The `_Cutoff` property can be instantiable or not depending on the config define. 
If `UNITY_DOTS_INSTANCED_PROP_OVERRIDE_DISABLED_BY_DEFAULT` is defined, then `_Cutoff` is not instantiable will behave just like  `_SpecColor` in this example. 
If `UNITY_DOTS_INSTANCED_PROP_OVERRIDE_DISABLED_BY_DEFAULT` is **not** defined, then `_Cutoff` is instantiable and will behave just like `_BaseColor` in this example.

Disabling instancing for every material property improved the GPU time by ~20 to 40% on Quest 2 with the URPLitProperties scene. So this is likely something you want to keep disabled for the majority of the material properties on low-end platforms considering the performance impact it has.
This PR fixes transparent materials never disappearing from the "Save Assets" window popup even after clicking "Save All"

Details:
*The keyword state for `_ALPHAPREMULTIPLY_ON` was being disabled and then enabled again, this was causing the material to get marked as dirty
*For this reason now we make sure to only call `SetKeyword` once at the end instead of calling `DisableKeyword` and `EnableKeyword` for transparent materials (the material should not get marked as dirty if the state doesn't changed from what it was set to before)
This PR backports the HDR Output tests in the URP Post Pro project, complete with the improvements that landed later.

373_HDROutput_ColorGamut renders 4 colourful cubes (red, blue, green for the primaries + yellow) so it exercises the enabling of HDR output. The scene is used in a math test (HDRColorGamutTests) that read pixels and verifies the colorspace conversion/encoding has been applied properly.
374_HDROutput_PassOrder renders 4 cameras with overlay UI, each with a different pass execution order (FinalBlit, UberPost, UberPost+FinalPost, UberPost+FinalBlit) to ensure there's no breakage in executing HDR output-specific code path.

Note the reference images look washed out/a bit too bright. That's intended since the swapchain is still SDR when the HDR faking mode is active.
…ip temporal upscalers and TAA

Adding new checkbox to allow materials to be excluded from temporal anti aliasing.
For now, this checkbox is only exposed to transparent materials since they are the only ones that can fit a stencil bit for such operation.

The materials that go through this path will generate a special mask (stencil or a bit mask in DLSS) that just performs spatial upscaling.

This checkbox is ideal for surfaces that contain texture scrolling that has to be neat and does not have velocity information.

Comparison (left is flag off, right is flag on, notice the scrolling is more clear and less blury than the one in the right):
![bluryTextureScroll](https://media.github.cds.internal.unity3d.com/user/3327/files/e1f0a283-e471-4f91-a015-f874da0915db)

![image](https://media.github.cds.internal.unity3d.com/user/3327/files/76046247-c229-4e9d-abda-dba342fdfc23)
Bug: https://unity3d.atlassian.net/servicedesk/customer/portal/2/IN-19568
Ticket: https://unity3d.zendesk.com/agent/tickets/1375225
Slack: https://unity.slack.com/archives/C3KQ4UD6V/p1667483309051999
Jira: https://jira.unity3d.com/browse/UUM-52220

Added a view bypass in core undo/redo behavior that prevents view from over-updating. Also, aggressively cache view-model relationships to speedup view updates.
…put docs

This PR simply adds one line about the projection axis of the decals.
@UnityAljosha UnityAljosha requested review from a team as code owners October 9, 2023 13:27
@UnityAljosha UnityAljosha merged commit ae9e4b7 into 2022.3/staging Oct 9, 2023
3 checks passed
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

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.