POV-Ray: Setting output resolution or width/heigh ratio within the script
Asked Answered
H

3

9

I have a code that generates a bunch of *.pov files for visualization using POV-Ray. Unfortunately, they are of different aspect ratios (width/height). That information is in the script in the form of the up/right vectors. However, when I render a script without any extra parameters, i.e. through povray test.pov, POV-Ray forces the standard 4/3 aspect ratio. Therefore, images are distorted.

Question: Is there any way that the script may request a certain aspect ratio or resolution?

Halverson answered 18/11, 2013 at 8:31 Comment(0)
T
7

This is how I do it (sorry for the late answer):

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

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

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

Width=1600
Height=900

If you don't want to use .ini files, you can also specify height and width in the command line:

povray -H900 -W1600 ...

Maybe this is closer to your scripting solution.

Transact answered 6/2, 2014 at 13:15 Comment(0)
A
3

As @Fabian said, you can use image_width and image_height. The following will assume that pixels are square. Then any +H and +W settings will end up cropping your image around the sides 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 get why something like this isn’t the default as most people care about the shape of the pixel rather than the aspect ratio of the target screen. I.e., I might be making an image that should only fill this a small part of the screen, but my pixels are square—then the above works. Or if your pixels are twice as wide as tall, just use right 2*image_width/image_height*x (a monitor with such pixels would effectively stretch the image along the X axis, so if you view that image on a monitor with square pixels, it’ll look squished along the X axis).

Aeronautics answered 2/2, 2017 at 6:4 Comment(0)
F
1

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

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

camera
{ right x*ImageWidth/ImageHeight
(other camera settings...)
}
Found answered 18/11, 2013 at 8:35 Comment(2)
Unfortunately, when I put up y * 3.5/5.0 to get a 5/3.5 aspect ratio, then calling povray test.pov renders in 800x600, which has a 4/3 aspect ratio, so my image is stretched.Halverson
Please be aware that there are two variables: image_width and image_height which will have the correct values. You don't need to put values in there.Anabas

© 2022 - 2024 — McMap. All rights reserved.