- Home /
Isometric game: 2D background mixing with 3D models
Hi there.
We're developing an isometric game for the iPhone.
Graphically the game will have a 2D static background (carefully drawn to match the camera angle), a number of 2D static objects (trees, columns, etc) and 3D dynamic objects moving around between the static objects.
The problem: make sure our dynamic 3D objects are shown properly behind or in front of the static objects.
I see a few possible solutions:
1) Put each static object into a billboard (plane?). Either place these by hand or by having some python script work thru the background image.
2) Render dynamic objects as 2D sprites. Draw bg and all sprites in order of the screen y coordinate of footpoint.
3) Use some "magic" pixel shader on all dynamic object to make sure each pixel is either occluded or shown.
Is there an easier / faster method? What will be the easier? What will be faster?
Cheers, Jesper Rasmussen
using planes for your static pre-rendered or drawn background is the most common (and easy) way of doing this.
Answer by Jessy · Jan 17, 2011 at 02:09 PM
For iOS, your best bet is probably to use a non-alpha testing shader, render all of your 2D dynamic objects after 3D dynamic objects, and employ your own sorting method so that they render back-to-front. You can use Shader.renderQueue to do that dynamically. I say "for iOS" because alpha testing on the POWERVR GPUs is slow.
If you don't want to do that, you can use a combination alpha testing/blending shader, or just an alpha testing shader. Be aware that they tried to foolproof alpha testing on iOS, so your darkest greys will get cut off just slightly faster than you would anticipate; you'll have to apply a Curves line, where 0 = .01 (i.e. 3 if we're talking 0-255), and 1 = 1, for your alpha. AlphaTest Greater 0 isn't recognized in Unity iOS anymore. >:-(
Answer by Jesper Rasmussen · Jan 25, 2011 at 02:19 PM
Thanks for your answer Jessy.
I think I get your shader idea ... I would have to use the z-buffer to mix in the 2d with the 3d objects, right? Guess I have to study shader magic first to fully understand it :o)
I just had another idea: maybe one could set the Shader.renderQueue for all object based on the screen.y position of their footpoint. In that way alle objects (2d or 3d) would get rendered in the right order.
Would this work?
Cheers, Jesper
Your answer
Follow this Question
Related Questions
3D Isometric Grid Based System, a feast of questions; 1 Answer
UDP app signature? 1 Answer
Isometric projectile collision 2D or 3D? 0 Answers
2D Battle System In a 3D Game 3 Answers
2D Shadows? 3 Answers