POV-Ray: setting resolution or width / height ratio within script

I have code that generates a bunch of *.pov files for rendering using POV-Ray. Unfortunately, they have different proportions (width / height). This information is in the script as vectors up / right. However, when I create a script without any additional parameters, i.e. Through povray test.pov , POV-Ray forces a standard 4/3 aspect ratio. Therefore, images are distorted.

Question: Is there a way a script can request a specific aspect ratio or resolution?

+6
source share
3 answers

Here's how I do it (sorry for the late answer):

In the .pov file, specify the keywords "up" and "right":

 camera { up <0,9,0> right <16,0,0> // right,up -> 16:9 } 

In addition, I specify the height and width of the output in the .ini file:

 Width=1600 Height=900 

If you do not want to use .ini files, you can also specify the height and width on the command line:

 povray -H900 -W1600 ... 

Perhaps this is closer to your scripting solution.

+6
source

As @Fabian said , you can use image_width and image_height . It is further assumed that the pixels are square. Then, any +H and +W settings will crop your image around, while keeping the height the same:

 camera { location <0, 2, -3> look_at <0, 1, 2> right image_width/image_height*x } 

I personally don’t understand why something like this is not the default, as most people care about the shape of the pixel and not about the proportion of the target screen. For example, I could make an image that should fill only a small part of the screen, but my pixels are square, then the work is higher. Or, if your pixels are twice as wide in height, just use right 2*image_width/image_height*x (a monitor with such pixels will effectively stretch the image along the X axis, so if you look at this image on a monitor with square pixels, the X axis) .

+3
source

From the documentation: http://www.povray.org/documentation/view/3.6.0/153/

You can set the aspect ratio with the keyword "right" in the camera unit. The general way to set the correct aspect ratio for your image is:

 camera { right x*ImageWidth/ImageHeight (other camera settings...) } 
+1
source

Source: https://habr.com/ru/post/958292/


All Articles