- Home /
Making a camera semi-orthographic
Hello unity community, I am asking if it is possible to make only the bottom of a perspective camera orthographic, in Unity Free. Here why,
I am creating a 2D game, and today was the first day of development and i already encounter an issue that has no easy fix. I want to add a scrolling like background in my game, like what is scene in unity. The issue is that to get the effect right, i need to use a perspective camera. However, this type of camera has a nasty feature, the bottom view goes down. This i bad because every layer has to be slightly lower than the other, and its really frustrating trying to fix it
One way i have thought about to fix it is possibly making the bottom of the camera straight, like orthographic, unfortunately I don't know if its possible and if it is, how do i do it?, so that is why i am posting this question.
EDIT: This is what i am wishing to achieve
What exactly do you mean by "the bottom view goes down"?? Do you have a screenshot maybe?
Hmm, I still do not see your problem. :) Why do you want perspective projection for the upper half of the screen?
If you are making a 2D screen, you can have a plane which is orthogonal to the z-axis and place your character on that plane. The background plane will be the same but further from the cam. That should actually look fine, no?
Answer by Loius · Jan 16, 2013 at 09:42 AM
You need to make changes to your camera's projection matrix.
Projection matrices is hard stuff. The internet has lots of resources; I can't give any specifics. It's been way too long since basic 3D graphics class :)
Thanks, just the answer i needed. Glad to know it is possible, just have to try and figure how to work it now :D
What would be really handy though is a tutorial to lead me into matrix, its way ro complex for me at the moment.
I think this is the link you want to stare at until your brain bleeds: http://www.songho.ca/opengl/gl_projectionmatrix.html
It terrifies my soul, but it looks like it's got all the right maths and stuff to actually build an entire matrix to do what you need.
You essentially want to make the bottom half of your matrix into an orthographic projection (just lines straight away from the camera), and the top half stay like it is (at an angle). The ortho stuff is at the bottom of the link, and it's very simple - you might be able to just get the current camera matrix and make simple adjustments to it (I've never tried).
I don't really see the point of this but I'm interested :D Even if you can construct a matrix that will be ortographic at the bottom and perspective on the top (??), that's not very flexible, since in ortho mode distance doesn't matter, so you'll have a hard time adjusting the background layers to actually seamlessly "transition" into an ortho view without artifacts. So I just don't see the point of the question, nor the proposed solution. Why not just use two cameras and render the background differently?
The fact that the projection region blends smoothly should smooth the transition on its own. I imagine it'd be a weird, but unique look. Lots of style to it.
I didn't even think of multiple cameras, though; that could be an easier solution depending on what exactly is wanted.
Answer by Wolfram · Jan 23, 2013 at 06:15 PM
What you are looking for is an off-axis projection where the optical axis is "shifted" from the center of the screen to the bottom. You can accomplish that by setting the element m[1,2] of a regular projection matrix to 1 instead of 0. (usually denoted as "b", for example here. Instead of top=1 and bottom=-1, you need to use top=2 and bottom=0, the new vertical "distances" of your screen corners from the optical axis. this results in B=1).
Your answer
Follow this Question
Related Questions
Camera 2D RPG in perspective 1 Answer
Why is part of object outside camera frustum visible? 1 Answer
Background Image as Orthographic 2D Game Background - and quick 2D parallaxing question 1 Answer
2d orthographic camera follow 1 Answer
Using a perspective camera can an object act as if viewed by orthographic camera? 1 Answer