White background in AO pass instead of black

I’m using AO a lot, but each time I need to tweak it in node editor and it is not the cleanest solution.

Is it possible to write script or addon to have a white background in the AO pass?

It’s black because there is nothing but you have alpha transparency.
It’s not really python related I think.

Why is this an issue?

I was also not sure if it is coding related…

I’m using the AO pass in the node editor to multiply it with combined pass. When the environment in AO pass is black, it darkens environment in the final image. I need that environment untouched by AO pass. That is why white and not black.

I do mostly animations and in some situations, this tweak is doing unwanted results (with fine details…) It would be much simpler and always correct with white bg in AO pass.

You should use a transparent background.

Thank you Vincent, nice solution, for stills I will use it. But as I mention I do mostly animations and with motion blur and DOF this is still not what I’m looking for.

What’s the problem? This is working also with animation, motion blur or DOF, but the setup may differ. Can you post an example that doesn’t work?

I like your simple setup, but using transparent background and alpha in animation with MB and DOF makes blurred alpha. I’m not english native and its difficult for me to explain it, but see the difference in the images. First one is your setup, second one is my tweak and the last one is that blurred alpha…

I don’t understand coding nor python. It only looks to me as not big deal - “just make the environment in AO pass white”, but may be, it is not so easy or maybe even not possible.

This is normal! The best you can do to avoid that is to separate the foreground and the background like I’ve showed in my previous post.

Post your blend, and I try it with your file but I’m sure it should work.

Ok, here is the .blend file, just removed textures to keep it small.

Anyway, I still would like to know if there is a way to get the white background in AO pass(without node editor tweak). :wink:


montalu AO thread.blend (6.78 MB)

I’m pretty sure Blender can’t have white BG at render time in the AO if there is no geometry. Maybe I’m wrong? but it seems logical to me.

I’ve changed a bit the setup to make it working better in your scene. No blur or ramp is needed and motion blur is not an issue.
The black edge artifact is most of the time because of premultiplied alpha. Blender multiplies each channel (RGB) by the alpha when the set alpha node is used.If you don’t know that, it can cause some issue!

montalu AO thread.blend (6.69 MB)

But also, you don’t really need AO in Cycles. Self shadow is already more accurate!

You could also render the AO pass from another render layer where you have a big white plane on the back of everything, covering the sky :stuck_out_tongue:

Thank you Vincent, very nice setup. I have created a nodegroup from it and will for sure use it.
I know that cycles generate accurate shadows. The scene in this thread was not typical where I use AO pass. I mostly use it to emphasize some geometry in instruction animations.

Gspin it is also a good solution, but the setup is not easier as nodes from Vincent and also rendertime is not the best… Thanks for the tip anyway.