-
Notifications
You must be signed in to change notification settings - Fork 839
Screen Coordinates Override #6597
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
Conversation
…enne/upgrade-test
…enne/upgrade-test
…enne/upgrade-test
…enne/upgrade-test
…enne/upgrade-test
…enne/upgrade-test
… into cluster-display/etienne/upgrade-test
# Conflicts: # com.unity.render-pipelines.universal/Runtime/UniversalRenderer.cs
…enne/upgrade-test # Conflicts: # com.unity.render-pipelines.universal/Runtime/RenderTargetBufferSystem.cs
Hi! This comment will help you figure out which jobs to run before merging your PR. The suggestions are dynamic based on what files you have changed. HDRP URP SRP Core Depending on the scope of your PR, you may need to run more jobs than what has been suggested. Please speak to your lead or a Graphics SDET (#devs-graphics-automation) if you are unsure. |
…enne/upgrade-test
…enne/upgrade-test
…enne/upgrade-test
…enne/upgrade-test # Conflicts: # com.unity.render-pipelines.core/CHANGELOG.md # com.unity.render-pipelines.high-definition/CHANGELOG.md # com.unity.render-pipelines.universal/CHANGELOG.md
…enne/upgrade-test # Conflicts: # com.unity.render-pipelines.universal/CHANGELOG.md
Is |
No it is meant to provide a transformation for screen coordinates, to be performed before some screen space post processing shader computations are performed. You can look at the docs linked in the PR description for more explanations of the problem/solution. I'd also be available for a zoom call :) The only commonality with |
…enne/upgrade-test # Conflicts: # com.unity.render-pipelines.high-definition/CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These changes look sensible and don't conflict with my dynamic scaling work which touch uv but on the vertex shader side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM overall. Mostly concerned about shader stripping.
@@ -9,9 +9,11 @@ Shader "Hidden/Universal Render Pipeline/FinalPost" | |||
#pragma multi_compile_local_fragment _ _LINEAR_TO_SRGB_CONVERSION | |||
#pragma multi_compile_vertex _ _USE_DRAW_PROCEDURAL | |||
#pragma multi_compile_fragment _ DEBUG_DISPLAY | |||
#pragma multi_compile _ SCREEN_COORD_OVERRIDE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this one by chance only used in fragment shader? If so please do multi_compile_fragment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be stripped so we don't regress build times / shader memory. We usually add option so user can optin / optout of feature.
@@ -6,6 +6,7 @@ Shader "Hidden/HDRP/FinalPass" | |||
#pragma editor_sync_compilation | |||
#pragma only_renderers d3d11 playstation xboxone xboxseries vulkan metal switch | |||
|
|||
#pragma multi_compile _ SCREEN_COORD_OVERRIDE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please used multi_compile_local_fragment here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need to use multi_compile_fragment
here
…enne/upgrade-test # Conflicts: # com.unity.render-pipelines.core/CHANGELOG.md
…enne/upgrade-test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you for adding the stripping option.
…enne/upgrade-test # Conflicts: # TestProjects/HDRP_Tests/ProjectSettings/EditorBuildSettings.asset # com.unity.render-pipelines.high-definition/CHANGELOG.md
Changes were addressed we need to land
JIRA Epic: https://jira.unity3d.com/browse/CD-74 Re-submission of #6597 which got reverted due to test failures. This PR introduces **Screen Coordinates Override** (**SCO** for the remainder of this document) for both URP and HDRP. SCO provides a transformation of screen space coordinates when evaluating screen space effects. We have found it useful in virtual production scenarios. The first use case for this is **Cluster Display** (formerly known as [Cluster Rendering](https://docs.unity3d.com/560/Documentation/Manual/ClusterRendering.html)), that is, distributed rendering. It allows for post effects such as vignette to be properly rendered at the scale of a grid of displays. Another use case is the implementation of Lens Distortion when replicating the distortion incurred by a physical lens. Since pixels near the edges may be pushed inwards of the viewport by the distortion, we need to render the scene with overscan. (By overscan, we mean rendering to an expanded pixel surface, later cropped out to its original size before being presented.) To preserve the distortion's aspect in the cropped image, we need to apply a transform to screen space coordinates when the lens distortion is being computed. The first implementation of this technique was part of the first Cluster Display effort, and was then called **Cluster Display Space** or **Global Screen Space**. A high level description of the technique can be found in [this document](https://docs.google.com/document/d/1I_mR42Tt119nVhhHwHG9F_n7DwpPin7Tds4yhx59oko/edit?usp=sharing) and [this one](https://docs.google.com/document/d/1qZqUTA5VAeV35PkldjOXXjpKD-JxWfgs2KJC6rh-4mo/edit?usp=sharing). The switch to the **Screen Coordinates Override** terminology is justified by the fact that the technique is relevant outside of Cluster Display. As illustrated above by our Lens Distortion example. In the changes we regularly see the introduction of 2 fields: - `screenCoordScaleBias` holds the scale and bias used to transform screen space coordinates. - `screenSizeOverride` holds the screen size (and its reciprocal) to be used in conjunction with transformed screen space coordinates. --- ### Changes Overview * #### SRP Core - `ScreenCoordOverrideUtils` -> basic utilities to manage the shader keyword. Main point is to avoid the duplication of the shader keyword. - `ScreenCoordOverride.hlsl` -> shader code and macros to perform the screen space coordinates conversion. * #### HDRP - `FrameSettings` -> add `ScreenCoordOverride` and `AsymmetricProjection` settings. `AsymmetricProjection` allows the activation of the asymmetric projection code path even when XR is not enabled. This is useful for Cluster Display. - `HDAdditionalCameraData` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `ShaderVariablesGlobal` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `HDCamera` -> update global shader variables. - `HDRenderPipeline` -> activates the shader keyword. - `HDRenderPipeline.PostProcess` -> activates the shader keyword based on frame settings. - `UberPost.compute` -> add SCO support. * #### URP - `ScriptableRenderer` -> fix a swap buffer issue (first fixed [here](#6522)) - `PostProcessUtils` -> init random generation using frame count so that it's consistent across machines in a Cluster Display scenario. - `UniversalAdditionalCameraData` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields and feature activation. - `UniversalRenderPipeline` -> populate additional camera data. - `UniversalRenderPipelineCore` -> add fields and associated shader properties. - `UniversalRenderer` -> related to swap buffer fix. - `Input.hlsl` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `FinalPost.shader` -> add SCO support. - `UberPost.shader` -> add SCO support. - `CapturePass` -> fixed color buffer access (before, post effects would not be captured) - `UniversalRenderPipelineGlobalSettings` -> add shader stripping option (`SerializedUniversalRenderPipelineGlobalSettings`, `UniversalRenderPipelineGlobalSettingsUI.Drawers` and `UniversalRenderPipelineGlobalSettingsUI.Skin` were modified to reflect this change) - `ShaderPreprocessor` -> implement shader stripping option
JIRA Epic: https://jira.unity3d.com/browse/CD-74 Re-submission of Unity-Technologies/Graphics#6597 which got reverted due to test failures. This PR introduces **Screen Coordinates Override** (**SCO** for the remainder of this document) for both URP and HDRP. SCO provides a transformation of screen space coordinates when evaluating screen space effects. We have found it useful in virtual production scenarios. The first use case for this is **Cluster Display** (formerly known as [Cluster Rendering](https://docs.unity3d.com/560/Documentation/Manual/ClusterRendering.html)), that is, distributed rendering. It allows for post effects such as vignette to be properly rendered at the scale of a grid of displays. Another use case is the implementation of Lens Distortion when replicating the distortion incurred by a physical lens. Since pixels near the edges may be pushed inwards of the viewport by the distortion, we need to render the scene with overscan. (By overscan, we mean rendering to an expanded pixel surface, later cropped out to its original size before being presented.) To preserve the distortion's aspect in the cropped image, we need to apply a transform to screen space coordinates when the lens distortion is being computed. The first implementation of this technique was part of the first Cluster Display effort, and was then called **Cluster Display Space** or **Global Screen Space**. A high level description of the technique can be found in [this document](https://docs.google.com/document/d/1I_mR42Tt119nVhhHwHG9F_n7DwpPin7Tds4yhx59oko/edit?usp=sharing) and [this one](https://docs.google.com/document/d/1qZqUTA5VAeV35PkldjOXXjpKD-JxWfgs2KJC6rh-4mo/edit?usp=sharing). The switch to the **Screen Coordinates Override** terminology is justified by the fact that the technique is relevant outside of Cluster Display. As illustrated above by our Lens Distortion example. In the changes we regularly see the introduction of 2 fields: - `screenCoordScaleBias` holds the scale and bias used to transform screen space coordinates. - `screenSizeOverride` holds the screen size (and its reciprocal) to be used in conjunction with transformed screen space coordinates. --- ### Changes Overview * #### SRP Core - `ScreenCoordOverrideUtils` -> basic utilities to manage the shader keyword. Main point is to avoid the duplication of the shader keyword. - `ScreenCoordOverride.hlsl` -> shader code and macros to perform the screen space coordinates conversion. * #### HDRP - `FrameSettings` -> add `ScreenCoordOverride` and `AsymmetricProjection` settings. `AsymmetricProjection` allows the activation of the asymmetric projection code path even when XR is not enabled. This is useful for Cluster Display. - `HDAdditionalCameraData` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `ShaderVariablesGlobal` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `HDCamera` -> update global shader variables. - `HDRenderPipeline` -> activates the shader keyword. - `HDRenderPipeline.PostProcess` -> activates the shader keyword based on frame settings. - `UberPost.compute` -> add SCO support. * #### URP - `ScriptableRenderer` -> fix a swap buffer issue (first fixed [here](Unity-Technologies/Graphics#6522)) - `PostProcessUtils` -> init random generation using frame count so that it's consistent across machines in a Cluster Display scenario. - `UniversalAdditionalCameraData` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields and feature activation. - `UniversalRenderPipeline` -> populate additional camera data. - `UniversalRenderPipelineCore` -> add fields and associated shader properties. - `UniversalRenderer` -> related to swap buffer fix. - `Input.hlsl` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `FinalPost.shader` -> add SCO support. - `UberPost.shader` -> add SCO support. - `CapturePass` -> fixed color buffer access (before, post effects would not be captured) - `UniversalRenderPipelineGlobalSettings` -> add shader stripping option (`SerializedUniversalRenderPipelineGlobalSettings`, `UniversalRenderPipelineGlobalSettingsUI.Drawers` and `UniversalRenderPipelineGlobalSettingsUI.Skin` were modified to reflect this change) - `ShaderPreprocessor` -> implement shader stripping option
JIRA Epic: https://jira.unity3d.com/browse/CD-74 Re-submission of Unity-Technologies/Graphics#6597 which got reverted due to test failures. This PR introduces **Screen Coordinates Override** (**SCO** for the remainder of this document) for both URP and HDRP. SCO provides a transformation of screen space coordinates when evaluating screen space effects. We have found it useful in virtual production scenarios. The first use case for this is **Cluster Display** (formerly known as [Cluster Rendering](https://docs.unity3d.com/560/Documentation/Manual/ClusterRendering.html)), that is, distributed rendering. It allows for post effects such as vignette to be properly rendered at the scale of a grid of displays. Another use case is the implementation of Lens Distortion when replicating the distortion incurred by a physical lens. Since pixels near the edges may be pushed inwards of the viewport by the distortion, we need to render the scene with overscan. (By overscan, we mean rendering to an expanded pixel surface, later cropped out to its original size before being presented.) To preserve the distortion's aspect in the cropped image, we need to apply a transform to screen space coordinates when the lens distortion is being computed. The first implementation of this technique was part of the first Cluster Display effort, and was then called **Cluster Display Space** or **Global Screen Space**. A high level description of the technique can be found in [this document](https://docs.google.com/document/d/1I_mR42Tt119nVhhHwHG9F_n7DwpPin7Tds4yhx59oko/edit?usp=sharing) and [this one](https://docs.google.com/document/d/1qZqUTA5VAeV35PkldjOXXjpKD-JxWfgs2KJC6rh-4mo/edit?usp=sharing). The switch to the **Screen Coordinates Override** terminology is justified by the fact that the technique is relevant outside of Cluster Display. As illustrated above by our Lens Distortion example. In the changes we regularly see the introduction of 2 fields: - `screenCoordScaleBias` holds the scale and bias used to transform screen space coordinates. - `screenSizeOverride` holds the screen size (and its reciprocal) to be used in conjunction with transformed screen space coordinates. --- ### Changes Overview * #### SRP Core - `ScreenCoordOverrideUtils` -> basic utilities to manage the shader keyword. Main point is to avoid the duplication of the shader keyword. - `ScreenCoordOverride.hlsl` -> shader code and macros to perform the screen space coordinates conversion. * #### HDRP - `FrameSettings` -> add `ScreenCoordOverride` and `AsymmetricProjection` settings. `AsymmetricProjection` allows the activation of the asymmetric projection code path even when XR is not enabled. This is useful for Cluster Display. - `HDAdditionalCameraData` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `ShaderVariablesGlobal` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `HDCamera` -> update global shader variables. - `HDRenderPipeline` -> activates the shader keyword. - `HDRenderPipeline.PostProcess` -> activates the shader keyword based on frame settings. - `UberPost.compute` -> add SCO support. * #### URP - `ScriptableRenderer` -> fix a swap buffer issue (first fixed [here](Unity-Technologies/Graphics#6522)) - `PostProcessUtils` -> init random generation using frame count so that it's consistent across machines in a Cluster Display scenario. - `UniversalAdditionalCameraData` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields and feature activation. - `UniversalRenderPipeline` -> populate additional camera data. - `UniversalRenderPipelineCore` -> add fields and associated shader properties. - `UniversalRenderer` -> related to swap buffer fix. - `Input.hlsl` -> add the `ScreenSizeOverride` and `ScreenCoordScaleBias` fields. - `FinalPost.shader` -> add SCO support. - `UberPost.shader` -> add SCO support. - `CapturePass` -> fixed color buffer access (before, post effects would not be captured) - `UniversalRenderPipelineGlobalSettings` -> add shader stripping option (`SerializedUniversalRenderPipelineGlobalSettings`, `UniversalRenderPipelineGlobalSettingsUI.Drawers` and `UniversalRenderPipelineGlobalSettingsUI.Skin` were modified to reflect this change) - `ShaderPreprocessor` -> implement shader stripping option
Purpose of this PR
This PR introduces Screen Coordinates Override (SCO for the remainder of this document) for both URP and HDRP. SCO
provides a transformation of screen space coordinates when evaluating screen space effects.
We have found it useful in virtual production scenarios.
The first use case for this is Cluster Display (formerly known as Cluster Rendering), that is, distributed rendering. It allows for post effects such as vignette to be properly rendered at the scale of a grid of displays.
Another use case is the implementation of Lens Distortion when replicating the distortion incurred by a physical lens. Since pixels near the edges may be pushed inwards of the viewport by the distortion, we need to render the scene with overscan. (By overscan, we mean rendering to an expanded pixel surface, later cropped out to its original size before being
presented.) To preserve the distortion's aspect in the cropped image, we need to apply a transform to screen space coordinates when the lens distortion is being computed.
The first implementation of this technique was part of the first Cluster Display effort, and was then called Cluster
Display Space or Global Screen Space. A high level description of the technique can be found in
this document and this one.
The switch to the Screen Coordinates Override terminology is justified by the fact that the technique is relevant outside of
Cluster Display. As illustrated above by our Lens Distortion example.
In the changes we regularly see the introduction of 2 fields:
screenCoordScaleBias
holds the scale and bias used to transform screen space coordinates.screenSizeOverride
holds the screen size (and its reciprocal) to be used in conjunction with transformed screenspace coordinates.
Changes Overview
SRP Core
ScreenCoordOverrideUtils
-> basic utilities to manage the shader keyword. Main point is to avoid the duplication ofthe shader keyword.
ScreenCoordOverride.hlsl
-> shader code and macros to perform the screen space coordinates conversion.HDRP
FrameSettings
-> addScreenCoordOverride
andAsymmetricProjection
settings.AsymmetricProjection
allows theactivation of the asymmetric projection code path even when XR is not enabled. This is useful for Cluster Display.
HDAdditionalCameraData
-> add theScreenSizeOverride
andScreenCoordScaleBias
fields.ShaderVariablesGlobal
-> add theScreenSizeOverride
andScreenCoordScaleBias
fields.HDCamera
-> update global shader variables.HDRenderPipeline
-> activates the shader keyword.HDRenderPipeline.PostProcess
-> activates the shader keyword based on frame settings.UberPost.compute
-> add SCO support.URP
ScriptableRenderer
-> fix a swap buffer issue (firstfixed here)
PostProcessUtils
-> init random generation using frame count so that it's consistent across machines in a ClusterDisplay scenario.
RenderTargetBufferSystem
-> remove a method not needed anymore. (Was involved in the swap buffer issue.)UniversalAdditionalCameraData
-> add theScreenSizeOverride
andScreenCoordScaleBias
fields and featureactivation.
UniversalRenderPipeline
-> populate additional camera data.UniversalRenderPipelineCore
-> add fields and associated shader properties.UniversalRenderer
-> related to swap buffer fix.Input.hlsl
-> add theScreenSizeOverride
andScreenCoordScaleBias
fields.FinalPost.shader
-> add SCO support.UberPost.shader
-> add SCO support.Testing status
We added the following graphics tests. We test custom post processes and passes since we want to enable users to use the
feature.
HDRP_Tests
UniversalGraphicsTest_PostPro
We are also in the process of developing Cluster Display and test this feature as part of our work. We are also adding
graphics test to that package as well.
Comments to reviewers
@sandy-carter-unity regarding the swap buffer bug we discussed in late december.
@phi-lira feel free to assign relevant members from your team.
@sebastienlagarde feel free to assign relevant members from your team.
Let me know how CHANGELOG update works, I assume I shouldn't add entries below past releases.