Search Unity

Recreating URP Outline Fullscreen Effect using color, depth, and normals?

Discussion in 'High Definition Render Pipeline' started by EthanFischer, Oct 8, 2020.

  1. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46
    Hi all,

    I'm able to create an outline fullscreen shader in the Universal Render Pipeline using this tutorial
    https://alexanderameye.github.io/outlineshader.html

    But I'm wondering how I can recreate this same effect in an HDRP project.

    I'd need color, depth, and normals to draw an outline on objects in the scene (including the objects' inner edges). The tutorial mentions URP automatically providing two textures, _CameraDepthTexture and _CameraColorTexture, and describes how to modify the pipeline to generate a third _CameraDepthNormalsTexture.

    I'm wondering how I can include these same textures in my fullscreen .hlsl shader.

    Any help would be appreciated!

    -Ethan
     
  2. Camarent

    Camarent

    Joined:
    Feb 19, 2014
    Posts:
    168
    This can be helpful - https://github.com/alelievr/HDRP-Custom-Passes
     
  3. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46
    @Camarent thanks. I've read through that before and gotten the effect described in there working. But it doesn't affect the inner edges on objects. I've learned more about how shaders work since then, though, so maybe I'll give it another look and see if I can modify it to suit my purposes
     
  4. Egad_McDad

    Egad_McDad

    Joined:
    Feb 5, 2020
    Posts:
    39
    I recently created a depth based outline effect using a compute shader and a custom post process volume component and detailed some of my finding in this thread. I believe it should be of some use, particularly how to sample the depth buffer, which should be the same in a fragment shader.

    In short, I found
    LoadCameraDepth()
    from ShaderVariables.hlsl to be very helpful. You can also find
    LoadCameraColor()
    in the same file.

    Doing a quick search of the HDRP custom pass samples it looks like the way to grab normals in fragment shaders is with
    DecodeFromNormalBuffer()
    from NormalBuffer.hlsl which is itself found in the hdrp package.
     
    Camarent and EthanFischer like this.
  5. EthanFischer

    EthanFischer

    Joined:
    Feb 10, 2016
    Posts:
    46
    @Egad_McDad Thank you! I think those are the answers I'm looking for. I'll give these a try next chance I get
     
    Egad_McDad likes this.