Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

povray

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?

like image 276
ANSI C Mastah Avatar asked Nov 18 '13 08:11

ANSI C Mastah


2 Answers

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.

like image 147
Aziraphale Avatar answered Sep 17 '22 07:09

Aziraphale


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).

like image 43
binki Avatar answered Sep 19 '22 07:09

binki