alelievr / HDRP-Custom-Passes

A bunch of custom passes made for HDRP
MIT License
1.25k stars 136 forks source link

HDRP-Custom-Passes

A bunch of custom passes made for HDRP. This project have been setup for Unity 2022.3 version with HDRP 14.x.

If you're looking for older versions, you can find them in the git branches: 2020.2/3, 2021.2/3.

TIPS Effect:

Features:

Source file link for this effect: TIPS.cs and TIPS.shader

TIPS_Effect TIPS_Effect_Size TIPS_Effect_Color

Slight Blur Effect:

Features:

Source file link for this effect: SlightBlur.cs and Blur.shader SlightBlur

Outline Effect:

Source file link for this effect: 02_Selection_Objects.shader and 02_Selection_Fullscreen.shader

Effect made without custom C#, setup in the inspector: image

OutlineThickness OutlineColor2

See Through Effect:

Source file link for this effect: SeeThrough.cs and SeeThroughStencil.shader SeeThrough

AR Effect:

Features:

AR

Glitch Effect:

Features:

Glitch

Scrolling Formulas Effect:

Features:

Liquid

Features:

Glass

Features:

Depth Capture

Features:

Render With Normal Buffer

Rendering objects in the normal buffer is essential to make objects work with screen space effects. This example show how to create a custom pass that renders an object in the depth, normal and color buffer so the SSAO can correctly be applied (you can see the exagerated SSAO effect in this screenshot)

image

And this is the same image without rendering the object to the normal buffer:
image As you can see the SSAO is completely messed-up

Note that because you need to render the object in both depth-prepass and forward pass, you need two custom passes volume with different injection points:
image

ScreenSpace Camera UI Blur

This effect blurs the camera color buffer and renders the screenspace UI on top of it. It is intended to be used in the after post process injection point UI_blur

Note that this custom pass also avoid z test issues when doing this kind of as the transparent objects are rendered after everything.

image

Render Video Without TAA

This effect allows you to render an object (for example a video player) without TAA. It uses custom post processes to achieve this, so be sure to have the "VideoPlaybackWithoutTAAPostProcess" post process in your HDRP default settings:

image.

As you can see in the videos, this pass will remove all artifacts visible when an object doesn't have valid motion vector data (which is the case for most texture animation or video playback):

With TAA:

https://user-images.githubusercontent.com/6877923/116881360-77e10300-ac23-11eb-8a19-f176d2364f11.mp4

Without TAA:

https://user-images.githubusercontent.com/6877923/116881366-78799980-ac23-11eb-97b0-5f8aa18f9b3c.mp4

By default in this effect, the fixDepthBufferJittering field is disabled because it's a very costly operation (re-render all the objects in the scene into an unjittered depth buffer) but it allows to get rid of all TAA artifacts remaining after you add this effect (mainly depth jittering).

Custom pass effect sources: Assets/CustomPasses/Video Playback Without TAA.

Render Object Motion Vectors

Render the Object motion vectors (not camera motion vectors!) into a render texture image

Sources: Assets/CustomPasses/RenderMotionVectors

Copy Buffer

Custom pass that can copy the following buffers to a render texture:

image

Source: Assets/CustomPasses/CopyPass

Screen Space Wetness

Effect that modifies the normal and roughness buffers in screen space to give a "wet" effect to objects. Sources: Assets/CustomPasses/Wetness

It's also compatible with ShaderGraph using the SubGraph "EncodeIntoToNormalBuffer".

https://user-images.githubusercontent.com/6877923/195407733-1e73b63c-5ba6-488f-829d-d4cb0d0b1412.mp4

Current Depth To Custom Depth

Duing HDRP rendering, you only have access to the depth buffer that contains all opaque objects, the depth texture is not updated when rendering transparent with depth pre/post passes.

This custom pass copies the current camera depth (up to date with the current injection point) to the custom depth buffer. The custom depth buffer can then be sampled in a fullscreen shader graph using the custom depth node.

Source file for this effect: CurrentDepthToCustomDepth.cs and CurrentDepthToCustomDepth.shader.