Outline mask texture?

I have a mask texture like this for example.

What I want to do is apply it to a plane with a material, but in the material, color in the mask (white parts) in light red and the edge of the mask (where the white meets the black) in a darker red, with some sort of border thickness, so the result looks something like this.

I know how to color in the white part in light red (or pink), by just mutltiplying the mask texture by a pink color. But does anyone have any idea how I could create the darker red border?

1 Like

Anyone got any ideas?

You can make separate texture mask for the outline, that would be the simplest option.

Second option, make the outline in your material. That requires sampling the texture several times:

You can also increase the outline ‘precision’ by sampling the texture 8 times (with additional offsets like (1,1), (-1,-1), etc.).


I will give that a try. The mask texture is generated at runtime using a render target, so I need a dynamic approach and it looks like your solution is what I was looking for. Thank you.

Absolute beast… was literally trying to run this logic for like 6 hours until i decided to look for help… got pretty close lol. thanks bro

1 Like

Hey guys, I need to do something almost the same but instead have the outline go in, because the texture fits exactly the full image, so it needs to go in because if it goes out it goes over to the other side.

Nice concept, could this be made more bulletproof for other shapes?

I tried adding more sampling, but I imagine using this method you would realy need like 360 texture samples?

I get this result with Star and hexagon

For Anyone trying to find another solution for outline :slight_smile: