PDA

View Full Version : Projection tweak



AdrianPi
11-09-2009, 04:24 PM
I need a projection that is perspective on x and parallel on y.
I mean, a view frustum whose top and bottom planes are parallel. Is that possible to achieve?

Dark Photon
11-09-2009, 06:59 PM
Intuitively sure seems so. Prob easiest with your own frag shader as you could only do the divide for X (the perspective foreshortened one). But you may be able to cook the projection transform so it just falls out in the math (pre-mult Y by W). Take a look at the parallel and perspective projection transforms in the red book appendix (http://fly.srk.fer.hr/~unreal/theredbook/appendixg.html) and mix them together.

Also may need some thought on what perspective-correct texturing means here if that makes any difference to you.

Seems like an odd projection though. Things get squished to a vertical line instead of a point as they move away from you?

AdrianPi
11-09-2009, 07:11 PM
Things get squished to a vertical line instead of a point as they move away from you?

Exactly. Texturing is not needed. What about doing it in a vertex shader?

Alfonse Reinheart
11-09-2009, 07:45 PM
What about doing it in a vertex shader?

It's simply a question of creating the right projection matrix.

AdrianPi
11-09-2009, 08:03 PM
Can you give me a hint? I've been trying to figure it out, but I couldn't.

Jackis
11-12-2009, 08:20 AM
Actually, as far as I get projection matrix, it's impossible to create such a projection matrix, which would make parallel projection alons one axis and perspective along other.
Imagine simple projection. The trick is we make W somehow proportional to Z, so you always have projection point, where all lines are going through it. But to achieve what you want you have to create such an operation, which will make perspective division only to X and Z, living Y parallel, so just like division by 1 here, so you may wish to write something like Y*Z there (to compensate perspective division), but perspective matrix is an affine transformation, so it is forbidden here.
[EDIT] You may want to do it like other people proposed - make some hacks in vertes shader, but if your tesselation is low, you would get not correct interpolation in term of your desired projection.