Skip to content

[URP] DepthCopy texture as a color #5369

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

Merged
merged 18 commits into from
Oct 6, 2021

Conversation

jonuuukas
Copy link
Contributor

@jonuuukas jonuuukas commented Aug 17, 2021


Purpose of this PR

Why is this PR needed, what hard problem is it solving/fixing?

This PR changes the behaviour of URP's DepthCopy pass to output R32_SFloat texture instead of a native depth texture.
Why? Because Native RenderPasses support only a single depth buffer and this copy buffer usually is the main offender on why RenderPasses get split.
This should also enable some features(f.e. SSAO, Decals and etc.) to be able to utilise RenderPass API as well, as a lot of them rely on additional depth texture. This would also mean that the depth could technically be framebuffer-fetched using this newly changed texture

Testing status

Yamato is as green as it can get (it seems, not sure), but QA pass definitely should be done, as this affects the whole URP. Manually checked all of the URP test suites and ran locally on mac editor.

Comments to reviewers

Notes for the reviewers you have assigned.

@jonuuukas jonuuukas requested review from a team as code owners August 17, 2021 14:33
@github-actions
Copy link

github-actions bot commented Aug 17, 2021

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.
Link to Yamato: https://yamato.cds.internal.unity3d.com/jobs/902-Graphics
Search for your PR branch using the sidebar on the left, then add the following segment(s) to the end of the URL (you may need multiple tabs depending on how many packages you change)

URP
/.yamato%252Fall-urp.yml%2523PR_URP_2021.2

VFX
/.yamato%252Fall-vfx.yml%2523PR_VFX_2021.2

SRP Core
You could run ABV on your branch before merging your PR, but it will start A LOT of jobs. Please be responsible about it and run it only when you feel the PR is ready:
/.yamato%252F_abv.yml%2523all_project_ci_2021.2
Be aware that any modifications to the Core package impacts everyone in the Graphics repo so please discuss the PR with your lead.

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.

@github-actions
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!

Copy link
Contributor

@manuele-bonanno manuele-bonanno left a comment

Choose a reason for hiding this comment

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

looks good! Some minor comments

descriptor.depthBufferBits = 32; //TODO: do we really need this. double check;
// descriptor.colorFormat = RenderTextureFormat.Depth;
descriptor.graphicsFormat = GraphicsFormat.R32_SFloat;
descriptor.depthBufferBits = 0; //TODO: do we really need this. double check;
Copy link
Contributor

Choose a reason for hiding this comment

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

this looks weird, not sure is needed

@@ -43,14 +43,15 @@ public void Setup(RenderTargetHandle source, RenderTargetHandle destination)
public override void OnCameraSetup(CommandBuffer cmd, ref RenderingData renderingData)
{
var descriptor = renderingData.cameraData.cameraTargetDescriptor;
descriptor.colorFormat = RenderTextureFormat.Depth;
descriptor.depthBufferBits = 32; //TODO: do we really need this. double check;
// descriptor.colorFormat = RenderTextureFormat.Depth;
Copy link
Contributor

Choose a reason for hiding this comment

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

the commented out line can be removed

@@ -31,6 +31,7 @@ public DepthOnlyPass(RenderPassEvent evt, RenderQueueRange renderQueueRange, Lay
base.profilingSampler = new ProfilingSampler(nameof(DepthOnlyPass));
m_FilteringSettings = new FilteringSettings(renderQueueRange, layerMask);
renderPassEvent = evt;
useNativeRenderPass = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

why is this pass not RP compatible anymore?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this actually get's set later as there is a possibility that with depth prepass we are going to have the additional depth as depth. however, if we can use it as a color texture - it will get set to true

@lukaschod lukaschod mentioned this pull request Aug 24, 2021
ClearFlag.None,
ClearFlag.Depth,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't follow why we are changing this. Could this maybe introduce regression for users that might read depend on depth after final blit pass?

@phi-lira
Copy link
Contributor

Adding @PaulDemeulenaere and @thomas-zeng for area review.

@manuele-bonanno
Copy link
Contributor

please also update the changelog

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.

Approve for the XR related changes. Please address other reviewer's feedback :)

@phi-lira phi-lira marked this pull request as ready for review October 6, 2021 14:32
@github-actions github-actions bot added the vfx label Oct 6, 2021
Copy link
Contributor

@PaulDemeulenaere PaulDemeulenaere left a comment

Choose a reason for hiding this comment

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

@@ -271,7 +271,7 @@ void frag(ps_input i
outSelection = float4(_ObjectId, _PassValue, 1.0, 1.0);
#elif VFX_PASSDEPTH == VFX_PASSDEPTH_ACTUAL
#ifndef WRITE_MSAA_DEPTH
dummy = (float4)0;
dummy = float4(i.VFX_VARYING_POSCS.z, 0,0,0);
Copy link
Contributor

@PaulDemeulenaere PaulDemeulenaere Oct 6, 2021

Choose a reason for hiding this comment

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

I'm not sure why we need to do this change but I think ™️ this value wasn't actually outputted, thus, it should be fine.

@phi-lira phi-lira changed the base branch from master to universal/staging October 6, 2021 15:09
@phi-lira phi-lira merged commit a65bb59 into universal/staging Oct 6, 2021
@phi-lira phi-lira deleted the universal/depth-copy-as-color branch October 6, 2021 15:10
@phi-lira phi-lira mentioned this pull request Oct 6, 2021
phi-lira added a commit that referenced this pull request Oct 11, 2021
@phi-lira phi-lira restored the universal/depth-copy-as-color branch October 11, 2021 09:57
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