Skip to main content
GameDev.net gamedev.net
🔒 Locked

Hybrid ortho/perspective view frustum

Started by _Unicron_ Dec 20, 2012 at 8:27 PM 3 replies 2.4k views
Original Post
_Unicron_
_Unicron_
I am trying to create an effect where the view frustum provides a perspective effect along the x-axis, but an orthographic effect along the y-axis.

Think of a perspective view frustum but where the top and bottom faces run parallel to each other. Does anyone know how I an achieve this effect?
Brother Bob
Brother Bob
Thinking about this for a minute, I don't think you can implement the whole chain of operations using matrices and the standard vertex processing stages. I believe it's the perspective division stage, which is introducing the perspective effect by dividing by the depth, that is the core of the problem since it is applied to both the X and the Y axes. You can either have no perspective, or perspective along both axes, since the divisor is the same for both axes.

You would have to implement your own vertex processing. This should be trivial with a vertex shader since you can just do the division yourself (divide only the X, Z and W components of the transformed vertex); then, OpenGL's own perspective division has no effect since the vertex has a unit W-component.
MaelmDev
MaelmDev
I can think of how this would work visually, but not the steps needed to produce the transform matrix. What I see is an orthographic frustum with the "near" side squished vertically to make a trapezoidal prism.
CryoGenesis
CryoGenesis
Sounds like one of those old raycasting type views.
Do you mean something like this:
http://image.dosgamesarchive.com/screenshots/wolfenstein4.gif
but instead of the crappy block graphics you have proper geometry?
_Unicron_
_Unicron_
Thanks Brother Bob, you're right. I was initially thinking that this would be possible to construct just by modifying the projection matrix. Doing the perspective divide in the vertex shader only on the x, z and w components did the trick! smile.png

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.