Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I've implemented basic 3D functionality and made little "2.5D" demo in orthographic projection using OpenGL ES 2 and Box2D.

Now I want to make completely two-dimensional game (using sprites) and consider 2 variants:

  1. Implement 2D graphics separately from 3D in separate layer, leave 3D stuff in background, draw 2D using various simplified algorithms (disable depth testing, simplified culling etc.)
  2. Leave everything as is and use billboards for sprites

Currently I use hierarchical system of entities with matrix transformations. I know about computational complexity of 3D and 2D graphics and believe first method should result in faster code, though it's my first engine and my google-fu fails me this time, so I'm not sure about it.

Engine is Desktop/Mobile.

What method would you recommend? Does implementing first method worth it (in performance aspect)? Is there any engines that went first way?

P.S. If you have any books to suggest where this question is answered, or just good game engine design books - please leave info about it in comment or answer :)

Thank you!

share|improve this question
    
Just as a side note, usually 2D is draw to screen coordinates (x and y) so there is no real need for depth testing. You would just draw your sprites in the same way as you create a game menu in a 3D game. –  Benjamin Danger Johnson May 30 '13 at 16:37

1 Answer 1

up vote 0 down vote accepted

Implementing 2D as 3D objects can have benefits when you want to mix the two (a 2D interface floating in 3D space, like Dead Space for example).

In the approach I would recommend you will have a 3D object that is the root of a 2D hierarchy. Use traditional 2D rendering to an off-screen buffer for all objects below that root, then use that as a texture for the 3D object (billboarded or not). You can have as many roots as you want (usually just 1 in a pure 2D game).

The problem is that 2D rendering typically works pretty differently to 3D in non-trivial cases. Render order becomes more important and trying to sort polygons in traditional ways for 3D games tends to not work super well for lots of 2D billboards. Using explicit depth layers is faster, easier, and will be more correct in the general case. The "faster" bit is probably not as important for you as you seem to think, though it'll become relevant at truly large numbers of sprites.

So far as engines, most do it your first way as they use an entirely separate library like Scaleform for all of their 2D rendering. Others, like Unity, have libraries to "optimize" some forms of 2D by rendering them separately (and doing various bits of geometry batching and depth ordering) though by default usually just uses the 3D pipeline straight up with a specialized orthographic camera setup.

In short, I would recommend to have both scene types, but make sure you can render either view to a texture so it can be rendered into the other scene type.

share|improve this answer
    
Yes, exactly what I need. Why didn't I thought about that solution. Thank you :) –  Zhur Jun 1 '13 at 7:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.