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/master #8063

Merged
merged 17 commits into from
Apr 15, 2024
Merged

Internal/master #8063

merged 17 commits into from
Apr 15, 2024

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.

amsXYZ and others added 17 commits April 10, 2024 22:25
This PR aims to fix Shaded-Wireframe rendering mode in URP when using RenderGraph, by introducing a "WireOverlay" `RasterRenderPass` that re-renders the scene for scene-view cameras if the mode is enabled. Since RenderGraph is now enabled by default, this was impacting the majority of our URP users using the latest betas.

Jira: https://jira.unity3d.com/browse/UUM-67686
- Remove the VR and XR modules, and therefore defines, from the SRP smoke tests. This allows catching compilation errors faster, in the `PR` pipelines instead of in the QV (so far only the (QV) OnDemandImport project was testing the path where these 2 modules are not used). More context in that [thread](https://unity.slack.com/archives/C20E70CAC/p1702559984581049?thread_ts=1702552104.332429&cid=C20E70CAC).
- This change prompted me to remove all other non SRP related packages/modules from the manifest. The goal with SRP Smoke tests is really just to make sure all packages compile, and having too much bloat even potentially hides unnecessary dependencies as this is not what an end user would have locally. The 2 graphics tests were removed as they needed the graphics test framework package, which depended on the VR and XR modules.

- Add the SRP smoke tests project to `PR URP`.
Adds documentation for some of the helper methods in the URP shader library (and some methods from Core SRP shader library files that URP includes)

To avoid this documentation task getting too large, I've focused on methods from:

- Core.hlsl
- Lighting.hlsl
- Shadows.hlsl
- ShaderVariablesFunction.hlsl
- SpaceTransforms.hlsl (from SRP Core)

I've aimed to cover methods/needs that are mentioned in our existing BiRP basic shaders documentation, so that users no longer accidentally find and use BiRP methods that don't work in URP.

Preview site: https://docs-internal-preview.prd.it.unity3d.com/markg/urp-shader-methods/manual/use-built-in-shader-methods.html (needs VPN)

Jira ticket: https://jira.unity3d.com/browse/DOCG-1019
JIRA: [UUM-69513](https://jira.unity3d.com/browse/UUM-69513)

Immediate Mode is a rendergraph debug mode that is only supported by non-NRP RG in HDRP
While we decide if we want to implement it for URP, it should be removed in URP so that users do not encounter issues with it.
… ONLY - DO NOT FORWARD PORT)

Applied the changes to the UI to make the "enter play mode" settings clearer and more user friendly.
https://jira.unity3d.com/browse/UUM-60957

![Mar-28-2024 16-36-51](https://media.github.cds.internal.unity3d.com/user/2126/files/befdad22-09df-4bb2-9e47-c1a9f9be9217)
https://jira.unity3d.com/browse/UUM-68021

`Type.name` was used which accidentally instantiate HDRP Volume component of the same name. As both of them are Scriptable Object it was produced an exception when use it and not when it instantiates.
…xceptions

Fix [UUM-66021](https://jira.unity3d.com/browse/UUM-66021)
Fixed IndexOutOfRange errors in the decal system when using multiple cameras. This was caused by the static variable `m_DecalsVisibleThisFrame` being updated during culling, so the number of decals visible were only considered for the last camera the decal culling ran on.
Fix wrong error feedback with relative path, add a missing check using base path.
Issue technically introduced at https://github.cds.internal.unity3d.com/unity/unity/commit/de946b09b4e9e9f3e06853c8f5465f5403f5ec96 but this isn't a regression since it's a new error feedback.
Currently in Unity 6, asmref files are sometimes used to bypass assembly visibility rules. In the future, asmref is no longer allowed so the current usage must be removed (see [RFC](https://docs.google.com/document/d/1SWAG19Ns5gnmbVl4WD-HT0f4DO2UVdiRj_YhX1o7J7E/edit#heading=h.9tfgs0fpr1tb)). 

This PR solves the sub-task [Remove asmref usage in main SRP package code](https://jira.unity3d.com/browse/XPIPELINE-917), part of the broader task [XPIPELINE-904](https://jira.unity3d.com/browse/XPIPELINE-904) to completely remove asmref usage from SRP code.

Asmref usage in this PR originated from the need to access the internal "rawRenderQueue" property inside Material class. This PR just makes that property public API. Similar code was also found in ShaderGraph and fixed the same way.
Currently in Unity 6, asmref files are sometimes used to bypass assembly visibility rules. In the future, asmref is no longer allowed so the current usage must be removed (see [RFC](https://docs.google.com/document/d/1SWAG19Ns5gnmbVl4WD-HT0f4DO2UVdiRj_YhX1o7J7E/edit#heading=h.9tfgs0fpr1tb)).

This PR solves the sub-task [Remove asmref usage in SRP samples](https://jira.unity3d.com/browse/XPIPELINE-918), part of the broader task [XPIPELINE-904](https://jira.unity3d.com/browse/XPIPELINE-904) to completely remove asmref usage from SRP code.

Asmref usage in this PR originated from the need to access HDRenderPipelineUI types, in order to display configuration UI to edit which settings an individual sample needs to be enabled.

The asmref files are now removed, and instead the `HighDefition.Editor` assembly does a single `[assembly: InternalsVisibleTo("Unity.RenderPipelines.HighDefinition.Samples.Common.Editor")]` call to allow the editor code of HDRP Sample to access HDRP Editor internal types.

In addition, asmdef files inside Core/HDRP Samples have been restrucuted and renamed to be more consistent with SRP naming conventions. The asmdef files are either "Runtime" or "Editor" assemblies, and the "Runtime" assemblies are not allowed to reference "Editor" assemblies. The new structure is displayed below:
![image](https://media.github.cds.internal.unity3d.com/user/3380/files/a59ed94f-d7de-438d-b465-38490d01059b)

Finally, I took an opportunity to replace some reflection code in the samples with a simpler callback.

This PR is a follow-up to earlier PR https://github.cds.internal.unity3d.com/unity/unity/pull/47596.
Fix shader warnings in URP 2D template
Currently in Unity 6, asmref files are sometimes used to bypass assembly visibility rules. In the future, asmref is no longer allowed so the current usage must be removed (see [RFC](https://docs.google.com/document/d/1SWAG19Ns5gnmbVl4WD-HT0f4DO2UVdiRj_YhX1o7J7E/edit#heading=h.9tfgs0fpr1tb)).

This PR solves the sub-task [Remove asmref usage in SRP tests](https://jira.unity3d.com/browse/XPIPELINE-919), part of the broader task [XPIPELINE-904](https://jira.unity3d.com/browse/XPIPELINE-904) to completely remove asmref usage from SRP code.

SRP tests used asmrefs in 3 places:

1) **HDRP_RuntimeTests project** where the test `012-SVL_Check` contains script `SVLChecker.cs` which needs access to `GenerateShaderVariantList` inside the `com.unity.testframework.graphics` package. However since that type is public, there is no need to inject this script into that assembly. We simply add an asmdef file which contains a reference to the `UnityEngine.TestTools.Graphics` assembly.

2) **VisualEffectGraph_HDRP project** contains an editor-only `TemplateEditor.cs` script which used asmref to inject itself into `Unity.VisualEffectGraph.Editor` assembly. This is unnecessary that assembly is already accessible, we can just wrap the code in `#if UNITY_EDITOR` instead.

3) **UniversalGraphicsTest_2D project** contains an editor-only `AdditionalMenuItems.cs` script which used asmref to inject itself into `UnityEditor.TestTools.Graphics` assembly from `com.unity.testframework.graphics` package. This was also unnecessary, just wrapping the code in `#if UNITY_EDITOR` is enough.


This PR is a follow-up to earlier PRs https://github.cds.internal.unity3d.com/unity/unity/pull/47596 and https://github.cds.internal.unity3d.com/unity/unity/pull/47609.
Post-processing alpha handling and output when the render target has an alpha channel and post-process alpha processing is enabled from the asset. The feature is opt-in.

URP alpha output semantics are similar to HDRP.

Enabled by toggling post-process alpha-processing from URPAsset->Post-Processing->Alpha Processing.
![image](https://media.github.cds.internal.unity3d.com/user/2125/files/243baf93-35d6-4d34-959a-c9af140cd841)
Alpha output is disabled by default to avoid regressions in existing projects.
If disabled, the alpha output shaders are stripped.

Alpha output warns if enabled, but the back-buffer format does not support alpha.
![image](https://media.github.cds.internal.unity3d.com/user/2125/files/ff56b253-13d6-433a-ad6f-b9c6f061f737)

Alpha output requires selecting a back-buffer format with alpha from URPAsset->Quality->HDR/HDR Precision.
![image](https://media.github.cds.internal.unity3d.com/user/2125/files/1bb561fb-1947-4a10-9725-d2dbb77c7da0)

| Setting       | Format.     |Alpha Output|
|------------|-----------|-------------|
| SDR 32-bit | RGBA8     | Yes               |
| HDR 32-bit | RGB11f     | No                |
| HDR 64-bit | RGBA16f  | Yes               |

[**URP-1586**](https://jira.unity3d.com/browse/URP-1586)
[**POI-1037**](https://jira.unity3d.com/browse/POI-1037)
Significantly improves the API in the Graphics Test Framework package and the Internal Editor API for capturing arbitrary Editor Windows.

- Adds new API to the Internal Editor Utility class to take snapshots of arbitrary windows instead of just SceneView windows
- Makes the older SceneView API obsolete
- Adds new API to the Graphics Test Framework to write the snapshot to a Texture2D for full compatibility with the current testing paradigm
- Refactors functionality for using this API on a SceneView window, leaving space for any other "special steps" done inside or outside the framework.
- Significantly improves the API usability and testability by moving away from IEnumerator setup and to an async setup instead.
- Updates the documentation around this functionality.

### Example captures

#### Scene view with no modifications

![SceneViewWindow_ImageIsNotNullOrEmpty](https://media.github.cds.internal.unity3d.com/user/2181/files/a5d944b3-021a-481e-b720-3708bae71e5a)

#### Scene view with all overlays disabled

![SceneViewWindow_ImageIsNotNullOrEmpty](https://media.github.cds.internal.unity3d.com/user/2181/files/7c79a8aa-10c9-4a5b-b281-491d0a3725be)

#### Scene view with most disabled + Debug Draw Mode

![SceneViewWindow_WithDebugDrawMode_ImageMatchesReference_BakedDirectionality_](https://media.github.cds.internal.unity3d.com/user/2181/files/27f23a76-ae59-4186-8257-898db5c34fa2)

#### Custom editor window

![CustomEditorWindowCaptureTest](https://media.github.cds.internal.unity3d.com/user/2181/files/067d9764-35ee-4d2d-a8ab-29637722db7d)
@UnityAljosha UnityAljosha requested review from a team as code owners April 15, 2024 09:33
@UnityAljosha UnityAljosha merged commit 438e586 into master Apr 15, 2024
2 of 3 checks passed
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.