# Blender setup for orthographic image rendering

I want to use blender to render some stuff for use with a 2D orthographic view with a scale that 1x1 blender unit is 64x48 pixels.

I set the camera up by hand (as I would use for normal 3D renders). This is fine for rendering my buildings etc., but causes slight issues around the edges of tileable objects, getting semi transparent pixels where I need solid ones (I used a simple cylinder/"pipe" for testing with the end-faces removed), as well as some unexpected shading effects. While rendering each of the individual pipe parts looks OK, if I then combine them later onto a tile grid, it becomes apparent the edges are not quite right.

I assume because my manual positioning was not perfect. I could fix those manually in an image, but would really rather not have to, especially for my more complex models.

It also seems id have to play manually with the resolution, orthographic scale, and camera position to handle different tile sizes (e.g. this pipe is 1x1, but some objects with be 2x1, 2x2, 5x5, etc.). Is there a better and more automatic way to position the camera for such rendering?

Some of the individual 64x96 renders, the edge pixels are not quite right.

When they are put together on a tile-grid.

EDIT: Can anyone explain @quiliup answer, because if I render that I get the exact same thing, what does it solve?

• related: blender.stackexchange.com/questions/65425/… just the math is different. – Jaroslav Jerryno Novotny Aug 9 '18 at 9:31
• Do you want the camera to be slanted downwards or can the view be one of the canonical orthographics ((ctrl +) Numpad 1, 3, 7)? – quiliup Aug 9 '18 at 9:34
• Slanted, if I did the maths right the 41.4 degrees is correct for 64x48 pixel tiles – Fire Lancer Aug 9 '18 at 9:36
• Pipe was maybe not the best example of that, but is a simple one to test that the render output can tile. The angle/"perspective" effect is more pronounced on buildings, but since each building is separate and doesn't tile, I have no problem except maybe the having to set the camera up individually every time. – Fire Lancer Aug 9 '18 at 9:43
• @JaroslavJerrynoNovotny How would the maths related, what needs changing? Seems like he is asking for something physically impossible hence the sqrt(2) requirement, but rendering a 1x1 footprint object onto a 64x48 tile at 41.4 degress angle should be correct for an orthographic projection with appropriate scale, if I understood everything correctly? It is 99% correct, except for the edges in the final render. – Fire Lancer Aug 9 '18 at 16:04

As you have many questions, here are many answers:

## Position

In orthographic mode, it is not important, how far away the camera is from the object (but stay within the clipping bounds). The position parallel to the object should be set and tweaked as you wish.

## Tilt

As you already calculated right, the tilt of the camera downwards is $\alpha \approx 41.4°$. Here's how to calculate it for the orthographical view:

$\cos\alpha = \frac{48\text{ pixels}}{64\text{ pixels}} = \frac{3}{4} \implies\alpha = \cos^{-1}(0.75)\approx 41.4096221°$

the other rotation axes should stay untouched (parallel to the grid)

## Orthographical Size & Resolution

This depends on how many grid squares you want to have in view. So we define, you want to have $m$ squares vertically and $n$ horizontally in view of your render.

If $n\ge m$ set the orthographical size to $n$.

The Render dimensions resolution: X-value is $n\cdot64$ px; Y-Value is $m\cdot48$ px.

The whole algorithm also works for different values $p,q\in\mathbb{N}$ with $p\ge q$ instead of $p=64$ Pixels and $q=48$ Pixels

With the above explained setup I got this render:

## EDIT:

Fire Lancer pointed out that he wants a tileable setup. Here's the setup with the blend file:

• Very nicely written and formatted answer, you deserve much more rep on this site! – Jaroslav Jerryno Novotny Aug 9 '18 at 12:14
• Hmm, sorry I wasn't clear in my question. So I rendered each of the pipe sections separately, then stuck the images together on a blue grid background to show, which is where the misalignment is apparent, will update.Position: I get that the distance is not important, that is part of orthographic. But moving the camera "up" and "left/right" from the screens perspective will move the object around in the rendered image, it needs to match the tile grid exactly. I used 64x96 for the render output because some of the pipes "stick out the top" of the tile boundary box due to their height. – Fire Lancer Aug 9 '18 at 12:22
• I am not seeing what this fixes. Can anyone explain? You have the objects adjacent, if I move them apart and turn on transparency without the grid overlay, it has the exact issue? i.stack.imgur.com/oFCBa.png blend-exchange.giantcowfilms.com/b/5102 . Are you saying to not try and render tileable outputs in blender, but to always render out at a larger size / combined output then fix it in an image editor? – Fire Lancer Aug 10 '18 at 8:05
• You talk about the 'exact same issue' and in the question you describe that 'the edges are not quite right', but I don't get your problem. If you want a sharp edge at the pipe's rim, you can turn off Anti-Aliasing. Please explain more precise, what you expect. – quiliup Aug 11 '18 at 19:25
• See the image with the red rectangles in the original question. If I take the separate renders as individual sprites and put them together I get that. I can try turning off anti-aliasing, but in theory that shouldn't be an angled edge at all and anti-aliasing effects all edges. The result of rendering the 11 different parts should be a set that will tile in any combination without transparent or darker borders. – Fire Lancer Aug 13 '18 at 14:12

I suppose the real problem is that the alpha-values of pixels at the rims of each tile don't add up to 1, which will result in slightly transparent gaps. The darker rim appears, where two tiles overlap with one's semi-transparent pixels on top of darker pixels. Here's the solution:

1. Make sure, your tiles only overlap at the rims. In our example these are the inner parts of the pipe. Here's the node-setup for Blender-Internal-Render to hide the backfaces:
2. Set the background to be transparent. (Disable Sky-rendering in Blender-Internal)
3. Set the Anti-Aliasing to a high value and the mode to Catmull-Rom, e.g.

This will make the alphas add up perfectly and I hope this serves as a sufficient answer.