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

[10.x.x] Bugfixes for SSAO #1213

Merged
merged 15 commits into from
Aug 28, 2020
Merged

[10.x.x] Bugfixes for SSAO #1213

merged 15 commits into from
Aug 28, 2020

Conversation

ellioman
Copy link
Contributor

@ellioman ellioman commented Jul 9, 2020

Purpose of this PR

This PR does the following:

  • Fixes an issue where SSAO was upside down when not rendering to an intermediate texture
  • Adds a GetNormalizedScreenSpaceUV() function to ShaderVariablesFunctions.hlsl
  • Adds a TransformScreenUV() function to ShaderVariablesFunctions.hlsl
  • Adds a TransformNormalizedScreenUV() function to ShaderVariablesFunctions.hlsl
  • Fixes the float2 normalizedScreenSpaceUV in InputData, as it wasn't actually normalized screen UV.
  • Fixed that the ScaleBias parameter was not being updated before drawing objects
  • Removes an extra _SCREEN_SPACE_OCCLUSION in Bakedlit shader
  • Removes unused code in DepthNormals pass
  • Adds AlphaClip to the ShaderGraph Depth Normals pass
  • Adds a new URP Asset (UniversalRPAssetBackBuffer) that disables features that forces an opaque texture
  • Adds a new quality setting (BackBuffer) that has the new URP Asset assigned
  • Adds a new Script (SetQualityLevelOnAwake) that switches quality settings on Awake() in playmode and reverts back to the original one in OnDisable()
  • Adds a new test scene (144_SSAO_RenderToBackBuffer) that uses the new script to switch to the BackBuffer Quality setting

Screen Shot 2020-07-09 at 11 39 46

Screen Shot 2020-07-09 at 11 40 32

Comments to reviewers

This is easily reproducible by going to the URP Asset and turning off Opaque texture, HDR and MSAA.


Testing status

Manual Tests: What did you do?

  • Opened test project + Run graphic tests locally
  • Built a player
  • Checked new UI names with UX convention
  • Tested UI multi-edition + Undo/Redo + Prefab overrides + Alignment in Preset
  • C# and shader warnings (supress shader cache to see them)
  • Checked new resources path for the reloader (in developer mode, you have a button at end of resources that check the paths)
  • Other:

@phi-lira
Copy link
Contributor

phi-lira commented Jul 9, 2020

Adding XR team as reviewer.

@fabien-unity fabien-unity removed their request for review July 9, 2020 13:50
…ving unused code and fixing FullScreenBlit from declaring _ScaleBias.
Copy link
Contributor

@thomas-zeng thomas-zeng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code change looks good to me, can we add a unit test for this SSAO use case(render without intermediate texture)? For this specific issue, XR test framwork will reuse that unit test and ensure yflip is correct when rendering in XR.

@ellioman ellioman marked this pull request as ready for review July 13, 2020 06:32
@ellioman ellioman requested a review from a team as a code owner July 13, 2020 06:32
Vector4 scaleBias = (flipSign < 0.0f)
? new Vector4(flipSign, 1.0f, -1.0f, 1.0f)
: new Vector4(flipSign, 0.0f, 1.0f, 1.0f);
cmd.SetGlobalVector(ShaderPropertyId.scaleBiasRt, scaleBias);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if someone tries to access these scaleBias variables in passes before drawobjects. Should also set up those at beginning of the frame so any custom pass or pass before main rendering doesn't access garbage/previous frame values?

Can be fixed in follow up PR.

@thomas-zeng
Copy link
Contributor

Adding Ryan to verify this is fixed in XR.

@thomas-zeng thomas-zeng requested review from DennisDeRykeUnity and removed request for ryanhy-unity July 13, 2020 15:55
@DennisDeRykeUnity
Copy link
Contributor

@ellioman @thomas-zeng Ryan is away so I'll test this. Based on problems that Ryan found with previous SSAO iterations, what testing seems appropriate for this PR? I assume I should test on Rift and Quest, but are other HMDs needed? Historically, have you seen cases where SSAO worked on one graphics API but broke on another?

Copy link
Contributor

@DennisDeRykeUnity DennisDeRykeUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has been discussed internally but I am repeating it here.

When I tried the following configuration what I saw in the Rift looked like a stereo version of the 142_SSAO_DepthNormal_Projection reference image:

  • Unity (trunk ef716c6ae229)
  • Graphics (universal/ssao-fixes 14b6738)
  • XRSDK, Oculus Rift, Single Pass Instanced
  • Editor Playmode and built Standalone Player
  • URP Graphics Test 142_SSAO_DepthNormal_Projection
  • UniversalRPAsset default settings (HDR, MSAA, and Opaque Texture on)

However, when I toggled off HDR, MSAA, and Opaque Texture I see what looks like an upside-down depth buffer superimposed over the scene geometry. Y-flip issues are difficult to solve ubiquitously. Y-flip fixes on one configuration frequently break another configuration. After this problem is purportedly fixed, this PR will need extensive testing across non-XR and XR platforms, graphics APIs, etc. prior to merging.

@thomas-zeng
Copy link
Contributor

Current master merged a PR that prevents the bug case from happening: #1199

I have manually reverted the above PR locally and tested the SSAO yflip issue is fixed in XR.

I don't think there is a good way for QA to test this PR at the moment without local changes.
@phi-lira please advice.

com.unity.render-pipelines.core: 10.0.0-preview.26
com.unity.render-pipelines.high-definition-config: 10.0.0-preview.23
com.unity.render-pipelines.high-definition: 10.0.0-preview.23
com.unity.render-pipelines.lightweight: 10.0.0-preview.23
com.unity.render-pipelines.universal: 10.0.0-preview.22
com.unity.shadergraph: 10.0.0-preview.23
com.unity.visualeffectgraph: 10.0.0-preview.23
@ellioman ellioman requested a review from a team as a code owner July 24, 2020 18:39
# Conflicts:
#	com.unity.render-pipelines.core/package.json
#	com.unity.render-pipelines.high-definition-config/package.json
#	com.unity.render-pipelines.high-definition/package.json
#	com.unity.render-pipelines.lightweight/package.json
#	com.unity.render-pipelines.universal/package.json
#	com.unity.shadergraph/package.json
#	com.unity.visualeffectgraph/package.json
@DennisDeRykeUnity
Copy link
Contributor

I repeated my tests from 7/17 using the latest dev branch commit with a newer trunk changeset. What I saw in the Rift looked like a stereo version of the 142_SSAO_DepthNormal_Projection reference image using these configs:

Unity (trunk c4cf72ed713b)
Graphics (universal/ssao-fixes cf02adb)
XRSDK, Oculus Rift, Single Pass Instanced
Standalone Player
URP Graphics Test 142_SSAO_DepthNormal_Projection
HDR, MSAA, and Opaque Texture: all Enabled, and all Disabled

I'll try similar tests on Quest.

Copy link
Contributor

@DennisDeRykeUnity DennisDeRykeUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I approve this PR. The depth buffer issue I reported on 7/17 does not occur with the following configurations.

I do see some sparkle artifacts on trees, like small flickering horizontal lines of brightly-colored pixels, as well as tearing. However, these anomalies also occur when I switch from the dev branch URP to URP packages from recent Graphics master (46f38be). I’ll investigate this further, and file bugs if applicable.

  • Unity (trunk 268f33c02e91)
  • URP (universal/ssao-fixes cf02adb)
  • scene 142_SSAO_DepthNormal_Projection
  • Quest
  • OpenGLES3, and Vulkan
  • MultiView
  • HDR, MSAA, Opaque Texture: all Enabled, and all Disabled

# Conflicts:
#	TestProjects/UniversalGraphicsTest/ProjectSettings/EditorBuildSettings.asset
#	com.unity.render-pipelines.universal/Runtime/RendererFeatures/ScreenSpaceAmbientOcclusion.cs
Copy link
Collaborator

@alindmanUnity alindmanUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shader graph changes look alright to me, but i don't know how much test coverage we have for the gbuffer pass yet. as long as you've manually confirmed that the results aren't breaking or drastically different then it's good to go

@ellioman
Copy link
Contributor Author

shader graph changes look alright to me, but i don't know how much test coverage we have for the gbuffer pass yet. as long as you've manually confirmed that the results aren't breaking or drastically different then it's good to go

Next up is support for Deferred where I'll be adding two test scenes for that. So we are good there.

@ellioman ellioman merged commit b2edddf into master Aug 28, 2020
@ellioman ellioman deleted the universal/ssao-fixes branch August 28, 2020 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants