Search Unity

Fade out objects between Target and Camera.

Discussion in 'Cinemachine' started by Michal_Stangel, Apr 26, 2020.

  1. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Would be great to have another Layers option in Cinemachine Collider add-on which would fade out objects between target and camera. Like in this camera asset:


    In my case I have often a lot of character models around targeted character and don't want to let camera going through them (it looks quite scary), but on the other hand colliding with each character when orbiting around is really messy and unpleasant experience from player's perspective, with constant camera moving forward and backward or up and down.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Excellent idea for a feature. Not sure it belongs on Collider, however.
    For now, you can write a custom script to implement this feature yourself, and add it to the main camera.
     
  3. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Thanks Gregory. I have several years long ToDo for my game, so I can afford to wait and see what professionals can do in the future in this matter :)
     
  4. skrups

    skrups

    Joined:
    Mar 28, 2014
    Posts:
    4
    Hi @Gregoryl, any updates on this functionality! Voting +1 for this one. Thanks!
     
  5. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Have a look at our FadeOutNearbyObjects sample scene. It shows how to implement this using shaders. This sample scene is available from version 2.7.2.
     
    x4000 and Gregoryl like this.
  6. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Is there a HDRP version of this FadeOut shader from this example? It would be best to work with normal LIT shader (in case of HDRP), having material with more textures than just Albedo or some custom shader allowing more textures.
    But I guess it would be much harder to acomplish and perhaps not the task for you people behind Cinemachine.
     
  7. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    We don't have a HDRP version. I have not looked into what would need to change to make it work in HDRP.
     
  8. Michal_Stangel

    Michal_Stangel

    Joined:
    Apr 17, 2017
    Posts:
    151
    Thank you, but no need, at least for me. It seems that author of The Vegetation Engine will add fade feature to his shaders and I would use these. Not sure if it will be possible to hook it somehow with Cinemachine or I will end up writing some script which will be shooting rays from camera to target and fading materials of objects in the way.
     
  9. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,788
    upload_2022-8-2_2-46-40.png
    Here's the basic graph if you want to use this with HDRP, don't forget to create the MinDistance and MaxDistance properties.
    Also notice i use alpha clip and dither node to fade the object, you can remove or change that if you want depend on your art direction
    this is what i got in HDRP
    upload_2022-8-2_2-50-5.png
    oh i forgot this part don't forget to enable use Shadow threshold in the shader option and assign a value to it in the shadergraph block or else when the object are fadeout the shadow will fade out too.
    in this sample scene i set it to 0
    upload_2022-8-2_2-54-23.png
    well unless you use proxy shadow mesh then don't worry about the last part
     
    Last edited: Aug 1, 2022
    gaborkb likes this.