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

Create a Fake Perspective ?

Started by Endemoniada Jun 1, 2012 at 3:14 AM 3 replies 2.1k views
Original Post
Endemoniada
Endemoniada
Hi guys,

The left side of the image below shows a regular projection with the camera positioned at (0,0,0) and looking at (0,0,farZ) which I show with a yellow dot. Notice the top and bottom of the boxes.

I want to render something similar to the right side. The camera would seem as if it's positioned at (0,bottom,0) and looking at (0,bottom,farZ). Notice the bottoms of the boxes here.

How can I do that ? If I simply relocate the camera half the objects will be off screen. This is a 2D game (with 3D objects) so I'm keeping the camera fixed.

Thank you.

cameray.jpg
Tsus
Tsus
Hi!

At first, I thought of suggesting an orthographic projection, but then I saw that your objects are getting smaller in the distance (perspective-like). This is rather tricky.
Maybe there is some easy matrix to achieve this, I don’t know. (One of the off-center matrices perhaps? I honestly don’t know.)

But, in case there is not, you could try to use two viewprojection matrices. The first one is a perspective matrix centered above the object, thereby producing the 3D look you want to have. Afterwards you move the object by a translation in clipping space to the desired position. The offset vector could probably be somehow found by using the “cameras” viewprojection matrix (probably orthographic) to see, where the vertex is on the screen and how far it is away from the camera. I’m not quite sure, whether this works so easily. It’s essentially the idea of rendering the objects to small imposters and then placing the imposters (except that you don’t need to render the object (and depth) to a texture, but instead just moved it to the desired position in the vertex shader).
Maybe you could pick up the imposter idea, which means you'd render your objects with the perspective projection to a texture atlas and then just render textured, viewport-aligned quads (billboards) to show them in the final scene. (If your atlas contains depth, you can adjust the output depth of the billboard pixels to get proper depth tests.)

I hope this helps at least a little. smile.png
darrenmarklines
darrenmarklines
PerspectiveOffCenterLH is what you want, you need to change the camera dynamically per object with an offset that is appropriate for the effect you want.
DvDmanDT
DvDmanDT
Can't you make the camera look waaay below your desired screen area (thereby making your wanted objects way above) and then apply a translation after the projection matrix?
haegarr
haegarr

...
I want to render something similar to the right side. The camera would seem as if it's positioned at (0,bottom,0) and looking at (0,bottom,farZ). Notice the bottoms of the boxes here.
...

How should it look like when the boxes are apart from the vertical axis?

Topic Locked

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

Sign in to reply to this topic.