2
$\begingroup$

I'm trying to set the resolution sample spacing on my rendered images as the number of meters in between the center of each pixel using Cycles render engine. For the sake of the example, let's say I wanted to output images where the real distance between the center of each pixel was 0.4m. This is different than the Blender -> Sampling -> Render parameter because that parameter sets the number of light paths to be sampled per pixel, not relying on physical distance.

Does anyone know how I could use a combination of the Sampling parameter, height of the camera, measured distance of objects with known bounding boxes in the image, resolution (image size), or anything else to set this value?

Thank you so much for any help!

$\endgroup$
4
  • $\begingroup$ I must be missing something here. The way I understand your question is that you want pixels to be 40 cm apart. This means that if the camera looks down on, let's say, a soccer field with 105x68 m dimensions, you need the render resolution to be (105/0.4)x(68/0.4) = 262.5x170 pixels. Since the first value isn't an integer, you would need to have 10 cm margin on both (shorter) sides of the field. $\endgroup$ Commented Mar 4, 2021 at 22:22
  • $\begingroup$ Hello :). Unless you're using Orthographic camera, this will depend more on output resolution, camera distance, focal length and sensor size. Sampling has nothing to do with it. $\endgroup$ Commented Mar 4, 2021 at 22:22
  • $\begingroup$ @MarkusvonBroady, that does partially answer my question! One detail I forgot to add is this needs to be a 512x512 image, so using your calculations, to calculate out a square soccer field, I would do: length of field = (pixel resolution)*(distance between pixels in m) = 512*0.25 = 128m. Then my last question would be how to make that 128x128m field take the up the entire 512x512 pixels - I'm assuming that's in the camera distance and focal length settings that Jachym Michal mentioned? $\endgroup$
    – karis
    Commented Mar 4, 2021 at 23:22
  • $\begingroup$ Yes. Camera distance is basically how far away the camera is from an object, making it look smaller. Focal length is a bit trickier to explain, but a high focal length makes things in the camera view look as if they are actually far away but are being zoomed up on with a telescope: more orthographic. $\endgroup$
    – TheLabCat
    Commented Mar 5, 2021 at 0:55

1 Answer 1

2
$\begingroup$

I'm assuming Metric is set as Unit System and Meters as Length in Scene Properties tab. If you're using any other unit, including those from Imperial system, simply convert the values calculated below as meters to the unit of your choice [Blender also operates on meters and converts them to other units if necessary ].

Using Orthographic camera, Blender takes the longer of the output dimensions and treats it as unit_scale * orthographic_scale meters. So increasing either Unit Scale or Orthographic Scale increases the area visible by the orthographic camera. Since Blender automatically scales objects when you change the Unit Scale, you can see the change by observing the grid in Top Orthographic View:

So for 200x100 dimensions, 1.0 unit scale, 1.0 orthographic scale, 200 pixels represent 1.0*1.0 = 1 meter and 1 pixel represents 1/200 = 0.005 meters or half a centimeter. For 100x500 dimensions, 2.0 unit scale, 2.0 orthographic scale, 500 pixels represent 2.0*2.0 = 4 meters and 1 pixel represents 4/500 = 0.008 m or 8 mm. Assuming square pixels here.

pixel_width = pixel_height = unit_scale * orthographic_scale / longer_output_dimension

You have output dimensions and target pixel dimensions (distance between centers of pixels), but you want to calculate the orthographic_scale, so you can multiply both sides of the equation by longer_output_dimension and then divide both sides by unit_scale to move them to the other side:

pixel_width * longer_output_dimension / unit_scale = orthographic_scale.

For 512x512 dimensions, 0.4 m pixel width and 1.0 unit scale: orthographic_scale = 0.4 * 512 / 1.0 = 204.8.

Step by step example

Let's say we want to duplicate (yes, not delete) starting cube a few times and make sure cubes are aligned to pixels. Therefore, pixel dimensions should equal cube dimensions - 2 m, and axis-aligned distances between cubes have to be multiples of 2 m.

  1. Press Numpad 7 for Top Orthographic View.
  2. Select the cube. Press SHIFT + D to duplicate it, hold CTRL and position it. Repeat a few times.

  1. Select the original (center) cube, press / to center view on it, then CTRL + ALT + Numpad 0 to set the camera to active view and / again to exit Local View.

  1. Since each cube should correspond to one pixel, in this example we can fit everything in 5x5 dimensions, so let's set such dimensions in Output Properties tab
  2. Press Numpad 0 for camera view, select the camera and in the Object Data Properties tab change its type to Orthographic. Set the Orthographic Scale to 2 * 5 [2 m cube dimension times longer output dimension] - Blender will accept a simple expression like that.

As you can see, cubes are aligned to pixels.

$\endgroup$
1
  • $\begingroup$ This answers my question exactly, thank you so much! $\endgroup$
    – karis
    Commented Mar 9, 2021 at 17:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .