3
$\begingroup$

I have a single icosphere in my Blender project and I'm using 2.91.0. My active camera has a background image of a few buildings and I have a foreground framing image that's a blue box that fits around the edges of the rendered area and the rest of it is alpha channel, so it can be transparent. The icosphere has a brick texture. This is all just for testing.

Here's the Blender window. I've hit numpad-0 so the view is through my camera: enter image description here Note that I have two images specified in the Camera editor on the right, one for foreground, one for background. I've also changed the offset for the background image and, in the Lens section (at the top of that editor - the top part of that section can't be seen), I've set an offset to put the sphere on the point of a small tower on a building.

In the 3D view, you can see the light blue frame I created (that's in the foreground image). The rest of the foreground image is transparent. You can see a bit of the orange camera image outline underneath the blue outline. So the blue should be framing the image when I render it.

Here is the rendered image, using Eevee: enter image description here

There are a number of differences:

  1. The frame in the foreground image is missing. (Note Opacity is set to 1.0, so it should be there.)
  2. The rendered image includes the entire background picture, not just the area framed by the camera (which matches the area I have framed in blue). The foreground image is the same size, in pixels, as the specified image size for rendering (set in the Output Properties editor).
  3. The sphere has moved to the left and up from the position I set it in when looking through the camera view in the 3D Viewport.

To render, I just went to the menu and picked Render->Render. (I use an iMac which uses the function keys, so I don't use them for individual programs.)

Why are there these significant discrepancies between the rendered image and the camera view in the 3D Viewport?

Blend file from blend-exchange:

$\endgroup$
2
  • $\begingroup$ maybe you should share here your blend file (with images/textures packed in). To pack use the menu "file/external data/pack all into blend". Please use blend-exchange.giantcowfilms.com and paste the obtained link here. $\endgroup$
    – lemon
    Nov 20 '20 at 19:45
  • $\begingroup$ @lemon: Thank you! While I get that the pack function is all-inclusive, a simple question to help my understanding, if you don't mind. The texture I'm using is one I found within Blender, so is that "standard" and built into the program, or does that get packed into the file, too? $\endgroup$
    – Tango
    Nov 20 '20 at 20:09
4
+50
$\begingroup$

First have a look at camera background images in the documentation:

Crop

Scales the image up so that it fills the entire camera view, 
but without altering the aspect ratio (some of the image will be cropped).

The image is scaled at minimum so that either its height or its width fits the view.

Then you have shifted the background image of -0.104 along Y.

Now in the compositor, you've used a scale with crop option: that means the image is cropped then displaced (if you displace it) so you'll have a transparent part at the top. This is probably not what you want to do.

You can use a "transform" node instead, and some little math.

Your image is 4032 x 3024.

The render setting is 1350 x 800.

As crop from camera background image has adjusted the width. That means you have a scale ratio of 1350 / 4032 = 0.334821.

That give a height of 3024 * 1350 / 4032 = 3024 * 0.334821 = 1012.5.

As you've moved the background image of -0.104 (which is -10.4% in the camera coordinates), you have to shift the image in the compositor of -0.104 *1012.5 = -105.3

That gives this compositor setting:

enter image description here

To add the blue frame which has the same size as the rendering, you can add another alpha over setting on top of the previous one:

enter image description here

And if you want to avoid the above math/calculation, you can also parent to the camera a plane that will render the background.

Place the plane far from it, then scale and move it as you need. The plane has no shader to render with its full colors (don't forget to adjust the camera clipping if the plane is too far):

enter image description here

A blend file for this last setting:

$\endgroup$
7
  • $\begingroup$ See my comments to the other answer about getting the frame in the front to show. I have a screenshot of it, but can't put a pic in a comment. I take it there is no way to get a node like Transform to follow the changes made in the camera node? $\endgroup$
    – Tango
    Nov 21 '20 at 9:08
  • $\begingroup$ @Tango, no, there is no way to automate that. Maybe you should place the images in a totally other way (not using camera background images)? $\endgroup$
    – lemon
    Nov 21 '20 at 9:12
  • $\begingroup$ In this case, I have to track it, but this is testing and learning, so I'm trying to learn all I can about how to do this. I hope, in the future, it won't be as big an issue. Part of what I'm working toward is being able to use Blender to print out blueprints, since I'm tired of some issues 2D CAD has with that. I'm trying to do a lot in a "per camera" basis, so I'm not turning images on and off for rendering from different views. The Transform node is perfect for this issue, so I'm glad you included that. (see next comment) $\endgroup$
    – Tango
    Nov 21 '20 at 9:14
  • $\begingroup$ I puzzled together what to do to make the frame show up (including alpha and all that) and can pass it on either in screenshot form or a new blend file if you want to add that in to include the other part of the question in your answer. $\endgroup$
    – Tango
    Nov 21 '20 at 9:15
  • $\begingroup$ @Tango, answer edited. Is that what you meant/wanted? $\endgroup$
    – lemon
    Nov 21 '20 at 9:31
1
$\begingroup$

I think most of your issues come from here:

enter image description here

In the compositor (where stuff is actually rendered) you've scaled the background image differently than you did in the camera settings (where the picture is treated like a non-renderable reference image).

I just put the same value (-0.104) on the compositor's "Y" and that alone nearly fixed the misplaced sphere. Maybe some more fine tuning can get the two settings to match and give you the expected result!

Still don't know what's wrong with the frame, though.

$\endgroup$
5
  • $\begingroup$ I'm still confused on the nodes, since I think I got it to render once before I added them, but late read I needed them. I added the same set of nodes for the frame and it shows - but the area in the frame image that's all alpha is not transparent. $\endgroup$
    – Tango
    Nov 21 '20 at 7:12
  • $\begingroup$ I did find out how to get the frame included - if you want to add it. (I don't know how to send a photo in a comment.) I added an Image node for the FG image, then a Scale Node, and an Alpha Over node. I ran the foreground and rendered output into one Alpha Over node, then the output from there and and the output from the background's Scale node into it as well, so everything was combined into Alpha Over nodes, then to Composite. The one glitch is that I can't change the background to Crop and offset it the same in the Camera editor and in the Scale Node. $\endgroup$
    – Tango
    Nov 21 '20 at 8:56
  • 1
    $\begingroup$ @Tango don't worry about it, lemon got the answer way better than I ever could (my knowledge about nodes is rudimentary at best). I'm just glad you worked something out! (in any case, we can only put links to images in the comments) $\endgroup$
    – CBarr
    Nov 21 '20 at 10:25
  • $\begingroup$ Links - so I'd have to upload it somewhere and link. Thanks. You got me going and, honestly, while Lemon covers it, you gave me stuff that helped too, so reading both answers helped me learn more than just one. $\endgroup$
    – Tango
    Nov 21 '20 at 21:09
  • 1
    $\begingroup$ @Tango You're welcome! Glad we could be of help. $\endgroup$
    – CBarr
    Nov 21 '20 at 23:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.