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

Merged
merged 16 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
6275024
2022.3 DOCG-5651 Backport: Lighting Docs Overhaul
Richard-Horton May 17, 2024
e91e500
[22.3] Fix Profilers.EndSample error with custom render passes callin…
vincent-breysse May 18, 2024
fa45c83
2022.3 URP DOCG-5659: Backport URP Config Package Docs
Richard-Horton May 20, 2024
94a095d
2022.3 Backport URP DOCG-5661: URP Docs Table Fixes
Richard-Horton May 20, 2024
13091e8
[Port][2022.3][URP] SingleCameraRequest : Add missing RenderPipelineM…
alex-vazquez-unity3d May 22, 2024
c6fdca2
2022.3 URP Docs: Fixes and Style Guide Change Backport
Richard-Horton May 23, 2024
2f9735b
[ShaderGraph][2022] BakedGINode initialization fix
May 23, 2024
dede534
2022.3 Docs: DOCG-5676 Backport
Richard-Horton May 24, 2024
d5ceff2
[content automatically redacted] touching PlatformDependent folder
svc-reach-platform-support May 29, 2024
b0516b4
Fix for incorrect way to check if xr is enabled
lpledouxUnity May 29, 2024
5be90fd
[Port] [2022.3] Make sure the RG events are not unsubscribed when com…
svc-reach-platform-support May 29, 2024
7ae5a55
[2022.3] Fixed Metal/PS5 Foveation API mismatch causing compilation e…
RogPodge May 30, 2024
e546cff
Shader Graph Sample - Production Ready Shaders backport
bencloward May 30, 2024
639332a
[Backport]Fix bug with non square cached atlas and remove redundant b…
acohade-U Jun 3, 2024
b4333e2
[2022.3 Backport] Bug Fix - [UUM-57147] - Disabling NRP for Editor Fi…
axoloto Jun 4, 2024
c55bd46
Fix Wireframe not rendering when using Vulkan API.
YohannVaastUnity Jun 5, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -706,11 +706,7 @@ void OnEnable()
foreach (var graph in registeredGraph)
m_RegisteredGraphs.Add(graph, new HashSet<string>());

RenderGraph.requireDebugData = true;
RenderGraph.onGraphRegistered += OnGraphRegistered;
RenderGraph.onGraphUnregistered += OnGraphUnregistered;
RenderGraph.onExecutionRegistered += OnExecutionRegistered;
RenderGraph.onExecutionUnregistered += OnExecutionUnregistered;
SubscribeToRenderGraphEvents();
}

private void CreateGUI()
Expand All @@ -720,10 +716,36 @@ private void CreateGUI()

void OnDisable()
{
UnsubscribeToRenderGraphEvents();
}

void SubscribeToRenderGraphEvents()
{
if (RenderGraph.requireDebugData)
return;

RenderGraph.requireDebugData = true;
RenderGraph.onGraphRegistered += OnGraphRegistered;
RenderGraph.onGraphUnregistered += OnGraphUnregistered;
RenderGraph.onExecutionRegistered += OnExecutionRegistered;
RenderGraph.onExecutionUnregistered += OnExecutionUnregistered;
}

void UnsubscribeToRenderGraphEvents()
{
if (!RenderGraph.requireDebugData)
return;

RenderGraph.requireDebugData = false;
RenderGraph.onGraphRegistered -= OnGraphRegistered;
RenderGraph.onGraphUnregistered -= OnGraphUnregistered;
RenderGraph.onExecutionRegistered -= OnExecutionRegistered;
RenderGraph.onExecutionUnregistered -= OnExecutionUnregistered;
}

void Update()
{
// UUM-70378: In case the OnDisable Unsubscribes to Render Graph events when coming back from a Maximized state
SubscribeToRenderGraphEvents();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,218 @@
#define UNITY_FOVEATED_RENDERING_INCLUDED

#if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS) || defined(UNITY_PLATFORM_VISIONOS))) || defined(SHADER_API_PS5)

#if defined(SHADER_API_PS5) || defined(SHADER_API_METAL)

#define SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER 1
#endif
#endif

#if defined(SHADER_API_PS5)
#include "Packages/com.unity.render-pipelines.ps5/ShaderLibrary/API/FoveatedRendering_PSSL.hlsl"
#endif
#if SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER
#if defined(SHADER_API_PS5)
#include "Packages/com.unity.render-pipelines.ps5/ShaderLibrary/API/FoveatedRendering_PSSL.hlsl"
#endif

#if defined(SHADER_API_METAL)
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/API/FoveatedRendering_Metal.hlsl"
#endif
#if defined(SHADER_API_METAL)
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/API/FoveatedRendering_Metal.hlsl"
#endif

#endif
// coordinate remapping functions for foveated rendering
#define FOVEATED_FLIP_Y(uv) uv.y = 1.0f - uv.y
float2 FoveatedRemapLinearToNonUniform(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingLinearToNonUniform(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapPrevFrameLinearToNonUniform(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingPrevFrameLinearToNonUniform(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapDensity(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingDensity(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapPrevFrameDensity(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingPrevFrameDensity(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapNonUniformToLinear(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingNonUniformToLinear(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}

float2 FoveatedRemapPrevFrameNonUniformToLinear(float2 uv)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
{
FOVEATED_FLIP_Y(uv);
uv = RemapFoveatedRenderingPrevFrameNonUniformToLinear(uv);
FOVEATED_FLIP_Y(uv);
}
return uv;
}
#undef FOVEATED_FLIP_Y

int2 FoveatedRemapLinearToNonUniformCS(int2 positionCS)
{
return FoveatedRemapLinearToNonUniform((positionCS + float2(0.5, 0.5)) * _ScreenSize.zw) * _ScreenSize.xy;
}

int2 FoveatedRemapNonUniformToLinearCS(int2 positionCS)
{
UNITY_BRANCH if(_FOVEATED_RENDERING_NON_UNIFORM_RASTER)
positionCS = RemapFoveatedRenderingNonUniformToLinearCS(positionCS, true);
return positionCS;
}

#else // SUPPORTS_FOVEATED_RENDERING_NON_UNIFORM_RASTER

// dummy coordinate remapping functions for non-foveated rendering
float2 FoveatedRemapLinearToNonUniform(float2 uv) {return uv;}
float2 FoveatedRemapPrevFrameLinearToNonUniform(float2 uv) {return uv;}
float2 FoveatedRemapDensity(float2 uv) {return uv;}
float2 FoveatedRemapPrevFrameDensity(float2 uv) {return uv;}
float2 FoveatedRemapNonUniformToLinear(float2 uv) {return uv;}
float2 FoveatedRemapPrevFrameNonUniformToLinear(float2 uv) {return uv;}
int2 FoveatedRemapLinearToNonUniformCS(int2 positionCS) {return positionCS;}
int2 FoveatedRemapNonUniformToLinearCS(int2 positionCS) {return positionCS;}

#endif

// foveated version of GetPositionInput() functions
PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, uint2 tileCoord)
{
PositionInputs posInput = GetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionNDC = FoveatedRemapNonUniformToLinear(posInput.positionNDC);
return posInput;
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, uint2 tileCoord)
{
PositionInputs posInput = GetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionNDC = FoveatedRemapPrevFrameNonUniformToLinear(posInput.positionNDC);
return posInput;
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize)
{
return FoveatedGetPositionInput(positionSS, invScreenSize, uint2(0, 0));
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize)
{
return FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, uint2(0, 0));
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float3 positionWS)
{
PositionInputs posInput = FoveatedGetPositionInput(positionSS, invScreenSize, uint2(0, 0));
posInput.positionWS = positionWS;
return posInput;
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float3 positionWS)
{
PositionInputs posInput = FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, uint2(0, 0));
posInput.positionWS = positionWS;
return posInput;
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS, uint2 tileCoord)
{
PositionInputs posInput = FoveatedGetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionWS = positionWS;
posInput.deviceDepth = deviceDepth;
posInput.linearDepth = linearDepth;

return posInput;
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS, uint2 tileCoord)
{
PositionInputs posInput = FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionWS = positionWS;
posInput.deviceDepth = deviceDepth;
posInput.linearDepth = linearDepth;

return posInput;
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS)
{
return FoveatedGetPositionInput(positionSS, invScreenSize, deviceDepth, linearDepth, positionWS, uint2(0, 0));
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth, float linearDepth, float3 positionWS)
{
return FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, deviceDepth, linearDepth, positionWS, uint2(0, 0));
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth,
float4x4 invViewProjMatrix, float4x4 viewMatrix,
uint2 tileCoord)
{
PositionInputs posInput = FoveatedGetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionWS = ComputeWorldSpacePosition(posInput.positionNDC, deviceDepth, invViewProjMatrix);
posInput.deviceDepth = deviceDepth;
posInput.linearDepth = LinearEyeDepth(posInput.positionWS, viewMatrix);

return posInput;
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth,
float4x4 invViewProjMatrix, float4x4 viewMatrix,
uint2 tileCoord)
{
PositionInputs posInput = FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, tileCoord);
posInput.positionWS = ComputeWorldSpacePosition(posInput.positionNDC, deviceDepth, invViewProjMatrix);
posInput.deviceDepth = deviceDepth;
posInput.linearDepth = LinearEyeDepth(posInput.positionWS, viewMatrix);

return posInput;
}

PositionInputs FoveatedGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth,
float4x4 invViewProjMatrix, float4x4 viewMatrix)
{
return FoveatedGetPositionInput(positionSS, invScreenSize, deviceDepth, invViewProjMatrix, viewMatrix, uint2(0, 0));
}

PositionInputs FoveatedPrevFrameGetPositionInput(float2 positionSS, float2 invScreenSize, float deviceDepth,
float4x4 invViewProjMatrix, float4x4 viewMatrix)
{
return FoveatedPrevFrameGetPositionInput(positionSS, invScreenSize, deviceDepth, invViewProjMatrix, viewMatrix, uint2(0, 0));
}

#endif // UNITY_FOVEATED_RENDERING_INCLUDED
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef UNITY_FOVEATED_RENDERING_KEYWORDS_INCLUDED
#define UNITY_FOVEATED_RENDERING_KEYWORDS_INCLUDED

#if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS) || defined(UNITY_PLATFORM_VISIONOS)) || defined(SHADER_API_PS5))
#if (!defined(UNITY_COMPILER_DXC) && (defined(UNITY_PLATFORM_OSX) || defined(UNITY_PLATFORM_IOS) || defined(UNITY_PLATFORM_VISIONOS))) || defined(SHADER_API_PS5)

#if defined(SHADER_API_PS5) || defined(SHADER_API_METAL)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ ParallaxOcclusionMapping

delta = intersectionHeight - currHeight;

if (abs(delta) <= 0.01)
if ((delta >= -0.01) && (delta <= 0.01))
break;

// intersectionHeight < currHeight => new lower bounds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,45 +15,49 @@ The **Rendering Debugger** is a specific window for the Scriptable Render Pipeli
![](Images/RenderPipelineDebug1.png)
The Rendering Debugger

## Using the Rendering Debugger
## How to access the Rendering Debugger

The Rendering Debugger window is available in the following modes:

* The Editor.
* The Play mode.
* At runtime in the standalone Unity Player, on any device. The window is only available in **Development Builds**.
| Mode | Platform | Availability | How to Open the Rendering Debugger |
|-----------|----------------|----------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Editor | All | Yes (window in the Editor) | Select **Window > Analysis > Rendering Debugger** |
| Play mode | All | Yes (overlay in the Game view) | On a desktop or laptop computer, press **LeftCtrl+Backspace** (**LeftCtrl+Delete** on macOS)<br>On a console controller, press L3 and R3 (Left Stick and Right Stick) |
| Runtime | Desktop/Laptop | Yes (only in Development builds) | Press **LeftCtrl+Backspace** (**LeftCtrl+Delete** on macOS) |
| Runtime | Console | Yes (only in Development builds) | Press L3 and R3 (Left Stick and Right Stick) |
| Runtime | Mobile | Yes (only in Development builds) | Use a three-finger double tap |

To open the Rendering Debugger in the Editor:
To enable all the sections of the **Rendering Debugger** in your built application, disable **Strip Debug Variants** in **Project Settings > Graphics > HDRP Global Settings**. Otherwise, you can only use the [Display Stats](#display-stats) section.

* Enable **Runtime Debug Shaders** in **HDRP Global Settings** (in the menu: **Edit** > **Project Settings** > **Graphics** > **HDRP Settings**).

* Select **Window** > **Analysis** > **Rendering Debugger**.

To open the window in the Play mode, or at runtime in a Development Build, use the keyboard shortcut Ctrl+Backspace (Ctrl+Delete on macOS) or press L3 and R3 (Left Stick and Right Stick) on a controller.
To disable the runtime UI, use the [enableRuntimeUI](https://docs.unity3d.com/Packages/[email protected]/api/UnityEngine.Rendering.DebugManager.html#UnityEngine_Rendering_DebugManager_enableRuntimeUI) property.

You can display read-only items, such as the FPS counter, independently of the **Rendering Debugger** window. When you disable the **Rendering Debugger** window, they're still visible in the top right corner of the screen. Use this functionality to track particular values without cluttering the screen.

You can disable the runtime UI entirely by using the [`enableRuntimeUI`](https://docs.unity3d.com/Packages/com.unity.render-pipelines.core@latest/api/UnityEngine.Rendering.DebugManager.html#UnityEngine_Rendering_DebugManager_enableRuntimeUI) property.

### Navigation at runtime
## Navigation at runtime

To change the current active item:
### Keyboard

* **Keyboard**: Use the arrow keys.
* **Xbox controller**: Use the Directional pad (D-Pad).
* **PlayStation controller**: Use the Directional buttons.
| Action | Control |
|----------------------------------------------------|-------------------------------------------------------------------------------------------|
| **Change the current active item** | Use the arrow keys |
| **Change the current tab** | Use the Page up and Page down keys (Fn + Up and Fn + Down keys respectively for MacOS) |
| **Display the current active item independently of the debug window** | Press the right Shift key |

To change the current tab:
### Xbox Controller

* **Keyboard**: Use the Page up and Page down keys (Fn + Up and Fn + Down keys respectively for MacOS).
* **Xbox controller**: Use the Left Bumper and Right Bumper.
* **PlayStation controller**: Use the L1 button and R1 button.
| Action | Control |
|----------------------------------------------------|-------------------------------------------------------------------------------------------|
| **Change the current active item** | Use the Directional pad (D-Pad) |
| **Change the current tab** | Use the Left Bumper and Right Bumper |
| **Display the current active item independently of the debug window** | Press the X button |

To display the current active item independently of the debug window:
### PlayStation Controller

* **Keyboard**: Press the right Shift key.
* **Xbox controller**: Press the X button.
* **PlayStation controller**: Press the Square button.
| Action | Control |
|----------------------------------------------------|-------------------------------------------------------------------------------------------|
| **Change the current active item** | Use the Directional buttons |
| **Change the current tab** | Use the L1 button and R1 button |
| **Display the current active item independently of the debug window** | Press the Square button |

<a name="DecalsPanel"></a>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,15 +182,15 @@ class BlitCachedShadowPassData
public TextureHandle atlasTexture;
}

public void BlitCachedIntoAtlas(RenderGraph renderGraph, TextureHandle cachedAtlasTexture, int cachedAtlasSize, Material blitMaterial, string passName, HDProfileId profileID)
public void BlitCachedIntoAtlas(RenderGraph renderGraph, TextureHandle cachedAtlasTexture, Vector2Int cachedAtlasSize, Material blitMaterial, string passName, HDProfileId profileID)
{
if (m_MixedRequestsPendingBlits.Count > 0)
{
using (var builder = renderGraph.AddRenderPass<BlitCachedShadowPassData>(passName, out var passData, ProfilingSampler.Get(profileID)))
{
passData.requestsWaitingBlits = m_MixedRequestsPendingBlits;
passData.blitMaterial = blitMaterial;
passData.cachedShadowAtlasSize = new Vector2Int(cachedAtlasSize, cachedAtlasSize);
passData.cachedShadowAtlasSize = cachedAtlasSize;
passData.sourceCachedAtlas = builder.ReadTexture(cachedAtlasTexture);
passData.atlasTexture = builder.WriteTexture(GetShadowMapDepthTexture(renderGraph));

Expand Down
Loading
Loading