HDRP - Render object in front of everything with Custom Passes when Ambient Occlusion is ON

Hello Respected,

For our game, we are using HDRP version 11. We needed a solution when the objects are in inventory or in examine mode, to be rendered in front of all other objects in the scene to avoid clipping. Since for HDRP using another camera was not a solution, we achieved that with creating Custom Passes. Here is our blog that we wrote for this solution since on the net, there was no any solution for it when HDRP is used: Unity HDRP – Render Object On Top Of Everything – Intetic

Everything worked fine. But now when we enabled Ambient Occlusion, the object that we want still is rendered in front of all other objects, but Ambient Occlusion itself is above this object that is in examine state (that is the point when our Custom Passes are running against that object).

Is it possible somehow to fix this problem? Because it looks like our object is “transparent” since Ambient Occlusion is above it.

Thank you,
Riste Tutureski

Hello there.
I was having trouble with custom pass before. My problem was that when I used subsurface scattering it showed the material black.

Topic link
https://forum.unity.com/threads/custom-pass-issue-subsurface-scattering.996329/

I discovered your blog two days ago and with your method I can now use subsurface scattering and custom pass.
I wanted to thank you for this.:slight_smile: I also wanted to say that it is problematic for using custom pass in temporalAA.

Video of the problem.
https://drive.google.com/file/d/1Ra5D_Xc7ct-3mr6jcFyhBbbKsrcV8CDG

Hello,
How did you solve the subsurface scattering problem that the material looks black?

I tried the way of ristetutureski, but still black:(

Hi.

I created a custom pass in camera. My camera and custom pass settings are as shown below.

7338361--892135--1.jpg
7338361--892138--2.jpg

Thanks! I could render sss material!:slight_smile:
Injection point and culling mask in main-camera are important

How do you deal with the motion vector?

I can’t. You can see it in the video.
https://drive.google.com/file/d/1Ra5D_Xc7ct-3mr6jcFyhBbbKsrcV8CDG

if i turn off motion vector this problem goes away but “taa” doesn’t work well and we cannot use motion blur.:frowning:

Ah, so it seems motion vector not working nicely with custom pass for now. I’ve tried spoofing the motion vector but it’s also doesn’t work. :confused:

@CihanGurbuz
well as usual find a way fix one but break others…
gentlepleasingcrocodileskink
Clipping can be avoided, custom FOV, Movecs support.
carefulsarcasticeidolonhelvum
But self shadow projection are broken. . . . :face_with_spiral_eyes:

@Reanimate_L
This is great! May I ask how you did it?

i move away from custom pass at least for now until they add support for motion vector in custompass.
I just use a slight modification of shader from this sample https://discussions.unity.com/t/720014
I modify so it’s also apply scaling on z axis view space. But yeah now it screwed up shadow projection.
This video also a good references but it’s on UE4 though
https://www.youtube.com/watch?v=zqfzvHCcvZs

we might need a separate thread to talk about fps viewmodel rendering in HDRP

@Reanimate_L

Ah yes, I’ve seen that before. I have not tried this method neither in unreal nor in unity. Because methods other than the render layer bring their own problems. For example, our weapon will have a muzzleflash and bulletshelleject effect. What will these effects look like when the gun goes into the wall? Problems problems and problems. :slight_smile:

Thanks for the feedback my friend.

yeah well like i said above, fix one break others :face_with_spiral_eyes:

I’m on the same boat, can’t find a way to make HDRP work with FPS weapons or items. :frowning:

  1. Custom Passes = messes the AO/motion vector buffers so it looks terrible
  2. Stacking cameras = with/without the Compositor has terrible performance.
  3. the FPS Sample shader = 3 years old… doesn’t work any longer.

Would be great to have somebody from Unity have some input on this, seems like everybody is having the same issue with FPS weapons in HDRP… since 2018.

I think our best bet is to wait until someone creates a 3rd party asset that completes this feature for them… coz this is apparently how it works…

I reckon the UFPS asset on the Asset store managed to accomplish the FPS weapon rendering in a performant and bug-free way somehow. Didnt pick it apart to see how it works yet but seemed to work.

I get what you did, but to have SSS shading working correctly in a Draw Renderer Custom Pass, there is another workaround :

  • Create your skin shader with ShaderGraph, set the Master Node to Transparent BUT set the material that come from this shader as opaque (it is still an option in the material, so np), it’s capital => there are some data that will get some data initialized to make your SSS happend in the custom pass.

  • for injection point : After opaque and Depth to Before Post Process should work as expected.

  • Render queue Type : all

  • Override Depth State box : need to be enable to draw the mesh correctly,

  • Depth write box : can be checked as and comparison set as less equal for normal sorting, but it can be as you choose it to be

here is a screen shot (I don’t have the exact same GUI as you guys as I have modified my Custom Pass scripts to output into a given RT only using the Samplebuffer material, and I did get rid of the custom Inspector Editor script btw). SSS is working perfectly and Depth too :

8274525--1084290--Capture d’écran 2022-07-13 170521.png

cheers, hope it will help some ppl using Lit Subsurface Scattering Shader in a CustomPass

Setting Master Node to transparent completely disables SSS for me (on StackLit Shader), regardless whether I use Custom Pass or not.

Weird I got it working on StackLit, into both the custom pass and the camera rendering, did you keep the material in opaque mode?

Ah something that may be important, It can be resolved.
Right Click on your Main Color Map property in your ShaderGraph, then set this property to be the Main Texture, It will help the shader to resolve everything accordingly to the baseColor map across each sampler