Tell us how you're creating 2D games that include 3D elements

Hello 2D creator folks! :slight_smile:

The 2D Team at Unity is interested in finding out more about your experiences and goals when using the 2D Renderer in URP to develop 2D games that include 3D elements.

Important Note:
For this exercise, we want to focus on 2D games developed using the 2D Renderer in URP. If you are not using the 2D Renderer or have another question to ask please start a new thread. Thank you for your kind understanding!

Here are some questions to get this discussion started:

  • What kind of game are you making? What perspective, genre and art style?
  • What are your expectations when importing 3D objects into your 2D project/scene?
  • Which URP features are required for the 3D objects in your game? How are they used?
  • Which 2D lighting features are required for the 3D objects in your game? How are they used?
  • Which 3D lighting features are required for the 2D objects in your game? How are they used?
  • Do you use a perspective camera in your game? If so, could you elaborate on your reasons?
  • Do you use camera stacking in your game? If so, how is it used?
  • Describe how you would like to construct a scene that has both 3D (with volume) and 2D (flat) assets?

What else would you like us to know about your experiences and goals when adding 3D elements to your 2D games?

If you would rather answer these questions in private, please feel free to DM me.

We’re looking forward to hearing from all of you!

3 Likes

I was about to start a project and was actually not sure if the 2D Renderer can handle 3D objects, so I went with the normal URP renderer. But I guess I could give you some feedback on what I was planning to do.

  • What kind of game are you making? What perspective, genre and art style?

Sidescroller like Mario, but with 3D objects in the background. Orthographic perspective, but was thinking about switching to perspective for that effect Paper Mario has. The art style is mainly pixel art, with geometric 3D shapes in the background.

  • What are your expectations when importing 3D objects into your 2D project/scene?

I’d like to be able to use them exactly like I use 2D Sprites. For Sprites it’s usually enough to drag them into the project and set the filter, PPU and compression. With 3D objects this becomes a bit of a hassle, since Blender for example uses a different coordinate system, so by default objects are always rotated when dragged into the scene.
I’d love if there was a universal setting where you can actually choose the 3D modeling software you’re using and that’s setting the import settings in a way that makes the entire process drag & drop. So like a dropdown in the project settings or preferences with Blender, 3DS Max, Maya etc. - and when I choose Blender, and then drag in files from Blender, they just work right off the bat, without having to change anything.

  • Which URP features are required for the 3D objects in your game? How are they used?
  • Which 2D lighting features are required for the 3D objects in your game? How are they used?
  • Which 3D lighting features are required for the 2D objects in your game? How are they used?

Shader Graph and I guess 2D Lights? I’m not sure how exactly they should be used, since the objects are 3D and I couldn’t get 2D Lights to work properly, so I went back to the normal 3D Lighting. There’s one Directional Light and a lot of Point Lights to illuminate both background objects and sprites. It’s really hard to say what I’m expecting, since there’s no clear guideline on how to get 2D and 3D objects to work with Lighting together.

I think I’d rather give feedback that there’s a lack of clear tutorials or information in general on how to set this up. Until I saw this thread, I was convinced that the 2D Renderer meant that I’m now constrained to using Sprites only. Which made sense in the beginning, but the more I’ve tried to work with it, situations where I needed 3D objects came up again and again. In a lot of cases it’s way easier to have a 3D object and rotate or animate that, instead of re-drawing a sprite from dozens of different perspectives. So in my opinion it’s essential to be able to mix the two. But the current information makes it seem like using the 2D keeps me from having anything 3D in my scenes.

  • Do you use a perspective camera in your game? If so, could you elaborate on your reasons?

Sometimes, yes. As mentioned, I’d like to create that Paper Mario effect where 2D Sprites run around in a 3D world. Currently I’m actually using Quads to render the Sprites. But in some levels I’m planning on switching between orthographic and perspective, like in Super Paper Mario:

I can’t tell you what I’d like the solution to be though. In my mind I’d want to use the 2D Renderer and its features (mainly 2D Lights) when in orthographic mode, but switch to a 3D Renderer in perspective mode. If there was a way of using only the 2D Renderer for both, that would be ideal. Although I’m not sure how that would work on the engine side.

  • Do you use camera stacking in your game? If so, how is it used?

No. Actually didn’t know URP had this yet, but might consider it if it’s needed. No plans though.

  • Describe how you would like to construct a scene that has both 3D (with volume) and 2D (flat) assets?

I think I already described this in the other answers. But in short the main application would be - 2D for most interactable objects, but 3D for backgrounds. Mainly for rotation and animation, since they are much easier to do in 3D.

1 Like

I used to work on a purely 2d game that eventuall became 3d (example) with some interesting implementation choices.

What kind of game are you making? What perspective, genre and art style?
This is a top down game that used to be purely 2D, its perspective was about 60 ish degrees kind of top down perspective, and its style/feel was to be a fast paced arcade rogue like shooter. So a lot of importance was in clarity but also enticing visuals at the same time.

What are your expectations when importing 3D objects into your 2D project/scene?
Not sure what this question means or trying to get at. I guess my expectation was that if I added a 3d model into a 2d game it then it should appear given there are 3d lights are present to illuminate it.

Which URP features are required for the 3D objects in your game? How are they used?
I used render textures frequently because I wasnt familiar with srps way of implement fullscreen image effects. This is specifically for adding lighting in underground areas like here by rendering the light layer as a black and white low res texture on top of the original render texture using a shader/material. So the only required feature would be how to make fullscreen image effects (which I know is possible I just couldnt be bothered to sift through different contradicting guides online).

One feature I really wanted was for sprite renderers to be lit from both sides by a 3d light, because of this I had to have 2 sprite renderes facing each way so that one casts and shadow and the other is lit from the camera’s POV. This is because the shadows should appear close to you, which would mean that the directional light needs to be pointing downwards and towards the bottom of the screen. Which results in sprite renderers not being lit. I didn’t want to make them unlit either cause then I lose the whole purpose of being able to use lighting in game (like point lights in underground areas)

Which 2D lighting features are required for the 3D objects in your game? How are they used?
At that time, 2d lighting as it is right now didnt exist.

Which 3D lighting features are required for the 2D objects in your game? How are they used?
When the game transitioned to 3d I removed the old approach for my lights and started using the usual 3d components for lighting. This includes directional lights and point lights.

Do you use a perspective camera in your game? If so, could you elaborate on your reasons?
Yes and no. The game atm lets you switch perspectives on a whim. This is because it was easier to make the game for 3d since there game’s features work well with those (jumping, arcing projectiles, elevation), so might as well use 3d tooling. But from a completely 2d game’s perspective, I see a very good reason to use a perspective camera, since it allows for free parallaxing as a result of a 3d projection and also intuitive depth management (since its all just regular 3d workflow). Theres also the usual ā€œthe game is 2d so use an ortho cameraā€ argument which is just using the more fitting camera setup for the setup (a very empty reason imo, but an easy decision to make).

Do you use camera stacking in your game? If so, how is it used?
Before the camera used to render 2 cameras, one for the game itself that is downscaled then upscaled to keep that pixel art look, then a 2nd for the lights. When I switched to 3d i could ditch those two which is great cause less cameras proves more efficient and simpler to work with in this game. Described more here. I also had a UI camera that was an overlay on top of the game camera, theres no real valid reason for this imo, it just adds to the overhead and going back I’d use one camera for everything instead.

Describe how you would like to construct a scene that has both 3D (with volume) and 2D (flat) assets?
In the future, if a game ever could have 3d elements, ill just make it 3d because its a lot easier to make a 3d game look 2d (from experience). This is what im doing at work as well.

1 Like

What kind of game are you making? What perspective, genre and art style?
We’re making Teslagrad 2. It’s similar to Teslagrad, which has a Steam page here. Both we and Unity have evolved a lot in the years between it released in 2013 and now, so imagine that everything is cooler and higher fidelity, but the perspective (side-on with perspective camera) genre (2D puzzle-platformer) and art style (handdrawnish) are the same.
To note things we are not making, we’re not doing pixelart at all, so things like the pixel perfect camera etc. is not interesting for us. We’re also using spritesheet animations for all the characters instead of any kind of 2D animation.

What are your expectations when importing 3D objects into your 2D project/scene?
That they should work! We’re using them to create depth in the scene, so all the 2D features should handle them.

And, well, they do?
Which URP features are required for the 3D objects in your game? How are they used?
Which 2D lighting features are required for the 3D objects in your game? How are they used?
Which 3D lighting features are required for the 2D objects in your game? How are they used?
Our setup is using 2D lights. In order to have them interact well with 3D objects, we use Sprite-Lit-Default for the 3D object’s material. That works well, except for the snag that we can’t set the sorting layer on the 3D objects from the UI, so we had to add a script in order to expose setting renderer.sortingLayerName in the UI.

Do you use a perspective camera in your game? If so, could you elaborate on your reasons?
The art style requires it. We’re not big fans of how orto cameras look, even in very simple 2D games.

It’s all about the parallax. Adding parallax scripts like in a snes 2D game is a lot more work than just setting the z-depth of objects. Things pretty much automatically look better if you’ve got that in, so I guess a bigger question is why you would ever use an orto camera? Maybe if you’re doing a very hard retro appeal?

Do you use camera stacking in your game? If so, how is it used?
There’s some camera effects that involve a camera filming a specific layer, writing that to a render texture, downsampling that, and placing it on an overlay canvas. So, uh, ā€œscreen space effectsā€?

Describe how you would like to construct a scene that has both 3D (with volume) and 2D (flat) assets?
I don’t think there’s anything really complicated in there. I want to put the 3D elements in there next to the 2D elements and have that function reasonably.

Features that would be nice would be stuff like;

  • If we’re using 2D lighting, then adding 3D objects to the scene should have them on Sprite-Default-Lit, or some other default material that supports 2D lighting, instead of URP/Lit, which does not. This already works for sprites.
  • If we add an EdgeCollider2D or a PolygonCollider2D to a 3D object, it should do a reasonable job of trying to match the outline of the object. It’s fine if that’s done in an ortographic way, but now we have to do it completely manually. BoxCollider2D works, I guess because it’s really easy to just grab the bounds.
  • Clearer docs on how this is supposed to work! Right now slapping a 2D shader on a MeshRenderer and then fiddling with hidden values makes things ā€œjust workā€, but the docs is very clear that these features should not function, so that is a bit worrying.
  • The requirement for things to be coplanar is a bit iffy. We have some background SpriteRenderers that we rotate, but in those cases we have to make sure that they’re not hit by any point lights that hit anything else, as the lights assumes either ortographic camera or no rotation on elements.
3 Likes
  • What kind of game are you making? What perspective, genre and art style?
  • What are your expectations when importing 3D objects into your 2D project/scene?
  • Which URP features are required for the 3D objects in your game? How are they used?
  • Which 2D lighting features are required for the 3D objects in your game? How are they used?
  • Which 3D lighting features are required for the 2D objects in your game? How are they used?

Right now I’m making a platformer with realistic sprites and 3D characters (for many reasons). I’m using built-in rendering and custom sprite shaders with 3D light support. I’d love to use URP features like Sprite Normal Mapping, but 2D lighting in URP doesn’t support 3D models in any way.

  • Do you use a perspective camera in your game? If so, could you elaborate on your reasons?
  • Do you use camera stacking in your game? If so, how is it used?

Right, perspective camera, because no built-in parallax scrolling in unity.

  • Describe how you would like to construct a scene that has both 3D (with volume) and 2D (flat) assets?

Just place them in the scene, that’s all.

1 Like

a quation about using the perspective camera, yes I use it to make sure everything looks the way it should

1 Like

Hi folks! I just want to say I appreciate all the detail that has gone into these responses. :slight_smile: Keep 'em coming! We’re reading them carefully and may have some follow-up questions for some of you soon.

Yes thank you for all of the responses! They are super helpful!

Just curious as to what prompted this decision because you make these really great looking pixel art games. So I’m wondering if there were any blocking production reasons that made you switch to 3D?

This is interesting too. Do you happen to have a screenshot of sorts to help us understand this use case fully? Thank you!

Thank you!
the game emphasised 3 dimensions, yet it was portrayed as a 2d game, and one of the gameplay features was to be able to jump (including over obstacles), as well as toss projectiles over walls. to showcase this more with my game I had shadows and I wanted them to look as youd expect shadows to look in a 2d game (with some artistic stylizing as well). with sprite renderers and the default sprite shader alone, this meant that I had to eventually start using masks everwhere to prevent certain renderers rendering over other renderers that are considered elevated or on top of another. I eventually decided that this wasnt worth the hassle of setting up, because I preferred the ā€œdefaultā€ approach, and working with masks and plenty of code to get it work wasnt default to me. so i made the switch to 3D because it fit what I wanted more, it did exactly what I wanted it to and it was easier to fake a 3D game to look like a 2D game.

In 3D then, you can see how the sprite would only be visible from the cameras point of view, but not from the directional light (the character is using a custom shader that I wrote). If i were to use the provided lit shader, I’d have to modify it to render both faces, but then the other side of the renderer wouldnt be lit. If the light direction was from the other side, then the sprite renderer would be fully lit, but the shadow would cast the other way (to solve this I had to use 2 separate lights, one for lighting the sprites and the other for casting the shadow). I also had underground areas so I had to account for that too.
8038463--1036856--upload_2022-4-11_11-3-12.png8038463--1036862--upload_2022-4-11_11-7-36.png

2 Likes

I personally sometimes put a camera, and sometimes not, it depends on how much it takes to render the characters and their quality in order to load less RAM.

1 Like

Thank you @print_helloworld for the details!

I see what you mean now. And even switching to 3D, to make it look like a 2D game, there were still workarounds needed because 3D Lights only light the Sprite Renderer from one side.

Because of this, you either had to (1) create two 3D Lights - one for lighting the Sprite and one for casting the shadows (in the right direction) because even with a bi-directionally-lit custom Shader, the shadows would still get projected on the wrong side as seen on your screenshot on the left.

Either that, or (2) to create 2 Sprite Renderers facing each way (one facing the camera, the other facing the other) so that one casts the shadow and the other gets lit from the camera’s POV. Though I’m guessing this would require the Sprites to be symmetrical in order for the shadows to look correct too. Is that true?

Also this is also an interesting point you brought up too. Do you happen to have a screenshot of this? Just to be sure we understood the issue correctly. Thank you!

1 Like

That’s so interesting thread

I am not currently using the 2d renderer, but would consider it if it met my needs.

Both 2d orthographic and mixed 2d and 3d scenes.

milkyremarkablekakarikis

I would prefer that 3d objects not be handled any differently by default. I mix 2d and 3d in a single project.

I use ā€˜render object,’ as well as depthnormals and outlines. These are mostly used for custom layering, masking or stylized lighting, other than outlines which is used for… outlines.

I use shadergraph for the usual shader-making reasons.

Ideally, being able to light ā€˜the 3d object from the perspective of the camera’ as if it were a sprite, to make the lighting consistent between 2d and 3d objects when using 2d lighting. Both in terms of receiving lights and using the screen-space outline to cast 2d shadows.

Allowing the screen depth of a 3d object to affect 3d shadows would be nice.

It would be great to make masking 3d objects as simple as it is to mask sprites.

While not exactly lighting, it would be nice for the rendering layer to be exposed on mesh renderers- you can edit it via script already and it is useful in 3d. For instance, I use it to mix procedurally generated meshes with sprite mechanisms such as the chains and wheels of a bike which are meshes that are meant to look 2d.

Proper tangents on sprite meshes. This has been a total thorn in 2d users’ sides from the beginning of sprites in Unity, and the single thing that would make me more interested in the 2d renderer. Of course, ideally this would be done for regular URP and BIRP as well, just because there is no reason I can imagine to not have proper tangents on sprite meshes. It makes making custom lit sprite shaders a real pain.

Generally speaking, sprites, spriteshapes, and rigged sprites responding to 3d lighting even when rotated.

It would be really nice for the rigged sprite editor to be able to export 3d meshes with 3d bones rather than sprites, the way that Anima2d(which the 2d rigging package was based one) did. This would allow for better integration between 2d and 3d in some cases, as well as allowing for exporting unity rigged sprites into 3d software for texture baking and the like.

I use a perspective camera sometimes, to allow for proper environmental perspective.

I do not yet, because it was introduced after I made my own solution. I would definitely consider using it in the future.

I would like to build to be able to set an arbitrary 2d plane.

Sprite shape splines allowing 3d positions for nodes would be useful.

Overall, I like the ability to just treat 2d objects as flat 3d objects and don’t want to move away from that paradigm. It is one of the best reasons to use Unity rather than a few of the other 2d engines.

I dislike the decision to make a separate 2d renderer, which feels like it will inevitably lead to the renderers drifting apart in features and support(no offense, but this has already happened with Unity and render pipelines multiple times), as well as making it even harder to deal with assets authored for any given renderer. There currently isn’t much value in the 2d renderer for me, since I don’t think that the 2d lighting is enough to justify breaking my existing projects.

I am still not sure what there is under the hood that requires splitting off a separate renderer, but I am willing to accept that there might be technical reasons to require the branch rather than using renderer features for 2d lighting, etc. I look forward to seeing how it develops, in any case.

1 Like

The 2D pipeline should support opaque + depth textures. I tried switching from URP to the 2D renderer, but it broke a water shade I made.
When I’m using the URP renderer the pixel-perfect camera doesn’t work

This leaves me in a situation where no matter what renderer I use, I either lose the ability to make a water shader or to have pixel-perfect graphics. Both are things that feel like they should be supported by both render pipelines.

2 Likes

I hadn’t realized that they had done this. Absolutely maddening- and a good example of the sort of stuff I’m worried about in splitting off a separate renderer.

1 Like
  • Which 3D lighting features are required for the 2D objects in your game? How are they used?

Directional lighting. Sun etc.

The one thing missing that anyone can notice right away, and also quickly gets pushed/lost into the many unanswered questions. Its the option to draw multiple sprites into one single sprite ( draw ). Game maker studio has the ā€œsurfacesā€, even godot with their clunky tileSets have the ā€œviewPortā€ option…

Unity has the ussually deities / divinities of intellectuality in one post, about the subject, argumenting why this a good or a bad thing.

3 Likes

I was about to start a project and was actually not sure if the 2D Renderer can handle 3D objects, so thanks for the update and the information

Isn’t RenderTexture similar to Godot’s Viewport? https://docs.unity3d.com/Manual/class-RenderTexture.html

EDIT: Nevermind, it’s nowhere near the usability of Godot’s Viewport.

2D Renderer can be added to a 3D object. All 2d is being draw on a 3D plane… ( dont blame be for changing the post subject :smile:)
I mentioned the option to render multiple sprites into one image. I havent found anything that could to this, except maybe make the 2d draw calls in a script.