Rendering a stroke outline on an alpha textured mesh?

I’m assuming that this is a post processing question and not a material texture one, right?

Anyway, I have a very simple texture applied to a mesh plane which has an alpha image.
I want to render it so that I can get a Photoshop-like stroke outline from the alpha edges of the texture. I want to be able to control the thickness and colour of the stroke, too.

This is NOT a stroke outline for the mesh itself but only for the texture alpha.

Can anyone please let me know how to achieve this?

Oh, and please explain things to me as if I was an idiot because I don’t up complex things too well.

Thanks in advance.

Cheers,
Paul
(mix_mash)

What does the alpha look like?

Just a random shape at the moment. But it’s for any hard edged alpha I plan to use in the future, really. Text, for example.

So, is it possible?

Paul
(mix_mash)

I think you can try the dilate/erode node then subtract operation to get the outline. I don’t really know because I don’t have the image.

1 Like

You don’t need the image! Create a basic plane mesh, type in some large text in Photoshop or something and save it out as a jpg or whatever (make sure that the text is black and the BG is white, or vice versa), create a material and set that image as an alpha texture for the mesh. And that’s it.

I will have a try of your suggestion but I am not good with nodes so I do not know if the setup will work or not. I need a step by step guide for this kind of thing.

Thank you anyway.

Paul
(mix_mash)

Is this what you’re trying to do?

edit: actually just tried Lehuan5062’s method, much better, id say thats the solution.

1 Like

Ahh, no! I see what the issue is here. I should have mentioned that I want the stroke to be an OUTER stroke and not an inner one. I’m sorry that I forgot to mention it. I think that maybe when I said that it would be like “a Photoshop-like stroke outline” that people would automatically understand what I was trying to say.
My apologies.

No, it needs to be an outer stroke that I am looking to create.

Anyone?

Paul
(mix_mash)

It’s pretty simple with the “dilate/erode” node, as lehuan5062 suggested. See attached image for the node setup.

1 Like

This looks interesting and I will try it out.

Is this set up material-based or scene-based?
Meaning: Can I set this up so that each material can have their own stroke colour and width or does this only work only the global opacity/alpha of the scene?

Thanks.

Paul
(mix_mash)

Dilate/erode is in compositing. It works for each image/render layer that has an alpha channel.

I tried setting everything up and I (painfully) managed to get the nodes set up like yours in both 2.79 and 2.83.5 BUT it wouldn’t display or render any outline stroke.

I should mention that I did set up the material via regular methods (IE not nodes) but the compositing part was done with nodes. I tried rendering/viewing in Blender Render, Eevee and Cycles. Still no result…

This is getting frustrating because I know that this would work but I seem to have difficulty finding out what I am missing. I struggle with nodes, in general, so it takes me longer to figure out other peoples’ solutions because I don’t know the complete set up.

Paul
(mix_mash)

It can be way easier if you can just share the image to us.

I have already mentioned this before but the image does not matter.
I used a simple black and white jpg image to act as an alpha mask for the material of the plane using regular methods (not nodes) in Blender 2.79 and 2.83.
I did not use a png file with existing alpha channel, if that is what you are thinking.

Paul
(mix_mash)

Ejay, would you be able to be kind enough to provide me with that Blend file and the image used for the alpha that you used in your example so that I can look at it and see what I may have done wrong?
The file needs to be for version 2.83.5 because that is the latest version for me (2.9 doesn’t work for me unfortunately :frowning: )

I hope I’m not asking for too much.

Thank you for your time.

Cheers,
Paul
(mix_mash)

I don’t have the original file but I recreated it : stroke_example.blend (657.1 KB)

(I almost missed your message. Make sure you tag me like this- @ejay - so that I get notified!)

@ejay Sorry about that. I’ve never used the ‘@’ system before. Anyway, thank you for your file. I’m still not getting the outline showing. I have a feeling that it either has something to do with my settings, my crappy internal video card or my crappy cheap laptop.
I appreciate your help anyway.

Sorry for the trouble.

Cheers,
Paul
(mix_mash)

What do you see when you render an image? (F12, not in the viewport)

The outline renders perfectly fine but I was hoping that I could get the stroke to show up as a preview in a viewport so I wouldn’t have to keep rendering to see the results after making tweaks to the stroke.
I mean, you seem to have it showing up normally in your viewport and, yet, something is just not working out in mine.
I do plan to use multiple plane objects, offset each on the Y axis slightly, that will all use the stroke effect. I’m not sure if Blender may have restrictions in regards to transparency for realtime viewport settings or not especially with multiple layers of transparent objects.

I have a feeling that I am just missing out on some settings or something.

By the way, thank you for your help.

Cheers,
Paul
(mix_mash)