What are the pros and cons of the 2D Renderer compared to the generic Universal Renderer?

I was wondering if there’s a breakdown of the pros and cons of the 2D Renderer compared to the different rendering paths provided by the Universal Renderer (Forward, Forward+, and Deferred). E.g. what are the limits on lights? My guess is the 2D Renderer has additional optimizations for better 2D-specific performance but this isn’t really spelled out anywhere that I could find.

The documentation also refers to the 2D Renderer as an experimental feature in at least one spot but it seems like the feature has been around for a long time. Is it generally considered production-ready?

2D Lights are production-ready and no longer experimental for quite a few versions.

The main reason to use the 2D Renderer is for 2D Lights and shadows. They’re faster than general URP for the specialty case of 2D lighting, but it’s not superior for every game type and case.

These lights integrate, for better and worse, with Sorting Layers. This fits most 2D games nicely. People can have performance problems, mostly from not understanding that 2D lights can overdraw, or from mismanaging their Sorting Layers creating many additional batches. There is an option on the 2D Renderer to reduce the Light Texture size which can greatly speed things up without noticeable visual loss.

A key point to understand is that 2D lights are painted in screenspace on top of everything. They don’t have knowledge of what objects are in front of or behind other objects and vice versa. The Frame Debugger will show you that the 2D Light Texture stage happens before any in-scene objects are drawn. This is important!

So if you have a top-down Rimworld-like game, then unless you’re doing something special (masking, layers, special light shapes) they will bleed through the walls. Likewise you couldn’t mimic Rimworld shadows with the built-in shadow system performantly; it’s not for that.

They were mostly developed wtih platformer (side view), or 2D top-down. You could make an Ori and the Blind Forest like game but not its sequel (due to 3D objects - you can’t combine w/ 3D objects well). They could theoretically be used for an isometric game but there are style constraints here and shadows won’t work exactly. Other styles of games, like Graveyard Digger, will not work; there is no individual light data passed to your shaders, just the Light Textures.

If you’re doing some kind of 2.5D game then perhaps URP is superior for you, especially if you can get away with opaque materials for your sprites - which probably means you have a pixelated-style game. I have a 2.5D isometric game using the 2D Renderer using 4 Sorting Layers; I hand-draw shadows so there’s not much of an issue.

If you want the 2D lights but don’t like the 2D Renderer’s lights the next best option is Smart Lights 2D on the asset store which imo is best asset of its class and has some additional options for masking lights.

All in all, try to create a vertical slice of what you want your game to look like. See if the 2D Renderer can make it work. If not, you’ll then face the choice of a custom solution, or changing your game’s visuals to better fit what it’s capable of.

As for performance considerations, it’s probably not too much of a concern either way unless you’ll have a lot of objects or many transparent layers. But transparent overdraw causes performance problems for reasons independent of the 2D Renderer. There’s no limit on the number of lights aside from the cost of drawing many lights in the Light Texture generation phase (see Frame Debugger).

2 Likes

You may also want to examine some of the official demos and case studies:

  1. Lost Crypt
  2. Dragon Crashers [also]
  3. Happy Harvest
  4. Case study: Tails of Iron by Odd Bug Studio
1 Like

Thank you for the insight, Lo-renzo! I really appreciate the detailed info and examples.

In my case I have side view game with no shadows so it sounds like I shouldn’t have any problems. Thanks for the tips on Sorting Layers and Light Texture size. I’ll need to make sure I’m using those appropriately.

It’s great to hear there’s no limit on the number of lights!

1 Like