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 #8123

Merged
merged 30 commits into from
Jan 22, 2025
Merged

Internal/2022.3/staging #8123

merged 30 commits into from
Jan 22, 2025

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.

…ution.

Jira : [UUM-83862](https://jira.unity3d.com/browse/UUM-83862)

The 'resolution' field of the Reflection Probe is an integer, but it is displayed as an enum value (256, 512, etc.). When comparing two resolution values, they should be treated as integers, but they were being treated as enum values.
…ullscreen Master Stack pages.

Added a reference to the custom renderer feature page.
Added a reference to custom-post-processing.md on the customizing-urp.md page.
Implemented the same structure as in the 6000 version.
Copied Fullscreen Master Stack pages, the feature is implemented in 2022.3 and was not documented in URP.
Converted the formatting from the main manual to URP.
Part 7 of minor fixes from feedback tickets 

Jira tickets:

- https://jira.unity3d.com/browse/DOCG-5586 - remove incorrect multidisplay info (already removed in U6 docs)
- https://jira.unity3d.com/browse/DOCG-4812 - add experimental to VFX blocks (already done in U6 docs)
Fix anchor link to light limit in 2022.3 docs

Jira ticket: https://jira.unity3d.com/browse/DOCG-5291
…re node in Shade…

UUM-90053: Prevent shader warnings when using  the NormalFromTexture node in ShaderGraph
…sk not blending

UUM-78038

There were issues where blending would occur further than the maximum distance for cascade shadows and could be broken depending on the camera view.

The alpha value of EvalShadow_GetSplitIndex is intended for blending between cascades. This is also used where the last cascade and shadowmask are blended, which is why the blending is not working properly.

Modified to blend cascade shadows and shadowmask in the same way as URP.

The images below compare the modified HDRP and URP.

* Blending of cascade shadows and shadowmask.
![image](https://media.github.cds.internal.unity3d.com/user/1641/files/fb63bbbc-c8fc-410d-ae0f-8dfffa22bcbd)

* To visualize the blending, cascade shadows are represented as 0 (black area) and shadowmask as 0.5 (gray area). Blending occurs at the maximum distance of cascade shadows.
![image](https://media.github.cds.internal.unity3d.com/user/1641/files/657f732a-934d-4362-b051-5f8f8ce8785b)

Comparison of original HDRP and modified HDRP as the camera distance increases. You can see that the blending works properly regardless of the distance.

* Original
![image](https://media.github.cds.internal.unity3d.com/user/1641/files/11e28622-fcc4-468e-be0d-b74f4014cd99)

* Modified
![image](https://media.github.cds.internal.unity3d.com/user/1641/files/98b11973-7485-452c-975f-e39034f7721e)
Jira: [UUM-72279](https://jira.unity3d.com/browse/UUM-72279)

As reported in JIRA, the Scene view flickers due to `NaN` output from the hair shader. It is because in `GetHairAngleWorld`, `angles.sinThetaI` can exceed the range [-1, 1] depending on the input hair `normalWS`. (The `L` vector may not be a unit vector in some cases.)
* `half3x3 localToWorld = GetLocalFrame(bsdfData.normalWS, bsdfData.hairStrandDirectionWS);`
* `half3 L = mul(localL, localToWorld);`

I was able to see that this `NaN` problem could happen if both `T` and `L` vectors are a unit vector due to precision. `angles.sinThetaI` can slightly exceed 1.0 so the `FastASin` result will be `NaN` in this case.

![image](https://media.github.cds.internal.unity3d.com/user/3842/files/f49cd338-9620-4d69-84e3-c9248bfb8a87)

By explicitly clamping the angles, we can prevent `NaN` output from `FastASin` calculation.
…ormWorldToShadowCoord

Jira: [UUM-73947](https://jira.unity3d.com/browse/UUM-73947)

This PR adds ScreenSpace Shadow coord transform to fix incorrect SS shadow sampling from some shaders, especially for ShaderGraph shaders. URP shaders support a correct SS shadow sampling by directly using `inputData.shadowCoord` which has a cascaded position or a screen position depending on `_MAIN_LIGHT_SHADOWS_SCREEN`. However, since we cannot use vertex output in ShaderGraph, it may be difficult to calculate a correct shadow coord using only `TransformWorldToShadowCoord` unless the user manually adds `_MAIN_LIGHT_SHADOWS_SCREEN` check if SS Shadow is enabled. 


| Before | After |
| -- | -- |
|![Before](https://media.github.cds.internal.unity3d.com/user/3842/files/abd5c548-74af-4fe0-82fc-2e3590f74758)|![After](https://media.github.cds.internal.unity3d.com/user/3842/files/5c80bc48-fcd8-41cb-9cb6-2402d4aa5146)|
Fix Graphics Corruption on Silicon Device which can generates artifact in every single Unity rendering.

![image](https://media.github.cds.internal.unity3d.com/user/42/files/3d4b4fcb-aa19-48c7-bfdb-910439677f6f)

The problem was due to an unexpected call from `Graphics.DrawMeshNow` while *not* being within a Repaint event (see also this [OnSceneGUI documentation](https://docs.unity3d.com/ScriptReference/Editor.OnSceneGUI.html))

- Issue with while rendering mesh in wireframe with mesh module in ParticleSystem, initial repro 🔽 

https://media.github.cds.internal.unity3d.com/user/42/files/45a4c51e-b236-4c3a-907a-5610c5e7b55b

- Found a repro of the wrong DrawHull in HDRP (this is a theoretical repro, I tested on windows) 🔽 

https://media.github.cds.internal.unity3d.com/user/42/files/9057b6d4-c8b4-481e-9421-783e16cbbb6f

- Checked other usage of DrawMeshNow in VFX
   - With DrawCurve  ✅ 
![image](https://media.github.cds.internal.unity3d.com/user/42/files/e739a750-9615-463b-81c2-7fa40a96396c)
   - With Draw Context Border ✅ 
![image](https://media.github.cds.internal.unity3d.com/user/42/files/503aca84-4e6f-4c28-bc8d-b08ec66899ff)
   - With Gizmo rendering `Graphics.DrawMeshNow`, we can trust the `EventType.Repaint`
   
https://github.cds.internal.unity3d.com/unity/unity/blob/eaea05a25d195f7c6e58128434cc9a5130ef3b91/Packages/com.unity.visualeffectgraph/Editor/Gizmo/VFXGizmo.cs#L88
… prefix.

Our resolution for name conflicts couldn't handle biasing for conflicts where an underscore was already present. Under some circumstances it could allow identifiers to conflict with unity macros (such as `_Weight`) or result in double underscore (such as `__Weight`); the double underscore is reserved in some environments and therefore invalid for userspace.
…used and fix renderer features

Fix UUM-86922 UUM-83351
…ta.OnDestroy

Fix error in Dedicated Server [UUM-75237](https://jira.unity3d.com/browse/UUM-75237)
What happened is that when destroying a UniversalCameraAdditionalData, in order to clear the buffer, the code was actually constructing the URP pipeline in case the pipeline was null.

Fix do the same without trying to construct the pipeline if it is not constructed (aka multiple pipeline scenario or headless server).
This is an almost automated backport based on https://github.cds.internal.unity3d.com/unity/unity/pull/55248 for branch 2022.3/staging requested by [[email protected]](mailto:[email protected]). This backport was created by [Backport Automation](https://backports.ds.unity3d.com/). Make sure that changes are correct!
Forward port of https://github.cds.internal.unity3d.com/unity/unity/pull/56678
I didn't use the automatic tool because 100_Fog generated a conflict.
…ith a clear coat value of 0

Jira : [UUM-84980](https://jira.unity3d.com/browse/UUM-84980)

**Short Description:** 

When 'Clear Coat'(Surface Option) is activated in the Shader Graph, _MATERIAL_FEATURE_CLEAR_COAT is enabled regardless of the actual Clear Coat value. In this case, if the coatMask value is 0 in the EvaluateBSDF_ScreenSpaceReflection() of Lit.hlsl, there is an issue with specular calculation (no problems arise with small values such as 0.001 or 0.00001).

Therefore, I resolve this issue by handling the Clear Coat calculation even when the value is 0.

**Long Description:**

- When 'Clear Coat'(Surface Option) is activated and the clearCoat value is 0 in the shader graph, the ssrLighting value in EvaluateBSDF_ScreenSpaceReflection() is not zero.

- For HDRP/Lit with a 'clear coat' value of 0, the ssrLighting value is 0, 0, 0, 0. (Therefore, no issue occurs)

- In the 'Render SSR' pass, during the 'ScreenSpaceReflectionsTracing' call, the rays are killed at the killRay step for HDRP/Lit, but they pass through in the shader graph.

- This issue arises due to different normalData.perceptualRoughness values, which are computed in the ForwardDepthPrepass.

- During the ForwardDepthPrepass when calculating normalData for each Object, the value changes depending on whether the _MATERIAL_FEATURE_CLEAR_COAT keyword is enabled.

- For HDRP/Lit, in LitGUI.cs, the _MATERIAL_FEATURE_CLEAR_COAT is disabled when the clear coat value is 0, but in the shader graph, the keyword is enabled based on the 'Clear Coat'(Surface Option) regardless of the actual Clear Coat value.

- Due to the nature of the shader graph, accessing the 'Clear Coat' value of the Fragment Node directly is difficult, and the variable name connected to the Clear Coat value can be set differently for each user, making it challenging to check if the Clear Coat value is 0 in ShaderGraphAPI.cs. (See the code below for reference)
```
float _Property_622a98e8ad5742088e5c548ea3797750_Out_0_Float = _Coat;
surface.CoatMask = _Property_622a98e8ad5742088e5c548ea3797750_Out_0_Float;
```

- Therefore, I modified EvaluateBSDF_ScreenSpaceReflection() in Lit.hlsl.
…ng into the material preview inspector

Fixes: [UUM-84064](https://jira.unity3d.com/browse/UUM-84064), by binding an empty spherical harmonics buffer when a preview camera is detected.
**This is a partial backport based on https://github.cds.internal.unity3d.com/unity/unity/pull/58698 for branch 6000.0/staging**

Minor fixes from graphics docs feedback tickets.

Jira tickets:

- https://jira.unity3d.com/browse/DOCG-6327 - fix link to DOTS instancing docs
- https://jira.unity3d.com/browse/DOCG-6328 - remove link to missing sample
- https://jira.unity3d.com/browse/DOCG-6294 - remove note from min and max
- https://jira.unity3d.com/browse/DOCG-6289 - remove incorrect use of 'naming conventions'
- https://jira.unity3d.com/browse/DOCG-5082 - add link to RenderingLayerMask API
- https://jira.unity3d.com/browse/DOCG-5803 - add link to depth texture information
…can prevent opening a VFX

How to reproduce:
1. Open the attached “IN-82864” project
2. In the Assets folder open the “EnemyDeath” VFX Graph file
3. Observe the Console log and the Windows prompt

Expected result: VFX Graph window opens as intended without any errors
Actual result: VFX Graph window doesn’t open, a Windows prompt “Select an app to open this .vfx file” appears and an error is logged into the console

Reproducible in: 2022.3.38f1, 6000.0.22f1

Reproducible on: Windows 11
Not reproducible on: No other environments tested

Note: Not reproduced internally by CQA

![](https://jira.unity3d.com/secure/attachment/1568365/image_2024-10-11_214015432.png)
[Provided file](https://jira.unity3d.com/secure/attachment/1568363/EnemyDeath.vfx)
**This is a backport of https://github.cds.internal.unity3d.com/unity/unity/pull/59034**

Minor docs fixes for January 2025, from user feedback.

Jira tickets:

- https://jira.unity3d.com/browse/DOCG-5765 - clarify underwater settings in HDRP
… when the original resolution is odd

Fixed black border artifact when using DLSS at certain resolution. The issue is that DRS causes the camera to have odd resolutions which the downsampled SSAO algorithm didn't handled well.
…ariants when "Strip Unused Variants" is disabled (UUM-91646)

This PR does the following:
- Fixes UUM-91646
- Makes sure that when "strip unused variants" is disabled, every keyword URP strips out or prefilters is included
- Adds editor tests for this and removes some redundant ones
Minor docs fixes for January 2025, from user feedback. Part 2.

Jira tickets:

- https://jira.unity3d.com/browse/DOCG-6479 - move experimental warnings to below h1s
- https://jira.unity3d.com/browse/DOCG-6481 - add a link to RenderDoc from shader debugging landing page
This change backports the FSR banding fixes from #49299 to 2022.3.
… is disabled

This PR fixes HDRP sky rendering when Camera Relative Rendering is disabled.

`ComputePixelCoordToWorldSpaceViewDirectionMatrix()` in `HDCamera.cs` contains:

```
...
if (useGenericMatrix)
{
    var viewSpaceRasterTransform = new Matrix4x4(
        new Vector4(2.0f * resolution.z, 0.0f, 0.0f, -1.0f),
        new Vector4(0.0f, -2.0f * resolution.w, 0.0f, 1.0f),
        new Vector4(0.0f, 0.0f, 1.0f, 0.0f),
        new Vector4(0.0f, 0.0f, 0.0f, 1.0f));

    var transformT = viewConstants.invViewProjMatrix.transpose * Matrix4x4.Scale(new Vector3(-1.0f, -1.0f, -1.0f));
    return viewSpaceRasterTransform * transformT;
}
...
```

Here the view matrix that was used to build `viewConstants.invViewProjMatrix` has translation component if Camera Relative Rendering is disabled when it shouldn't.

![scene_view](https://github.cds.internal.unity3d.com/unity/unity/assets/7006/95047d07-52f3-4d19-8698-0120ad86987f)
Scene View

![game_view_wrong](https://github.cds.internal.unity3d.com/unity/unity/assets/7006/2cb0b898-ddb2-4819-ae58-7900ce0c4221)
Game View, bugged

![game_view_fixed](https://github.cds.internal.unity3d.com/unity/unity/assets/7006/0a9b4699-9737-426f-a605-fd51a5ae72eb)
Game View, fixed
… docs

**This is a backport of https://github.cds.internal.unity3d.com/unity/unity/pull/59127**

Add steps to the 2D sprite lit shader graph URP docs, to clarify connecting up transparency/alpha, and setting the normal map input. Response to user feedback.

Jira tickets:

- https://jira.unity3d.com/browse/DOCG-6464
- https://jira.unity3d.com/browse/DOCG-6465
…a warning

This is to fix some warnings when using the multiplayer VR template and creating a build. Some shaders generated via shadergraph were doing an implicit truncation of values (specifically the 2 UV sets passed to the UnityMetaVertexPosition function). This has been fixed.

Jira: https://jira.unity3d.com/browse/UUM-84269
This is an **edited backport** of https://github.cds.internal.unity3d.com/unity/unity/pull/58119, which fixes some issues with the blitting documentation in URP.

Jira ticket: https://jira.unity3d.com/browse/DOCG-6268
@UnityAljosha UnityAljosha requested review from a team as code owners January 22, 2025 14:23
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!

@UnityAljosha UnityAljosha merged commit 32265cd into 2022.3/staging Jan 22, 2025
4 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.