Outline in cycles?

Is it possible to create an outline in cycles? Using sobel from the alpha output on the image doesn’t work in cycles.

Any ideas?
Thanks.

First thing that comes to mind:

http://i.imgur.com/NuOFQCyl.png

Or you could use freestyle.

Sorry for the super late reply, but I tried that and it didn’t work unfortunately.
I think it’s because my scene is not transparent. It doesn’t show up checkerboarded when in the render result. I have the world rendered, maybe that’s the problem?

I saw this http://timbarnerstudio.com/animation/pages/blender_edgerender.shtml

He used the
Cycles + Blender Internal Engine and the Sobel Filter
I made a new material, called toon_edge just like him, except there is no “Less than” node or “Minimum” in the search.

Yes that’s the problem. You could separate the bg from the object with two render layers: enable environment pass in render layers and render with transparent background (render properties -> Film -> transparent) and then composite your object over the bg.
Or, you could do the same but only use one render layer, two is more clear though.
Or you could enable object index pass in render layers, set object pass for object, and use that to separate the object in compositing:


Those are in the math node.

You could separate the bg from the object with two render layers: enable environment pass in render layers and render with transparent background (render properties -> Film -> transparent) and then composite your object over the bg.

How do I composite my object over the bg exactly though?

Or you could enable object index pass in render layers, set object pass for object, and use that to separate the object in compositing:
Not sure I follow this exactly, I enabled the option but I don’t know where to proceed =/

I tried following your image, but I don’t seem to have IndexOB on my Render Layers node.

Thanks for the help so far by the way, it’s really appreciated.

I tried Minstrel’s solution as well, and it does work but the image bg is black, but if I enable transparency I can see the outline.
I want to combine that with the world’s white color.

EDIT: In the meantime, I followed this http://www.blendswap.com/blends/view/67827

and it does work with the scripts he used. The problem is, this is uses the open shading language which only runs on cpu, and it’s very slow.

Enable film transparency, add another render layer for the background, enable environment pass, and then combine them in the compositor


Render layers and passes are on the right. BG render layer renders an empty layer, it has environment pass enabled so that we have access to it in the compositor. Passes also have object index, which you didn’t enable previously.

That way you have the cube separated and has transparent background, which you can use to add effects to. When you’re done, you just have to add it over the background.

Thanks, almost got it.


I can toggle the background on and off, and the bg is white.

I am not sure how to get the black outline though, it’s white at the moment.

Got it, using two render scenes. The sobel filter worked nicely once I played with the colorramp.


Thanks for the help again

RenderLayer.001 (Empty one) has Environment checked.

Under Film-> Transparency is checked.

Attachments


There are so many ways to do this but the way you have it now, you get jagged edges for the outline because of the sobel filter.

This is not hard.

When you have your object separated so that you get the alpha channel, it’s basically a matter of moving the alpha channel edges and then multiplying with that mask. Why? Because in the alpha channel you have two color values 0 (black) and 1 (white). When you multiply any color value with 0 you get 0. When you multiply any color value with 1, you get the same value.

Now if you blur that mask, you get a grayscale image where values go from 1 to 0 gradually. With colorramp you can adjust how immediate that change is, effectively adjusting anti-aliasing with a nice slider and resulting in jagged-free lines.

Combination of blur and colorramp also spread the pixels and you have to decide if you want the borders to take away from the original object or the background. If you don’t want to lose any color from the original object, then multiply the background with the mask (invert if necessary) and put the original object over that result.


You can shift+LMB click on any node to connect it to the viewer node. With backdrop enabled or if viewing the viewer node output in the UV/image editor, you can easily follow what is happening in the nodes.

Thanks, I noticed the jaggies too, looks nicer this way.

Knew what was going on, just wanted to just wanted to get this over with though.