2D Renderer in Universal Render Pipeline in 2019.3

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: Start Your Creative Projects and Download the Unity Hub | Unity
  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.
    5487339--562797--Universal RP 7.2.1.png

Configuring the 2D Renderer

  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

5487339--562809--UniversalRenderPipeline Asset.png
3. Select the created Pipeline Asset then assign the created 2D Renderer to the first item under General → Renderer List
5487339--562812--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!

1 Like

Samples


If you’d like to see examples of 2D Lights, Pixel Perfect Camera, Post-Processing, Shader Graph and 2D Shadows, download or clone the 2D Renderer samples from:

2 Likes

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?

2 Likes

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 :slight_smile:
Here is a small visual tease.

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/

2 Likes

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.

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.

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?

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.

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

5517673--566569--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

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

I followed every step, but I’m not able to add any 2D light to the scene…

This can happen if you have Universal RP set but have not assigned your UniversalRenderPipelineAsset a 2D Renderer Data asset.

What template did you use? And can I get a video of the inconsistency you are seeing?

We will be supporting camera stacking in the coming months. Hopefully sooner rather than later.

By template, I mean starting a new URP project, ala…
5533432--568687--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.

5533432--568690--2dlightbug.gif

The second gif shows it working AFTER deleting the default pipeline assets.
5533432--568693--2dlightbugpostdelete.gif

1 Like

@Chris_Chu Thank you for responding!

I did assign it…

5536750--569272--Screenshot 2020-02-29 at 22.07.56.png
5536750--569275--Screenshot 2020-02-29 at 22.10.41.png
5536750--569278--Screenshot 2020-02-29 at 22.11.01.png
5536750--569281--Screenshot 2020-02-29 at 22.11.35.png
5536750--569284--Screenshot 2020-02-29 at 22.13.12.png

@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?

I’ll look into this today.

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

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.

1 Like

Is there any plans on supporting SpriteRenderer’s Flip X with normalmaps?