Overlay Camera with Renderer2D on UniversalRenderer not supported anymore?

I’m working on a project with some very specific rendering needs. I’m overlaying a lot of 2D and 3D elements. I’m using the z-buffer to cheat sorting even with a perspective camera.

Basically, I’d like to have access to Unity’s 2D light suite, but I’m using 3D lights for characters and some key objects.

I’d rather not reimplement basically the same thing that already exists in Unity’s 2D lights (light texture), but I’ve found the functionality frustratingly difficult to access when also using 3D lights. Various (unofficial) articles I’ve found have referenced using an overlay camera to achieve this, but it seems that’s not possible in Unity 6. Whenever I use a Renderer2D overlay camera with a UniversalRenderer camera as the base, this is spammed in the logs:

Only cameras with compatible renderer types can be stacked. The camera: Sprite Camera are using the renderer Renderer2D, but the base camera: Main Camera are using UniversalRenderer. Will skip rendering

Basically, is there a way to do what I’m trying to do? I’ve tried various things: even tried setting up a Renderer Feature that uses the relevant ‘Passes,’ but all of them are marked internal. Unless there’s a better way, I’m probably about to the point where I’m going to clone URP and modify some of the code myself.

Yeah I know how it feels because you can’t stack 2D renderers with UniversalRenderer (which handles 3D). Have you tried dual stacking cameras? for example, adding 2 cameras, then rendering 2D elements and 3D elements separately with their own dedicated cameras and then using layered rendering

  • Now be sure to that these cameras render different layers to avoid issues.

Then what you do is:

  • Set the 2D camera to render to RenderTexture.
  • Apply the RenderTexture as a material or overlay on a screen-space canvas or on a quad in the 3D space.

Let me know if this works. In my case, I had a similar issue, and I finished using custom passes via Scriptable Render Features :frowning:

Thanks for your reply. I played around with your suggestion for a bit. It’s not a bad idea, but unfortunately it just doesn’t quite work for me because of layering issues, basically.

I build a ScriptableRendererFeature and added it to the Universal pipeline that I am calling ‘Light2DFeature.’ I had to copy a few hundred lines of code from Renderer2D, but I got it working.

If anyone’s interested, I can share the code, but I will warn that it’s very hacky. Since a lot of things in that assembly are marked ‘internal,’ it needs to use a decent amount of reflection. I understand marking some things internal so you don’t have more APIs to support, but damn, Unity really wanted all of this functionality to be completely inaccessible.

Another dumb thing I had to do is have a camera in the scene at all times in Overlay mode with the Universal2D pipeline selected. The camera isn’t doing anything at all–it’s not rendering, it’s not in stack mode; it’s literally only there to trick Unity into letting me place Light2D’s around the scene.

Anyway, if I was able to get it working within a handful of hours as very much a non-rendering Engineer, then I’m confident an actual employee of Unity could expand support for 2D lighting alongside 3D lighting into the Universal Pipeline. Consider this a feature request :slight_smile:

Enabling the checkbox “Compatibility Mode (Render Graph Disabled)” in Project Settings > Graphics made the 2D Overlay Camera properly render again in Unity 6000.0.32f1 but I believe this solution will not be useful for projects that use the Render Graph API as written in the warning.

Can you show us the code? I have the same problem. Did you use render graph api?