Edge Outliner Shader

I’ve put together a shader that draws outlines of shapes by passing the normal and depth buffers of the viewport through a Sobel convolution. You can adjust the size of the kernel to make the lines thicker or thinner and even taper.

6 Likes

I know just some of these words :slight_smile:

Amazing work! You should put a link to the repo too, as I’m sure someone will be interested in it. I’ll definitely play around myself.

1 Like

Thanks! I’ve added the link.

1 Like

Really cool stuff. This is a hard problem to solve. Have you seen the new feature added in Godot 4.5 beta 1?

They’ve added stencil support.

TBH, other than the screenshots, I don’t know a lot about it, but it seems pretty exciting specifically for the purpose of outlining. Personally I’ve tried about half a dozen versions and all of them are a bit janky where corners don’t always line up. Yours definitely seems better. But as @wshs says you seem to know your stuff. So I’m curious what do you think of this new feature?

1 Like

I didn’t realize the Godot team was adding that for 4.5. It might be a good replacement for the depth test in this shader. I’d like to know how they’re exposing it to the shader API.

1 Like