POV-Ray / povray

The Persistence of Vision Raytracer (POV-Ray)
https://www.povray.org/
GNU Affero General Public License v3.0
1.37k stars 282 forks source link

Default aspect ratio is 4/3 = 1.333333 or approximated to 1.3300? #304

Closed ubuntuslave closed 6 years ago

ubuntuslave commented 7 years ago

The POV-Ray documentation for the camera states that the right vector's magnitude is 4/3 =1.33, but is this value being approximated/truncated to 2 decimal points so it is 1.3300 or is it more precise like 1.333333333...?

If there is such an approximation, then the horizontal FOV angle could not be 67.380 degrees as the camera documentation page states.

This is a doubt that arose when looking at the POV-Ray rendered dataset by ICL-NUIM where the focal lengths of the camera matrix differ (which implies the pixels are not exactly square) and their camera file used in the provided MATLAB scripts employ this 1.3300 approximation for the focal lengths computation.

Can someone please verify what the default values actually are? Thanks in advance!

wfpokorny commented 7 years ago

I didn't realize it myself. Looks like the default today is 1.33. Further, that others have noticed this as an issue in the code.

From Camera /source/core/scene/camera.cpp :

void Camera::Init()
{
    Location    = Vector3d(0.0,  0.0, 0.0);
    Direction   = Vector3d(0.0,  0.0, 1.0);
    Up          = Vector3d(0.0,  1.0, 0.0);
    Right       = Vector3d(1.33, 0.0, 0.0); // TODO FIXME
    Sky         = Vector3d(0.0,  1.0, 0.0);
    Look_At     = Vector3d(0.0,  0.0, 1.0);
    Focal_Point = Vector3d(0.0,  0.0, 1.0);

Easy to update and that is my instinct on seeing a hard coded 1.33. But... Wondering if there is some historical reason here that has kept things as is. Anyone remember?

In any case, the default right vector is easily overridden so as to be 4/3 in the SDL. I note your point that a section of the documentation is today not accurate to the current default and I'll post a link to this issue in to the povray newsgroup for inbuilt documentation.

ubuntuslave commented 7 years ago

Thanks for confirming that this has never changed since version 3.1. There is an old forum from year 2001 discussing about this hard-coded 1.33 as opposed to a more precise 4/3.

I would like to know why this hasn't been FIXMEed. I'm assuming there is a bunch of legacy rendered scenes that used that value. This in fact causes pixels not to be squared, so unless explicitly setting the Right vector to be 4/3*x, a desired 4:3 aspect ratio is violated.

wfpokorny commented 7 years ago

Quick note that Christoph implemented a change for this with commit 12fbab3 in the 3.8.0 branch. Once that branch is merged back into master we should look to close this issue.

jmichae3 commented 7 years ago

umm, pov-ray has some kind of internal aspect ratio which I cannot overcome for multiple monitors and a different aspect ratio (like 8:5 ot 16:9 or 2:1.) pixels appear squished in one axis or other. I have made aspect ratio calculations before ans I know what they are supposed to look like, so it's not new to me.

take out the internal and default aspect ratio. it's supposed to be 1:1 pixels remember? we will set aspect ratio in camera as we need it.

dickbalaska commented 7 years ago

How are you changing aspect ratio? I find camera { location <1,2,3> right <image_width/image_height,0,0> look_at <4,5,6> } works for me.

c-lipka commented 7 years ago

@jmichae3 Please visit our newsgroups at http://news.povray.org (or if you prefer to use a newsreader software, news://news.povray.org) for support. This place is for reporting bugs or suggesting new features.

jmichae3 commented 7 years ago

think again, Y needs to be changed also, not just X. there's an equation I sell for this for engineers. what you get with that is squeezed pixels.

c-lipka commented 6 years ago

Fixed for v3.8.0 as per commit 12fbab3e902057e6b82a813e422a5c2358d300ff. The camera right vector's length now defaults to the physical aspect ratio of the output image (i.e. image_width/image_height). In other words, the camera will now adapt to the output image's aspect ratio by default (presuming the output image format uses square pixels). For backward compatibility, this behaviour is subject to the #version statement. Legacy (pre-v3.8) scenes will continue to use the old quirky value of 1.3300.