archie305 / openscad2povray

Convert a subset of OpenSCAD elements to POV-Ray
GNU General Public License v2.0
3 stars 3 forks source link

VPD: distance needs to be about twice as much in Povray vs. Openscad #11

Open hzeller opened 4 years ago

hzeller commented 4 years ago

In order to get about the same size output, the distance (vpd) has to be doubled in Povray. Not sure if this is an artifact of different ways how to calculate the perspective, so leaving this here for exploration.

Example: here openscad invoked with the following parameters, most notably the $vpd=500

openscad  -D'$vpd=500' -D'$vpt=[-35, 29, 42]' -D'$vpr=[59.2, 0, 45.3]' radial6.scad

This yields distance-500-openscad

(notice the distance is shown as 500 in the status bar)

In order to get the same view, I have to use the distance of 1000 ($vpd=1000 or openscad_vpd=1000) when generating the echo file:

openscad -Dopenscad_vpw=800 \
             -Dopenscad_vph=800 \
             -Dopenscad_vpd=1000 \
             -D'$vpt=[-35, 29, 42]' -D'$vpr=[59.2, 0, 45.3]' \
             radial6.pov.scad -o radial6.pov.echo

.. which then creates the same frame radial6

Is there somewhere a factor of 2 off ?

hzeller commented 4 years ago

I suspect the angle-of-view different, i.e. the simulated camera in OpenSCAD is more 'wide-angle' ? If so, maybe it is possible to fish out the actual constants of the angle of views used for OpenSCAD.

hzeller commented 4 years ago

The "#macro openscad_camera_angle(w ,h) tries to calculate that, and it is dependent on the aspect ratio; possibly this calculation changed in OpenSCAD since the last update of openscad2povray. In particular my choice of rectangular aspect ratio highlit that discrepancy

With a different aspect ratio, now 1600x800, this looks like this:

OpenSCAD invocation with distance 500

openscad -D'$vpd=500' -D'$vpt=[-35, 29, 42]' -D'$vpr=[59.2, 0, 45.3]' radial6.scad

openscad-1600-png

It looks vertically centered like before, just that there is now more space right and left due to double wide screen.

Povray echo generation with 1000 distance in initial bug entry. This now looks off.

openscad -Dopenscad_vpw=1600 \
                 -Dopenscad_vph=800 \
                 -D'$vpd=1000' \
                 -D'$vpt=[-35, 29, 42]' -D'$vpr=[59.2, 0, 45.3]' \
                 radial6.pov.scad -o radial6.pov.echo

radial6

Playing around with the OpenSCAD UI it seems that the angle is determined not from the ratio (which is what the openscad_camera_angle macro uses to calculate the angle) but just from the height ? Changing the width of the window does not change the size of the output, just the vertical size does.

Once that is figured out, the openscad_camera_angle macro can be adapted to match that.

Needs further investigation.