Object distortions on the edges of window

Started by
11 comments, last by BlackJoker 10 years, 7 months ago

Shouldn't this line...

float xScale = 1.0f / tanf(0.5f * fovy);

...be:

float xScale = 1.0f / tanf(0.5f * fovx);

?

No, because in that case image will be twisted.

To All

I think the real problem is in projection matrix. I used standard projection matrix by mistake and receive such distortions, when i switched to my custom projection matrix, I receive now more than twice less distortions (70px vs 30px now), but my question is: is it possible to improve projection matrix more to have less distortions leaving FOV 90 degrees?

For now I build my projection matrix like this:






void CameraDX_Free::perspective(float fovx, float aspect, float znear, float zfar)
{
    // Construct a projection matrix based on the horizontal field of view
    // 'fovx' rather than the more traditional vertical field of view 'fovy'.

	float e = 1.0f / tanf(XMConvertToRadians(fovx) / 2.0f);
	float aspectInv = 1.0f / aspect;
	float fovy = 2.0f * atanf(aspectInv / e);
	float xScale = 1.0f / tanf(0.5f * fovy);
	float yScale = xScale / aspectInv;

	

	XMFLOAT4X4 temp ;
	XMStoreFloat4x4(&temp,m_projMatrix);

    temp(0,0) = xScale;
    temp(1,0) = 0.0f;
    temp(2,0) = 0.0f;
    temp(3,0) = 0.0f;

    temp(0,1) = 0.0f;
    temp(1,1) = yScale;
    temp(2,1) = 0.0f;
    temp(3,1) = 0.0f;

    temp(0,2) = 0.0f;
    temp(1,2) = 0.0f;
    temp(2,2) = zfar / (zfar - znear);
    temp(3,2) = -znear * zfar / (zfar - znear);

    temp(0,3) = 0.0f;
    temp(1,3) = 0.0f;
    temp(2,3) = 1.0f;
    temp(3,3) = 0.0f;

	m_projMatrix = XMLoadFloat4x4(&temp);

    m_fovx = fovx;
    m_aspectRatio = aspect;
    m_znear = znear;
    m_zfar = zfar;
}
Advertisement

So, let me clarify things.

What I described as “correct” was described by Hodgman as being fish-eye, which indeed it often is.

What Álvaro says disappears does disappear, but only as much as the human mind can or typically perceives. Mathematically, in physics, the curves are still there, just reduced so much that we do not notice them.

When I said the “fish-eye” effect was “correct” I meant physically. All eyes and cameras have the fish-eye effect, but usually reduced to such a point we simply cannot detect it. We only start to call it “fish-eye” when it is exaggerated to the point we start to easily notice it.

All humans have the fish-eye effect to some degree, depending on your field-of-view, which depends on how far outside of your sockets your eyes are.

However we are all also trained to focus on what is ahead rather than to the sides. What happens in our peripheral vision is low-frequency and only meant to drag our eyesight over to put the event into the high-frequency zone the focal-point area of our eyes are designed to digest.

If you can put the high-frequency area on hold for as long as you can and put the line that marks the corner of your room as far into your peripheral as you can and try to focus carefully on that area of your sight, you will be able to see the line marking the corner of your wall curving just as in the first image in the link does.

It’s “correct” based on being physically…correct.

As Hodgman also mention, it is based on a curvilinear perspective, but you are still trying to get non-curved but also non-stretched results in a rectilinear perspective transform.

It’s simply not possible. The only possible way things can appear to always be the correct widths and heights (not stretched) is with a curvilinear perspective and a huge amount of tessellation. Or post-processing.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

L. Spiro

Thanks for explanation. It is much more clear now.

Foe this moment I use FOV 75 degrees and there is no (or almost no) visible stretching of objects, so I think on this stage I have almost perfect image.

Thanks to all who participated in this discussion.

This topic is closed to new replies.

Advertisement