Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Question Custom render pass: Culling layers blending

Discussion in 'High Definition Render Pipeline' started by Sylafrs, Jan 30, 2024.

  1. Sylafrs

    Sylafrs

    Joined:
    Jun 25, 2013
    Posts:
    66
    Hello,

    I'm trying to achieve a custom render pass where I can 'blend' between two views of the same camera with different culling layers; do you know if that is possible?

    I would like to have this effect: (2:35)


    but without setting the material's shader/alpha, since I'd like the character to fade without seeing the different renderers pixels multiplied one onto another while fading

    Thanks :)
     
    Last edited: Jan 30, 2024
  2. Sylafrs

    Sylafrs

    Joined:
    Jun 25, 2013
    Posts:
    66
    Hm.. just seeing at this image :



    Feels like render passes won't allow me to do that..
    that means that I'll have to make a custom shader for each shader I want to fade + be sure ZTest/Stencil works as I want (to avoid multiplies on the same Layer)

    Sorry for the post, I'll still read if you think that's its possible or if that's not or just a bad idea to begin with :p
     
  3. Sylafrs

    Sylafrs

    Joined:
    Jun 25, 2013
    Posts:
    66
    Last edited: Jan 30, 2024
  4. Sylafrs

    Sylafrs

    Joined:
    Jun 25, 2013
    Posts:
    66
    All right, so I managed to get it working with compositor (with an alpha of 0.5f)
    It seems to have issues with Cinemachine though : cameras are being activated when they shouldn't.
    I'll try to fix that and the set the alpha value (could use a static variable for that)
    but I finally have the result I wanted :)

    Just.. I won't be able to use it as it takes too much perfs x)
    > since Compositor re-draws the sky, then I have to re-redraw everything else and lerping between the two cameras (and not just blitting a culled camera rendering); so.. not effective
     
    Last edited: Jan 30, 2024
  5. antoinel_unity

    antoinel_unity

    Unity Technologies

    Joined:
    Jan 7, 2019
    Posts:
    271
    Hello,

    Switching to a transparent material for your character fading is a bit tricky and it'll probably not work for several features because transparent materials don't write in the depth buffer we use in all our screen space effects (like SSR, etc.). So you'll not get the same look as opaque even with an opacity of 1.

    A simpler approach for this would be to do a single ShaderGraph for all the objects you want to fade and then do a dithered fade using an alpha clip instead of transparent objects.
     
  6. Sylafrs

    Sylafrs

    Joined:
    Jun 25, 2013
    Posts:
    66
    Oh, nice idea :)
    I'll try this :
     
    antoinel_unity likes this.