Orthographic always better for 2D?

Hey all-

currently working on a 2D project and using a normal style camera, and so far everything is working fine. However I would prefer to set things up so that there was a 1:1 mapping of the images. I have seen the references on how to do that with an orthographic camera. I also understand all perspective is removed from this style, so normal style parallax which would easily work in a standard camera is removed. I figure I could fake it by moving background and foreground layers according to camera position, however is this worth it? Does the 1:1 mapping look significantly better?

If anyone with experience in the matter could offer some pros and cons, or advice, before I go and change my whole project it would be greatly appreciated. Thanks!

Anybody?

I have a very early prototype where I use a non-orthographic camera to achieve parallax scrolling. To get my sprites (near) pixel-perfect, I first put a cube at the position where I would want a sprite, press play, take a screenshot, and then make a texture of the exact same size as the cube is in the screenshot. If you then apply the texture to the cube (or a plane, or a spritemanager sprite, I hadn’t gotten that far yet, it will almost be pixel-perfect. I say almost, since sometimes I lost a few pixels depending on the camera position, but it was pretty good.

But using an ortho-camera and moving the layers will work too, off course. I don’t think there would be much if any difference in performance, but I’m no expert.

if orthographic is better highly depends on the game.
there are cases where it clearly is as you can position all objects independent on the depth the same way (important for multiple scrolling parallax layers and alike) but there are also cases (for example in 2.5d ie isometric) where both is an option

Really no difference most of the time.

I prefer perspective cameras, but I’m also scaling/rotating/animating my 2d elements like crazy. If I were trying to make something pixel perfect I would probably go orthographic, but I’m fine with my assets getting a little filtering, the effect is invisible with my art style.

perhaps its my stupid day but don’t see how rotating etc implies any camera type, as perspective camera impacts the rendering in the depth, not transformation applied to objects at a specific depth or image animation

Personally, I’m pretty sure I’ll always use 3D cameras for 2D games. The reason being that the miniscule amount of “glittering” that you would see on sprites in a 3D world is negligible compared to the extra game power this offers you - automatic parallax, possiblilty of 3D scene objects or backgrounds and a bit more freedom when it comes to level design (multiple distance depths to the 2D world as opposed to a single plane. Obviously you can get around this, but using a 3D camera, there’s less of a need to.

Also, there are other ways to make sure you retain visual integrity when you’re doing games with 2D characters in 3D:

  • Make sure the sprites are billboarded (always facing the camera). That way, you’ll get no distortion of the images.

  • Calculate the view distance from the camera so that you get a 1:1 pixel ratio with the original texture. I can’t remember the way to do this exactly, but dreamora put up a very succinct and effective equation for this in another thread.

Based on that, unless you’re actually trying to do something which looks identical to an old 2D game, there’s no reason not to use a 3D camera, IMHO. :slight_smile:

don’t get the automatic parallax part.
flat is flat and UV transform is uv transform. both are not the slightest bit related to orthographic or perspective cam

as you see in the orthographic cam settings thread, its automatic with ortho cams too and the script is as dead simple as it can be and uses the sprite manager

perhaps I’m wrong but it seems like there is a serious missunderstanding around what ortho cams do and what perspective cams do.

basically perspective cams project the whole world onto a single point (cam) while ortho cams project it parallel on a plane. this means that the only things that are actually affected by it are things with different z coordinate (relative to cam) and things that are not in planes perpendicular to the cam (-> billboard) and naturally 3d objects with real depth

if you have everything in a single plane + billboard you are really just wasting performance with perspective transformations of each single object.

Hi Dreamora-

Can you expound a bit on wasting performance with perspective transformations? I am currently shooting for three layers of parallax here, and while it does come “automatically” when using a perpsective camera with everything aligned in the XY plane with different Z depths, I just don’t like that for whatever reason.

When I switch to an orthographic camera, I do lose the innate parallax of the perspective camera. Everything just stays where it was placed and that’s it, regardless of depth. What I read above seems to insinuate that it should still be automatic? I haven’t done it yet but it should be pretty easy to script slightly altering the position of the layers relative to the main layer, however then I know I’m wasting cycles on code that positions objects. I’m the kind of person that likes to make things as small and tight as possible and will obsess over minute details for better or worse. I am just getting to grips with Unity but it seems pretty good so far.

So do you actually gain performance by using an ortho camera over the perspective version? It seems like having everything “flat” with an ortho camera, and then moving around the layers would be more elegant than trying to place things with depth and line them up to the proper size and distance so they look right. But I just want to start it off right and use the approach that will be the most efficient in the end and give me the most FPS, not which will be the easiest necessarily.

Thanks for any advice you can offer.

An orthographic camera does not require to do perspective transformation to “skew” models in shape (or math wise, its an identity matrix), while a perspective camera needs to do so. that means that you basically add another 4x4 * 4x4 matrix multiplication per transform to get nothing from it.
but the lose on that end is actually pretty low and shouldn’t make a feelable difference unless you have many objects or polys

perhaps we don’t think of the same thing as parallax.
parallax is movement of the background from one side to the other or just in a direction.
Don’t see how you would get that from perspective cameras without having UV animation. I’ve provided code using the sprite manager that offers exactly that and that in a pixel perfect way, allowing you to define the scrolling on a pixel per second base.

Or are you talking just of the fact that you can have multiple layers one behind the other, if so then thats possible with orthographic cams just as well, with the difference that the layers remain pixel perfect.

If not done much performance comparisions as I prefer / require the pixel perfect positioning of the objects instead of blind guessing.

Not to pick nits, but this is not parallax… it is simply scrolling. Parallax scrolling, by definition, requires multiple background layers moving at different speeds. Hence, the parallax effect.

And if there is an easy way to do parallax with the orthographic camera, I’d love to know what it is!

I’ll work on a solution and post it if I make one.

My point was that the only benefit of an orthographic camera is to be 100% positive that your graphical elements are not being scaled or otherwise filtered in any way by perspective. Any kind of scale (either through transforms, or depth) or rotation will cause your images to no longer be pixel perfect, and recieve a bit of filtering, and since I do rotate/scale my 2d elements constantly my textures are always recieving some amount of filtering. (which is fine by me).

If you want to avoid EVER having your art get filtered at all, you’d want an ortho camera so that you can have things on different depth layers without having the depth mess with their scale as well. I suppose a perspective camera requires more computation too, but the effects are rather miniscule. I prefer getting that parallax scrolling effect “for free” rather than faking it through code.

Thats exactly what I described.
Parallax is an effect that bases on different speeds for things in different “distances”, not on a perspective camera.
Actually, back in the days parallax was used, ie 16bit console age and earlier, there was no perspective camera or 3D at all, it was all pure 2D, or as you would call it today “orthographic camera”

I recommend to search the orthographic setup thread. You will find a Sprite Manager script in there that allows you to define something as a scrolling background with its own speed (in x and y direction) in pixel per second.
Nothing prevents you from having multiple such layers at different depths, I for example have 5 of them.

Yeah, I know how to do parallax the old fashioned way. It’s just not as easy as using the perspective camera and having it work automatically! :wink:

Well this thread has answered my question. I am going to try orthographic for my 2D game. I would much rather have exact control over each layer in terms of the scrolling rather than try and fudge and mess with scaling, depth etc. Thanks all.

Think you might have got the wrong end of the stick, Dreamora.

By Automatic Parallax, I simply meant that if you have a 3D camera (not ortho) looking at a 3D landscape, but are treating game objects (such as player character and NPC) as 2D objects (they’re billboarded sprites, and all have the same Z-Depth), then you WILL see a parallax effect in the background due to the increasing distance away from the camera that the 3D background has.

You’re correct in stating that an Orthographic Camera projects in parallel lines, so has no perspective forshortening. This means that in order to create parallax, you need to actually move background layers at different speeds, otherwise the motion of the camera will make it look like all layers are superimposed over each other, even though they could be miles apart on the Z-Axis.

In short, Orthographic cameras turn the Z-Axis into a “Zoom-In” on an XY plane, so parallax has to be handled manually.

SB

1 Like

Ah you were talking about real 3D backdrops 8)

Was the whole time under the impression that we talk about 2D and 2D only, so the dynamic things beeing 2D and the background layers beeing 2D.
In that case the decision on cam would be unimportant.

With real 3D its naturally a whole different story :slight_smile:

Dreamore, even for 2D, a non-ortho cam can be handy because it will have automatic parallax. If you put one (flat) layer at 100 units from the camera, and the other one at 200, they will obviously move at different speeds when you move the camera. Easy.