Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Official 2D Renderer in Universal Render Pipeline in 2019.3

Discussion in '2D Experimental Preview' started by rustum, Feb 17, 2020.

Thread Status:
Not open for further replies.
  1. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190
    2D Graphics 2019.3.png With the release of 2019.3 the 2D Renderer is now available in Universal Render Pipeline.

    The 2D Renderer includes:
    • 2D Lights
    • Lit and Unlit Sprite Masternode in Shader Graph
    • Pixel Perfect Camera component
      • As a reminder: This will be the new home for Pixel Perfect Camera. The standalone package will still receive bug fixes, but new features will only be added here.
      • This is the same component with the same workflow as the one in the Pixel Perfect package. The main change is that Pixel Perfect is now compatible with the 2D Renderer in Universal Render Pipeline.
    • Normal map support for all the other 2D renderers:
      • Tilemap Renderer
      • Sprite Shape Renderer; and
      • Sprite Renderers that are deformed by bones.
    • Experimental shadow caster component
    • Post-Processing support

    Getting Started

    Installing Universal RP

    1. Download and install the latest Unity 2019.3 from Unity Hub or here: https://unity3d.com/get-unity/update
    2. Get the Universal Render Pipeline version 7.2.1 or newer from the Package Manager in Unity
    3. Select the package and click Install.
    Universal RP 7.2.1.png

    Configuring the 2D Renderer
    Create 2D Renderer.png
    1. Create a new Pipeline Asset by right clicking in the assets view of the project window, and selecting:
    Create > Rendering > Universal Render Pipeline > Pipeline Asset (Forward Renderer)
    2. Create a new 2D Renderer by right clicking in the assets view of the project window, and selecting:
    Create > Rendering > Universal Render Pipeline > 2D Renderer

    UniversalRenderPipeline Asset.png
    3. Select the created Pipeline Asset then assign the created 2D Renderer to the first item under General -> Renderer List

    Scriptable Render Pipeline Settings.png

    4. In the graphics settings set your Scriptable Render Pipeline Settings to use the created Pipeline Asset

    The 2D Renderer should now be configured.

    Documentation
    Click on the View Documentation link in the Package Manager.

    Upgrading
    If you are installing the package into a Project with pre-existing Prefabs, materials or Scenes, you will need to upgrade any materials used to a lighting compatible Shader. The following functions allow you to do so. Do note that this is a one way process and cannot be reverted.

    Upgrading a Scene
    To upgrade the currently opened Scene, go to:
    Edit > Render Pipeline > Universal Render Pipeline > 2D Renderer > Upgrade Scene To 2D Renderer

    Upgrading a Project
    To upgrade all Prefabs and materials in your Project, go to:
    Edit > Render Pipeline > Universal Render Pipeline > 2D Renderer > Upgrade Project To 2D Renderer

    Improvements
    Here are more details on improvements we've made to the 2D Renderer in Universal Render Pipeline 7.2.0
    • Added Transparency Sort Mode and Transparency Sort Axis (as seen in the built-in render pipeline)
    • Set default material to use when creating new Sprites. This is useful when you have a custom Sprite shader that you want to apply to all new Sprites in your project.
    • Blend Styles in the 2D Renderer Data are now automatically enabled/disabled, depending on whether there are 2D Lights that actually use them.
    • Using the 2D Renderer without lights (e.g.: to use Shader Graph) is now faster than it was. We now recognise that no 2D Lights are present and thus we can render with a faster rendering path.
    Please share your experience with the tools by replying to this post or creating a new one. How does this feature help you achieve your desired outcomes? What works as expected? And what doesn’t? We’re excited to hear back from you!
     
    Last edited: Feb 19, 2020
    CJ_Smith likes this.
  2. rustum

    rustum

    Unity Technologies

    Joined:
    Feb 14, 2015
    Posts:
    190
    Last edited: Feb 20, 2020
    CJ_Smith and Xepherys like this.
  3. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Having separate forum is really cool. Can you fill us about the tilemap support for the shadow casting? When will it be supported? Soft shadow?
     
    Deleted User and elZach like this.
  4. spiderspy

    spiderspy

    Joined:
    Aug 1, 2013
    Posts:
    16
    Hey, cool work on the 2D lights.

    I want to highlight a need to cull light better, since it is not being done well and when I generate a larger scene with lights it still goes through all of the lights in the scene that should be frustrum culled or distance culled at the very least. Can take 8ms in a not too big scene. We do our own culling now on everything but it would be nice if it was not needed for the lights.

    Also want to mention that there are some iffyness when you want to use meshes and bones that are rotated quirky, the normal map stuff uses the rotation a bit weird since it uses the same functions for 3D normal code. I will see if I can get time to share this at some point.

    Would like to take the time and show that we are using it for Source of Madness :)
    Here is a small visual tease.
    https://twitter.com/TheSpiderspy/status/1231269849428635648

    We use the shape light to highlight the entrance to the shop for example, I also made a special light type for the global light that adds and acts as a sort of ambient fog.

    Also we at Carry Castle will be at GDC to speak at the machine learning talk o/
     
    Xepherys and DungDajHjep like this.
  5. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    We'll take a step back and re-evaluate the current 2D shadow workflow, because we think there are some improvements we can make. This means it will take some time before we add any new features related to shadows.
     
  6. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    That's a really nice showcase of the 2D lights!

    What type of custom culling are you doing? I'm interested to understand the use case.

    Also want to learn more about the rotated normal map issue.
     
  7. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    Is it possible to have more than one 2D Renderer Camera in the scene for doing funky blitting stuff? It seems that camera stacking isn't supported (will it do so any time soon?) and trying to grab rendertextures from more than one camera isn't allowed at the moment?
     
  8. spiderspy

    spiderspy

    Joined:
    Aug 1, 2013
    Posts:
    16
    It is not anything fancy, we spawn a lot of prefab/rooms in a big grid, and now we distance cull grid cells based on openings. However we only need to do that because the lights take too long to render when there exist a lot of them in the active scene even if you are not remotely close to them. I think it got to do with how you do the global light but I need to take a look at it again. Preferably it would be nice with some inbuilt culling for the 2D lights like there are for most featuers and other light types.

    The normal map texture you create is affected by rotations that a 2D renderer should not care about so our 2d rendered meshes gets weird artifacts since it is very difficult to import completly clean armature setups into unity. I need to find my documentated images to explain this properly, but in essence we do not get even light distribution on our "2D meshes" because things are rotated and that affects the image you create for the light directions.

    The big issue with the normal is when we stack our objects infront of each other and they get vastly different lighting result because of their different transform matrices.
     
  9. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    I'm getting a lot of inconsistent behavior when trying to add any of the experimental 2D lights to the hierarchy. Sometimes it adds a light, sometimes it doesn't. There are no errors in the console when it doesn't.

    Makes me believe there are some rules or conditions that need to be met that are unclear and uncommunicated.

    Using 2019.3.2f1 with URP package 7.2.1

    Likewise, when I do get a PointLight added to the hierarchy, adding the Light 2D script gives me a warning which I do not agree with since I'm using the 2D renderer data with URP and everything is assigned in the inspector

    2dlightwarning.JPG

    Nuking the default assetPipelines that come with the template seems to clean up the situation. So I'm guessing there's some references that are not being reset when starting a fresh project from a template
     
    Last edited: Feb 24, 2020
  10. spiderspy

    spiderspy

    Joined:
    Aug 1, 2013
    Posts:
    16
    Here you can see the funkyness of the normal map/light render. Snippet taken from a gpu profiling when it "renders" the normal map/lighting map
     

    Attached Files:

  11. porandojin1

    porandojin1

    Joined:
    Aug 5, 2017
    Posts:
    7
    I followed every step, but I'm not able to add any 2D light to the scene...
    upload_2020-2-26_22-54-46.png
     
  12. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    This can happen if you have Universal RP set but have not assigned your UniversalRenderPipelineAsset a 2D Renderer Data asset.
     
  13. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    What template did you use? And can I get a video of the inconsistency you are seeing?
     
  14. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    We will be supporting camera stacking in the coming months. Hopefully sooner rather than later.
     
  15. Livealot

    Livealot

    Joined:
    Sep 2, 2013
    Posts:
    228
    By template, I mean starting a new URP project, ala...
    2dbugtemplate.JPG

    The issue is with both 7.1.8 and 7.2.1, although this time I saw an error in the console. The first gif shows not being able to add a 2d light.

    2dlightbug.gif

    The second gif shows it working AFTER deleting the default pipeline assets.
    2dlightbugpostdelete.gif
     
    Kokowolo likes this.
  16. porandojin1

    porandojin1

    Joined:
    Aug 5, 2017
    Posts:
    7
    @Chris_Chu Thank you for responding!
    I did assign it...
     

    Attached Files:

  17. porandojin1

    porandojin1

    Joined:
    Aug 5, 2017
    Posts:
    7
    @Livealot, I didn't read your previous comment at first, but it solved my problem too! thanks!
    Is deleting those files something we want to do, though?
     
  18. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    I'll look into this today.


    Did you also use the Universal RP template to create your project?
     
  19. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    I looked into this today. Because the Universal RP template assigns its assets in the Quality settings it does not respect the asset in the graphics settings.

    Until we have a template with the 2D renderer I would suggest you use the 2D template instead of the Universal RP template.

    However, if the Universal RP template is your starting point, then I would suggest assigning the 2D Renderer asset to the UniversalRP-HighQuality, UniversalRP-MediumQuality, and UniversalRP-LowQuality assets.

    Or you can assign the new asset in the quality settings.
     
    Last edited: Mar 2, 2020
    CodeRonnie likes this.
  20. _Exerion

    _Exerion

    Joined:
    Dec 3, 2014
    Posts:
    12
    Is there any plans on supporting SpriteRenderer's Flip X with normalmaps?
     
  21. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    Hello! I'm getting garbage generated every frame by the RenderPipelineManager.DoRenderLoop_Internal() call. Closer inspection suggests RenderingUtils.RenderObjectsWithError() is what's allocating the memory, specifically Material.CreateWithShader() further in.

    Any idea what might be causing this to happen? RenderObjectsWithError sounds like something I've set up might be causing this?
     

    Attached Files:

  22. MrPaparoz

    MrPaparoz

    Joined:
    Apr 14, 2018
    Posts:
    157
    That's a very good question. I've been wondering this myself also.
     
  23. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    Hi! I believe this is fixed in the latest version of the URP package. Can you test it again?
     
  24. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    I think we can avoid the allocation for RenderObjectsWithError(). Let me look into it.
     
  25. Unusual-Cadence

    Unusual-Cadence

    Joined:
    Aug 12, 2015
    Posts:
    42
    Thanks! What kind of thing would cause RenderObjectsWithError to call? Anything using the legacy Sprite shader? (Edit: It seems like that's just called with every camera rendering pass, so not ideal that it's just naturally making 0.4kb of GC Alloc every frame.

    I have a couple of extra cameras in the scene (doing some reflection-based rendering shenanigans) that are calling GetCameras() and SortCameras() that's also creating garbage every frame with Array.Sort(). I know it's not much, but the only memory alloc happening every frame in my scenes at the moment is coming from the Universal Render Pipeline and that seems not so good :)

    Edit 2: I did a deep profile of the Lost Crypt demo and interestingly I'm not seeing the GetCameras/SortCameras call making a GC Alloc call there, even though that's pretty much where I cribbed the reflection rendering from, haha! I wonder what I'm doing differently that would cause those functions to behave differently for me?

    Edit 3: Ok! It seems that having one camera rendering and one camera going to a rendertexture creates zero GC Alloc calls, however having three cameras (one rendering, two going to rendertextures) or more is what starts getting Array.Sort(cameras, new CameraDataComparer()); called every frame. Hopefully something simple that can be fixed if you're able to look at this as well!
     

    Attached Files:

    Last edited: Mar 9, 2020
  26. _Exerion

    _Exerion

    Joined:
    Dec 3, 2014
    Posts:
    12
    URP 7.2.1 still not fixed
     
  27. MrPaparoz

    MrPaparoz

    Joined:
    Apr 14, 2018
    Posts:
    157
    I was wondering if are there any roadmap or version target that we should expect it to be use for at least more than experimental reasons?
     
  28. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    I don't think we can promise a version until we get closer to fixing all the issues we want to fix.

    Right now there are a few things keeping this in experimental. There are performance issues we are looking into, also we are missing important features that might make the 2D Renderer feel incomplete or even broken (missing SRP batching, instancing, camera stacking, a way to access the frame buffer, and so on).

    These are currently our priorities so we can leave experimental as soon as possible. I think even after we get the renderer ready for production use, we may leave shadows in experimental.
     
    Last edited: Mar 13, 2020
  29. MrPaparoz

    MrPaparoz

    Joined:
    Apr 14, 2018
    Posts:
    157
    This seems quite bad news. For my opinion, shadows are weakest part currently (other than your list ofcourse). So we can easily say it's targeted after 2019 LTS?
     
  30. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    I'd say that's probably a safe assumption.

    I would agree shadows are the weakest right now as well, which is why there is a lot of work/rework that it needs.
     
  31. MasoInar

    MasoInar

    Joined:
    Feb 20, 2014
    Posts:
    126
    Does anyone else have a problem with a pixel perfect camera, that it 'zooms out' randomly?

    I use pixel perfect camera (experimental) from URP and also Cinemachine and I have set reference resolution to 640x360 (with no any other options checked), and when testing with phone (android), it starts with correct resolution, but quite quickly zooms out.

    I also tried with upscale render texture checked, but it didn't change anything.

    I'm using Unity 2020.1.0b2 and latest URP packages and it doesn't happen in editor. Is there way to 'lock' zoom level or something?
     
  32. Jonathan-Westfall-8Bits

    Jonathan-Westfall-8Bits

    Joined:
    Sep 17, 2013
    Posts:
    271
    I recently started having this issue on PC builds for windows. Got so annoying I took out pixel perfect camera till we find out why it is doing it.
     
  33. zfh2773

    zfh2773

    Joined:
    Nov 16, 2019
    Posts:
    27
    When would I add a similar sprite depth of field effect?
     
    Innocent-Dev likes this.
  34. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    The first problem I think that you'd probably run into with this at the moment is that sprites are completely transparent. As such they don't write into the z-buffer. Additionally, we are missing a depth copy pass.

    It needs both of these so it can use the depth of the pixel to calculate the proper blurring for that pixel.
     
  35. mexicano

    mexicano

    Joined:
    Nov 12, 2013
    Posts:
    23
    Hi, I am doing a pixel art card-based game. I am using the new Unity 2D lights. I have a ScriptableObject for the card's data but I can't swap the light cookie from the unity "2Dlight" script because of its read-only. Any advice?
    I am using the light cookie to display the image of the creature and do highlights.
    is there a way of editing the Unity Script?

     
  36. ratuspro

    ratuspro

    Joined:
    Apr 5, 2015
    Posts:
    17
    Hello all,

    I'm working on a 2D game for WebGL and was wondering if this package fully works on this platform.
    I've been playing with point lights and shadow caster, and they do not seem to work properly.
    The same scene in the editor: upload_2020-3-28_17-33-56.png

    and in WebGL:

    upload_2020-3-28_17-34-16.png

    Seems like the normal map is working but was wondering about shadow. In particular, the casting lightsource is a point light.

    Thanks in advance,
    Diogo
     
  37. NotEvenTrying

    NotEvenTrying

    Joined:
    May 17, 2017
    Posts:
    43
    I'd really like to see this prioritized - I've seen dozens of other people asking for it since 2D renderer was first publicly available, and in my opinion this is far more important than shadows in 2d atm. As it is, high quality, professional games made with 2D renderer are essentially restricted to pixel art games - not having z-write on the sprite shader removes a lot of options like water, depth of field, etc. Even Ori, the game that has been the face of Unity's website for the longest time and still tops the "Made with Unity" chart, is quite literally impossible to recreate with 2D renderer atm, not because of performance issues, shadows or the other aforementioned things, but not being able to have depth based effects.
     
    Lars-Steenhoff and RemDust like this.
  38. NotEvenTrying

    NotEvenTrying

    Joined:
    May 17, 2017
    Posts:
    43
    On another note, I've found it really handy to create "manual" shadows using the 2D lights using a custom subtractive blend style from the 2D pipeline asset, I think including a proper shadow/inverse-light blend style for the 2D pipeline would be an amazing addition, as it gives us complete artistic control over how the shadows look in a scene!
     
  39. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    I feel like this shouldn't need to be read-only. Let me look into this and see if there is a good reason to have this this way.
     
  40. Chris_Chu

    Chris_Chu

    Unity Technologies

    Joined:
    Apr 19, 2018
    Posts:
    257
    Can you file a bug for this?



    I can appreciate what you are saying. However, we really need to leave experimental as soon as we can, and that means improving/stabilizing what we have.

    In the next few months, we are not putting in new features except to fix things that seem inconsistent (like things such as camera stacking).

    This should be in our backlog, and is something I would really like to do as well.
     
    Last edited: Mar 30, 2020
    RemDust, DungDajHjep, sk1zZ and 4 others like this.
  41. MrPaparoz

    MrPaparoz

    Joined:
    Apr 14, 2018
    Posts:
    157
    Will there be a custom falloff distance for shadows aside from Shadow Intensity setting in lights?
     
  42. ratuspro

    ratuspro

    Joined:
    Apr 5, 2015
    Posts:
    17

    There's no need for that.
    I ended up raising the default quality settings to Ultra in WebGL and it started to work.

    Thanks for the reply anyway.
     
    Chris_Chu likes this.
  43. psuong

    psuong

    Joined:
    Jun 11, 2014
    Posts:
    126
    Hello, is there a way to use the 2D Renderer with a scriptable render pass and a graphics command buffer? I'd like to try and draw something additional orthographically in screen space - similar to URP's 3D RenderPasses by just grabbing a commandbuffer and drawing a mesh in the Execute(ScriptableRenderContext ctx, renderingData) function.
     
  44. psuong

    psuong

    Joined:
    Jun 11, 2014
    Posts:
    126
    upload_2020-4-1_23-50-25.png
    Actually I was able to figure it out by just switching the inspector to be on Debug view instead. By any chance will this field be exposed in the future?
     
  45. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    was also wondering about camera stacking for 2drenderer. any eta on this?
     
  46. castor76

    castor76

    Joined:
    Dec 5, 2011
    Posts:
    2,517
    Also, I was wonder how to add emissions to the shader, using shader Graph? The Sprite Lit Master node only has 3 inputs... Adding to the color is not the correct way. We need to be able to add colors after the lighting.
     
  47. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    We will support custom render features in the future. For now we're focusing on improving the performance of the 2D lighting system.
     
    psuong likes this.
  48. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    I'm working on this right this moment. But it's probably going to be a few months before its release.
     
    Ferazel and MasoInar like this.
  49. yuanxing_cai

    yuanxing_cai

    Unity Technologies

    Joined:
    Sep 26, 2014
    Posts:
    335
    This is on our list but it's not our top priority currently.
     
  50. ratuspro

    ratuspro

    Joined:
    Apr 5, 2015
    Posts:
    17
    Hey again,

    I'm trying to use shader graph to create a custom shader for a material on URP.
    I was wondering if I can use the computed lighting anyway?

    Maybe these variables also apply for the 2d Lights. Is that so?

    Thanks
     
Thread Status:
Not open for further replies.