Best method of mixing 2D and 3D?

I'm thinking of using 3D environments as backgrounds for an otherwise 2D game, so I've looked into ways of mixing 2D and 3D. There seem to be three ways to do this, but I don't know what the tradeoffs between them are.

The ways that I've found are:

  • The environment is a 3D scene and the 2D scene is rendered into a texture, which is then mapped onto an object in the world. This can be seen in the "2D in 3D" demo. It seems that this is best if the game is primarily 3D but you want to render 2D things onto objects in the 3D world, or at least if the 3D camera doesn't move, so its probably not what I want.

  • The environment is a 2D scene and the 3D scene is rendered into a texture, displayed as a sprite. This can be seen in the "3D in 2D" demo. This has the opposite camera issue in that the 3D scene is positioned in 2D space, so if the 2D camera moves, the 3D scene changes position of where its rendered, but this could easily be fixed for my purposes by positioning the 3D scene relative to the player.

  • The 2D scene is rendered into a different viewport, which is overlaid above the 3D scene. Now they are decoupled and both on screen together, with their own independent cameras.

I assume that, for my purposes, the third option is exactly what I want, but I would like to hear if there are any other tradeoffs or considerations besides those mentioned above.

Posted Mar 15, 2018, 8:22 PM UTC

84
snowflakestudios•

I'm currently developing a game that is like a traditional 2d rpg, but with some 3d objects.

So for each 3d object I have a 3d scene/camera that gets rendered to a Sprite in the 2d game world.

The biggest issue I have come across is writing the code to create a proper collision shape that changes as the 3d model is rotated. It was doable, but difficult to do in a clean way. Most of the issues were of this type--syncing the 3d model with the 2d scene in various ways. Luckily, I won't have too many types of these objects so it's a problem I've been mostly been able to move past.

Additionally , I had an issue where too big of one of these 3d texture sprites caused slowdown, so I'm not sure how viable a large 3d background rendered to a Sprite is.

My recommendation is that if there is a lot of interaction with the 3d shapes you keep the game in 3d and use 3dsprites or something.

2
guywithknifeOP•

Thanks very much for your insights! Very useful to hear about your experience, I hadn't considered the issue of creating collision shapes.

For my use case, this isn't an issue and I think I will only ever have one 3D scene rendered at one time, so I think the viewport overlay is most appropriate, but of course I want to hear people's thoughts before I make the call. You're experience with "3D in 2D" has been helpful, so thanks again!

Would you say that one large 3d sprite is worse performance than many small ones? Is it more the size of the texture or the complexity/size of the 3d scene being rendered? Just trying to get a feel for the performance implications.

1
snowflakestudios•

I don't have an answer to that. It could have been any Sprite of that size would cause slow down--it was very big. But if you're going to create a background with this method it would probably be a good idea to whip up a quick stress test.

1
MinRawsProgrammer @steincodes•

I concur with the idea of 2D viewport use, I haven't used the texture technique though. But rendering a scene on a Sprite will be more stress full based on the pixels it has to render so big objects are bad, but large number of small objects is something I am not exactly sure about.

1