Edge Detection PostProcess Feedbacks

Hi everyone,

I’ve been working on an edge detection post process last week and I would like to share it with you.

First, few screenshots to show you the result :

[HR][/HR]

To summarize :

I started from this tutorial that use a sobel operator.
Tutorial – Creating outline effect around objects | Unreal Engine 4 blog
(a great start if you want to understand how edge detection works)

I modified the texture sample to add more details to the edges. Instead of just using the depth, I converted the world normals to view space and created a Vector3 with (Normal X, Normal Y, Depth).
(Inspired by a post from William Chyr and Lucas Pope)
http://williamchyr.com/2014/05/revisiting-edge-detection/
Return of the Obra Dinn [Releasing Oct 18]

I also added a falloff to reduce the intensity of the normals and the depth, so I avoid noisy details in the distance. I used a log2 falloff to keep some nice details at close distance even with a high max distance.
The normals and depth have a different falloff. I find it nicer when the depth maximum distance is higher to just have the outlines of far objects.

I share the blueprints (sorry for the bad screen quality but if you know how to take good quality screens of BP, just tell me), feel free to use it or modify it.

If you have any feedback to improve the detection quality, optimisation tricks, or any feature that you might think could be useful, tell me.

I hope it will help you :slight_smile:

[HR][/HR]

2 Likes

Cool, looks great! Thanks for sharing.

I’ve been trying to figure out something very similar to this - thanks for sharing!

Thank you a lot for that mate

great work, thanks!

I’m trying to recreate this from your BP diagrams, but it’s not working. Any chance you could share the materials/project?

@Guthmann I noticed some artifacts in 4.17 when using the thinnest line width (0.5). Maybe 0.5 isn’t supposed to work?

Actually a super cool implementation! Nice and easy to follow :slight_smile:

D/L the version I put together. I made some small changes to the UV inputs before the depth/image combination to allow for small tweaks to the final output. Really gives it a drawn look, I think. Also added lighting to it too, so it affects depth, colour, and lighting.

2 Likes

Wonderful stuff, thanks for sharing. All I can really think of myself that can be added in as a feature is, have the line thickness able to be determined based on distance, if possible. I dont know very much about graphics programming, so I cant try it for myself. Could that be done easily?

Also Construc_, would you be willing to make a bare bones project of these files working on there own so they can be migrated into other projects? Having the .uassets by themselves doesnt connect the references to each other and it breaks the material and has other issues. If so, that would be pretty sweet

Good work, Thanks for sharing !

Is there any chance to recreate the material to use on normal material that is not PP so I can apply to specified object? I’ve tried to change Scene Texture nodes in NormalDepthCombine function but it does not work with any regular nodes. Any ideas plz?

You can apply it to specific objects using a stencil instead.

yeah, I did. It worked well but there is one thing that this PP material does not work with transluency. Already tried reodering PP before transluency but does nothing. I posted my question in UE4 Facebook community as well and someone told me to fix the MF. So I think I might get a proper answer here :smiley:
https://www.facebook.com/groups/ue4d…1778071020557/

Moreover, the edge dectection material is far more useful to implement curvature shaders such as soften the edges so I’d like to try on paticular mesh.
Below is the effect I want to recreate in UE4.

Translucent materials do not write to depth.
You can write to custom depth (option in material), but then you would need to merge custom depth with depth to be used by the sampler.

Sorry for the necro but do you still have those files? The mega link is dead, unfortunately