Border cleaner node

Hey all

Just couldn’t force myself to study for an exam i have on friday so i thought i’ll be more useful doing something that bothered me for quite some time.

When You render a couple of render layers and try to mix them You’re probably going to get ridiculous seams (borders) all around a layer. It’s quite a simple oversampling problem, RGB shouldnt be touched when a sample with alpha 0 is found (meaning the ray didnt collide with anything).
Unfortunately Blender Internal mixes the sky color with the material color in such situation. So… if the sky was black (eg. sky rendering was turned off for a layer) You’ll get good alpha values but whenever alpha is below 1, rgb values are mixed with black which results in a nice border whenever oversampling encountered both sky and some object.

So I’ve created a simple Node group which multiplies rgb values back to the values they should have. And here are some results:
( without the node -> with the node)

Mitchel filter at 0.8 size (blurry so the edges are wider)
http://img12.imageshack.us/img12/3460/bordercleanerbeforezv7.th.jpghttp://img12.imageshack.us/img12/5532/bordercleanerafterly4.th.jpg

Mitchel filter at 1.2 size (nice and sharp)
http://img11.imageshack.us/img11/1414/bordercleanerbefore12gt3.th.jpghttp://img11.imageshack.us/img11/8133/bordercleanerafter12xj4.th.jpg

And now, how to use the node. Quite simple actually:
http://img120.imageshack.us/img120/7534/bordercleanernode2gd2.jpg

  • Inputs:
    [LIST]

  • Image - image to repair it’s rgb values, layer’s sky color must be black! (sky rendering turned off for the layer)

  • Fac - image’s alpha

  • Output:

  • Image - repaired image

[/LIST]
And the actual node group inside with a zoom on the edges:
http://img12.imageshack.us/img12/7278/bordercleanernodext3.th.jpg

And of course the .blend file
Hope You find the node useful :slight_smile:

…now back to studying for the exam…
greets
-Kroni

PS. this is just a work-around, the problem should be fixed with some changes in BI code

Great trick kroni! Thanks for this.

Sorry - I don’t want to disappoint you, but the problem has already been solved in blender code. All you have to is to turn on the “Key” switch in the messy Render buttons (below OSA settings). See the release log (Full Sample Antialiasing) for more details.

I might be misunderstanding something, but isn’t this what we use premultiplied alpha for?

-mats

Hmm. Honestly, havent used premultiplied alpha, but i checked it now and actually it’s more of the effect of Key background blending than Premul (pre-multiply). Premul will not render the sky but will multiply rgb by alpha, while Key leaves rgb untouched.

The difference is You can use the node group on per-layer basis instead of global render setting, which makes sense if You actually render the sky on some background layer (if You’d use Key blending the sky wouldnt be rendered at all).

Still, thanks for pointing it out :slight_smile: If You could set sky/premul/key blending on render layer level then it would serve the same function.

greets
-Kroni

Hi There!
Man!!! This problem was always present in Orion Tear, and I couldn’t do anything about it… Thanks kroni :wink:

Oh, you’re right! Sorry again.
I couldn’t understand why the release log says something different than things seem to be, so I tried to turn on other buttons I’ve never used. And FSA really works :slight_smile: You have to turn on “Save Buffers” and then “FullSample”. It gives the desired perfect results - including sky if needed.
Only with one big problem: the compositing time increases rapidly. With a simple set of Alpha Combine and 8 AA samples it was about thrice more. But that should be okay I guess, the actual render time is usually way much longer than the compositing time.

This is great. Been trying to fix this for 2 years! Without and with node:

Attachments