How to render environment in advance (Searching for best practices)

I’m an architect and am thinking about the following:
When rendering houses, most of render time is wasted about rendering (not changing) environmental objects like trees, grass etc.

My question is whether it’s economical to have a blend file in which I render Hi-poly environmental objects (mostly vegetation) and then I insert my house onto another layer, render it separately and ZCombine the two. It’s easy to solve this, but doesn’t seem to be much of an advantage, because of some shorcomings:

-possibly a bug, but in 2.78a there is a halo around object can be swithched off by full sample antialising. But when I switch to full sample, the masking goes wrong and I cannot ZCombine the two images (house+environmen). When i render the first imput, the second diminishes and so on. When full sample is switched off, the stuff works.
-is it possible to save the image with alpha channel and Z channel? Obviously Z channel is an important stuff here. In an ideal case there should be an image (with both alpha and Z channels) that could be saved with the .blend file and I should re-render only the house.

A mockup scene is attached


ZCombine teszt.blend (3.14 MB)

My first instinct would be to avoid Zcombine. It can work OK but I don’t think is has ideal precision for compositing like this. I may be wrong, so please chip in if you know otherwise.

Another approach is simply to use Alpha Over composites. You render your background using the house/cube as a mask, and your cube/house you render on it’s layer (no mask needed), and make sure In Render Settings>Shading>Alpha ‘Transparent’ is set. So this will cut an alpha ‘hole’ in the background wherever the Cube is in front of the background. Then you just alpha-over the background over the foreground. I know that seems backwards :slight_smile: This will work without FSAA too, but may need tweaking depending on the complexity of the scene. You may just need more than 2 layers of course.

It seems that masking the cube with the grassy plane in your scene doesn’t work. I imagine this is a problem with strand masking… But the other way around as I described above is fine.

As far as saving Z data in your image file, AFAIK you will need to used a multilayer format like EXR. This is great for compositing anyway-well worth looking into. (I use half float most of the time-most of the benefits and much smaller than Full 32 bit).

Good luck!

Having another play with Zcombine and found another possibility.

If you turn on shading trasparency as I described above, but still composite the layers using Zcombine - Everything works OK even without FSAA. You just need to toggle ‘Use Alpha’ on the Zcombine node to get rid of the outlines.

By rendering this way, I imagine you could render your background once, save as EXR with Zbuffer, then render various building layers to combine with the background, without re-rendering the background for each. Let us know how it goes!

Looks like a great bug.
If I do it with Multilayer OpenEXR, right at the opening it shows the correct image (offering Z output) and later diminshes and a purple fill shows up.

Surprisingly it started to work.

The node editor contains two separate pipelines, the first writes the background to a multilayer OpenEXR file (and when it’s done, it’s all muted). The second does the rendering.

It seems that for some reasons OpenEXR doesn’t handle Z well and simply write it to the file is wrong. Thus when loaded, and Input/Image is set to “Generated” from “Single Image” “Z” shows up but gives corrupted or wrong data.

Instead I added an extra input to the OpenEXR file output (Tool shelf/Properties/Add input), wrote Z values into it and this extra layer was used as Z input.

Works with full sampled antialias as well, a perfect solution.

I include the .blend file.

ZCombine teszt.blend (3.14 MB)

Thanks for Your help.

Interesting! Might be worth making a bug report if there seems to be a problem with OpenEXR Z pass though. I’ll have a look soon and see if I can understand :slight_smile: