Search Unity

How can I make certain meshes be rendered through walls in HDRP?

Discussion in 'High Definition Render Pipeline' started by Wantcha, May 24, 2019.

  1. Wantcha

    Wantcha

    Joined:
    Dec 2, 2017
    Posts:
    114
    I have an object in my scene that I would like to be rendered with an outline/an effect when behind walls, similar to this:
    . How can I create this in the HD Render Pipeline?
     
  2. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,
    this is not available currently in HDRP. A change will come in 2019.3 version of HDRP to allow to do such effects.
     
  3. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    265
    Hello,

    Another way you can achieve this effect is by re-creating the ZTest operation in a shadergraph to know if you're behind an object or not then you can do whatever you want. The problem is that it requires the material to be set in ZTest Always mode so the object is always rendered and this is not currently available in HDRP (it's in progress here: https://github.com/Unity-Technologies/ScriptableRenderPipeline/pull/3692).

    Example Graph:
    upload_2019-5-27_14-11-26.png BehindTheWalls.gif
     
    Reanimate_L and valarnur like this.
  4. asdzxcv777

    asdzxcv777

    Joined:
    Jul 17, 2017
    Posts:
    29
    What will that change be?
     
  5. HenryLiN0118

    HenryLiN0118

    Joined:
    Jan 3, 2018
    Posts:
    1
    Finally! I'm waiting this function for so long since I saw LWRP can do such things
     
  6. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    265
    Hello, quick update about the custom passes :)

    Custom passes in HDRP have been shipped with the 7.1.1 version, there are currently in an experimental state and a lot of bug fixes and improvements will be available during for the next releases.
    There are already some examples of custom passes in HDRP that can be found here: https://github.com/alelievr/HDRP-Custom-Passes, Note that this repository is currently using a branch on the SRP repository that will be part of the next release of HDRP. I'm currently writing the documentation for the custom passes so right now there is pretty much nothing about it except the examples in the HDRP-Custom-Passes repository above.
     
  7. pabloruiz55

    pabloruiz55

    Joined:
    Aug 13, 2012
    Posts:
    8
    Hi, does it work with URP?
     
  8. Digital_Seven

    Digital_Seven

    Joined:
    Aug 20, 2015
    Posts:
    15
    It would appear not. I just recreated it, I guess. There is no "Base" colour that I could find. Doesn't seem to do as the GIF suggests. Always seems to show the blue shader. No glowing through objects either
     

    Attached Files:

    Last edited: Apr 1, 2020
  9. gino_pisello

    gino_pisello

    Joined:
    Jun 24, 2013
    Posts:
    33
    What change? Is it possible to recreate that effect with HDRP now that 2019.3 is out?
     
  10. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
  11. SmorgasOfBorg

    SmorgasOfBorg

    Joined:
    Mar 1, 2015
    Posts:
    5
    So, custom passes look like a good thing for sure. But what about the OP question? How can I achieve the same effect from the LWRP video the OP linked while using HDRP? I am a skilled coder of many years, but shader code for some reason still eludes me... can this be achieved without code in hdrp lie it did in lwrp in the linked video?

    or at the very least.. How can I achieve the same effect from the LWRP video the OP linked while using HDRP?

    Any assistance here to get me over my mental block would be great.
     
  12. iDerp69

    iDerp69

    Joined:
    Oct 27, 2018
    Posts:
    49
    I'm having this same issue SmorgasOfBorg. Did you figure out a way, ultimately?
     
  13. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    265
  14. iDerp69

    iDerp69

    Joined:
    Oct 27, 2018
    Posts:
    49
    Interesting! I didn't see that one there several days ago, did you create it for demonstration purposes? I know many were looking for this effect! I like that it's pretty much drop-in ready. It may not be as simple as achieving this effect in URP (like in the Brackeys video), but at least it's now achievable in HDRP for intermediate devs.

    How difficult would it be to add a distance check so the effect stops occurring after a certain distance?
     
  15. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    265
    Yeah, I got so many requests for this effect that I finally added it. Note that there will be a new custom pass API version coming with 20.1 and 20.2 that will allow you to code these effects more easily and with less code.
    It's also planned to add the stencil configuration in the custom passes UI and when we'll have that, it'd be possible to re-create this effect without any code, just using the builtin custom passes, and a ShaderGraph material.

    You have several ways to do it:
    - Discard the pixel based on his distance to the camera in the ShaderGraph (you can also make it fade before disappearing)
    - Discard the pixel based on the object position in ShaderGraph, it uses the mesh pivot instead of the pixel position so it doesn't work with static batching (because meshes are merged together).
    Note that these techniques don't save any draw-call, it just discards the visual result. If you want to save the draw calls of the objects I think you'll need to do a custom culling query in the custom pass. But, of course, it's trading CPU performances for GPU so I can't say you'll win any performances as it depends on the content of your scene.
     
  16. toorican

    toorican

    Joined:
    May 25, 2018
    Posts:
    16