Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

2D URP. Character silhouette behind the object

Discussion in '2D' started by BeginnerPolymath, Apr 14, 2022.

  1. BeginnerPolymath

    BeginnerPolymath

    Joined:
    Jul 31, 2015
    Posts:
    38
    Hi all. Is there any way to implement a similar silhouette renderer https://docs.unity3d.com/Packages/c...ures/how-to-custom-effect-render-objects.html for 2D rendering?
    I have custom Transparency Sort Mode axes so the character can overlap objects, but apparently Renderer Feature - Render Objects does not work with 2D rendering as needed.
    I would like to either find out what the problem is, or find another solution to implement this effect.
    The character I have uses bone animation and Sorting Group. There are also many objects in the scene that use custom shaders that can also make adjustments.
    What options can you suggest?
     
    tonytopper likes this.
  2. BeginnerPolymath

    BeginnerPolymath

    Joined:
    Jul 31, 2015
    Posts:
    38
    Bump
     
    tonytopper likes this.
  3. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    253
    Can you tell me more about what you mean?
     
  4. juicedup

    juicedup

    Joined:
    Aug 18, 2019
    Posts:
    47
    I'd like to know how to do this aswell
     
    tonytopper likes this.
  5. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    253
    Looking at the docs it seems like this would have a number of issues when it comes to working with sprites. I can look into this when I have time and make a sample.
     
  6. ttran07

    ttran07

    Joined:
    Mar 9, 2019
    Posts:
    6
    Any update on this?
     
    tonytopper likes this.
  7. juicedup

    juicedup

    Joined:
    Aug 18, 2019
    Posts:
    47
    I think it's better to avoid unity's 2d renderer for the time being.
     
    RemDust likes this.
  8. BeginnerPolymath

    BeginnerPolymath

    Joined:
    Jul 31, 2015
    Posts:
    38
    Maybe by now there is some way to make a silhouette with custom sorting in 2D URP?
     
    tonytopper and RemDust like this.
  9. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    167
    Trying to figure this out myself with no luck. Disappointed to learn "Renderer 2D Data" doesn't support it. The example should really mention this clearly.

    I think I switched to the "Renderer 2D Data" renderer for some of the lighting capabilities. Switching back to the "Universal Renderer Data" probably wouldn't work.

    I tried stacking renderers to see if that could make it work; no luck.

    upload_2022-11-10_14-9-46.png

    I definitely have a lot to learn about the rendering pipeline. Feel like I am shooting in the dark. Also noticed differences between ShaderGraph "Sprite Lit" and the included "Sprite-Lit-Default" shader from URP/2D in terms of how they work with the scope of these different renderers.

    Trying to learn more about how this works under the hood. Starting here: https://docs.unity3d.com/Manual/SL-CameraDepthTexture.html
     
  10. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,281
    If you have serious need for depth, like for a Depth of Field effect, you may be better off using standard URP and not the 2D Renderer. There's a depth texture checkbox on the 2D renderer asset, but it won't support certain effects.
     
  11. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    167
    Is there any documentation on what the 2D renderer does and doesn't support regarding the depth texture?
     
  12. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,281
    :( no. You can always read the source code (am doing this right now lol) by searching for Renderer2d.cs in "Packages" within your project. In comparison to UniversalRenderer.cs, it lacks a lot of depth stuff, no opaque pass.
     
  13. tonytopper

    tonytopper

    Joined:
    Jun 25, 2018
    Posts:
    167
    Thanks for the additional insights Lo-renzo.

    So what exactly does "no opaque pass" mean? Does that mean "AfterRenderingOpaques" Event won't trigger? Does that mean Filters using the "Opaque" Queue don't work?

    Just tried: https://learn.unity.com/tutorial/custom-render-passes-with-urp, which is another tutorial published by Unity that shows off the render pass features, but I can't get that one to work either.

    We REALLY need a render pass example that works and uses Renderer 2D Data and preferably a Shader Graph shader.
     
  14. Lo-renzo

    Lo-renzo

    Joined:
    Apr 8, 2018
    Posts:
    1,281
    It does not do a separate pass over your opaque objects. In the UniversalRenderer.cs, it does the typical thing of an opaque pass followed by a transparent pass. In contrast if you put a URP standard Lit shader into a 2D Renderer scene, it won't look correct. It doesn't even generate a depth texture quite right. I think that's a bug. I had to fork the 2D renderer to get _CameraDepthTexture to work. You can check out Renderer2D.cs to see its passes. It's very simple, a few hundred lines.

    The closest thing is a demo of a Kawase Blur pass in the 2D Renderer Samples project: https://github.com/Unity-Technologies/2d-renderer-samples/tree/21.2/Assets/Samples/2D Renderer/01 Feature Samples/09 Renderer Features
     
  15. juicedup

    juicedup

    Joined:
    Aug 18, 2019
    Posts:
    47
    Is this on the roadmap at all or is there no plans to support it?