Archived

This topic is now archived and is closed to further replies.

kamrann

Projections

Recommended Posts

kamrann    122
Hi I''m using D3D, but at the moment and doing my own transformation and lighting. What I dont understand is, why do objects appear really distorted when they get closer to the edge of the viewport? They sort of stretch out sideways if they go near the left or right of the screen. My projection matrix is copied from a book and is almost identical to the one D3D uses. Am I forgetting to do something? Also, I dont fully understand the near clipping plane. If you were doing some sort of first person perspective engine, doesnt the near plane stop a wall or object right in front of the person from being rendered? How does this work? thanks Cameron

Share this post


Link to post
Share on other sites
Friday13    130
They look distorted because they are projected onto a PLANE, while your (human) field of view is actually ''spherical'', so to say. In other words, triangles that lie closer to the edge of the screen would be farther from you in real world, but your model doesn''t take this fact into account since z-distances to projection plane are the same regardless of x and y. In order to fix this, you have to evaluate the actual RANGE to a 3d point, not just its Z value. Try using R=sqrt(x^2+y^2+z^2) instead of just Z.

Share this post


Link to post
Share on other sites
WitchLord    4677
Although Friday13 is absolutely correct in his explanation, the more common solution is to use a lower FOV (multiply x and y with a constant larger than 1) for your projection matrix. This is probably the only solution you can use, as the solution Friday13 gives would give you other strange effects: The projection tries to bend the world around the viewer, but the triangles cannot be bent thus giving apparent warping of the vertices.

- WitchLord

Share this post


Link to post
Share on other sites
furby100    102
The viewing distance should be something like 200 (in 640x480), this minimises the distortion sufficiently to make it appear flat. Higher resolutions need higher viewing distances, this is why there is a viewing distance parameter, otherwise it will only look correct if you have your nose pressed against the monitor, which will most likely make a nasty greasy mark.

------------------------------
#pragma twice


sharewaregames.20m.com

Share this post


Link to post
Share on other sites
Friday13    130
2 WitchLord

Yeah, actually it does bend the world around, which produces a somewhat ''fish-eye'' effect. I was thinking of countering this by projecting to a concave hemisphere at first, but then I was given a GeForce2 whose HW T&L doesn''t (for some strange reason)support weird experiments (which is sad ;-)

Share this post


Link to post
Share on other sites
kamrann    122
What is the viewing distance?
Does this have something to do with my question about the near clipping plane in my original post?

thanks

Cameron

Share this post


Link to post
Share on other sites
furby100    102
The formula for perspective is:
x = x/z * viewing distance
y = y/z * viewing distance

If you increase the viewing distance, it is like zooming in. It is supposed to represent the viewer''s distance from the viewing plane ie the monitor screen.

------------------------------
#pragma twice


sharewaregames.20m.com

Share this post


Link to post
Share on other sites
kamrann    122
ok thanks.
that reminds me of something else though.
you say the viewing distance should be something like 200 in
640 x 480. this must depend though on the sizes of the objects in youre world, right, which is what i''m not sure about. at the moment im doing my own very basic modelling, but am just randomley guessing at the size these objects should be in terms of coordinates. is there some suggested sizes? or do I make things as small as possible so long as it allows me to be able to create the smallest object I want with the level of detail I want?

a bit confusing...

cheers

Cameron

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
To minimize the distortion, you have to use the right angle. The viewing angle used in the software should be about the same as the angular width of the screen as seen by the user (assuming the screen is flat). Theoretically, this will give a perfect result, but of course no-one always sits at exactly the same distance. For example, if the width of the screen is 40 degrees, use that as the horizontal viewing angle. Then the height would be about 30 degrees (assuming you''re looking straight at a normal screen), and that''s the vertical viewing angle to use.
Generally, unless you''re sitting very close to the monitor, you''ll have to use a bit more as the normal viewing angle when looking at the screen is too narrow to be usable, unless you want to simulate tunnel vision. I''d say use at least 60°, the distortion isn''t that bad.

Wim Libaers
wim.libaers@skynet.be

Share this post


Link to post
Share on other sites