Hey! This thing is easy to copy, but please, at least try to understand what you're doing instead of mindless copying. Thanks!

Edit: Updated the code, so it now works on mobile ;)
Edit: Added an optimized version that uses only 4 texture samples at the end of this post.

Fun fact: I've tried to create the whole effect entirely in Custom node, but it was impossible. SceneTextureLookup is available only if the preprocessor flag NEEDS_SCENE_TEXTURES is defined. The flag is defined only if your material uses SceneTexture node.

First you need to create a material in PostProcess domain:


Next create a Custom node, set Output Type to CMOT Float 1 and paste this code:

More info on Custom node here.

float texels[9];
int id = 0;

float2 uv = ScreenAlignedPosition(GetScreenPosition(Parameters));

// iterate through surrounding texels
for (int i = -1; i < 2; i++)
    for(int j = -1; j < 2; j++)
        // calculate uv offset - since uvs are from 0 to 1, we have to get the
        // fraction of screen per pixel (texel size) and multiply it by the direction
        // told by loop iterators (-1, -1) will be the top right corner (1, 1) - bottom left and so on
        // ---
        // Texel Size: View.ViewSizeAndInvSize.zw
        // ---
        float2 o = View.ViewSizeAndInvSize.zw * float2(i, j);

        // SceneTextureLookup returns built-in engine's buffer by index
        // id 13 -> CustomDepth. You can find the full list in
        // Material Editor's SceneTexture node in SceneTextureId dropdown
        // (indexes start with 0 (zero)! ofc)

        // let's set the texel to 1.0 / 5000.0 - getting rid of division fo optimization
        // we need to divide out custom depth value by some big number, cos it will have
        // a value of the distance to the object (in centimeters) and we only need 0-1 range
        float4 texel = 0.0002;
        texel *= MobileSceneTextureLookup(Parameters, 13, uv + o).r;
        texel *= SceneTextureLookup(uv + o, 13, false).r;

        // put the average components value to the array
        texels[id] = texel;

// take the average of differences between pairs of opposite texels in our matrix
return (abs(texels[0] - texels[8]) + abs(texels[1] - texels[7])
        + abs(texels[2] - texels[6]) + abs(texels[3] - texels[5])) / 4.0;

There isn't much work left to be done. You just have to add your material to PostProcess Volume's blendable materials:


And set Render CustomDepth Pass on the object you want to have an outline on:


That's it.

A bit less clear, but an optimized version (it needs only 4 texture samples instead of 9!). Works both for mobile and PC.

#define tex(x, y) 0.0002 * SceneTextureLookup(uv + ts * float2(x, y), 13, false).r
#define mobtex(x, y) 0.0002 * MobileSceneTextureLookup(Parameters, 13, uv + ts * float2(x, y)).r

float2 uv = ScreenAlignedPosition(GetScreenPosition(Parameters));

float2 ts = View.ViewSizeAndInvSize.zw;

return (abs(mobtex(-1, -1) - mobtex(1, 1)) + abs(mobtex(1, -1) - mobtex(-1, 1))) / 2.0;
return (abs(tex(-1, -1) - tex(1, 1)) + abs(tex(1, -1) - tex(-1, 1))) / 2.0;

Edit: you can add thickness by simply replacing
float2 ts = View.ViewSizeAndInvSize.zw;
float2 ts = View.ViewSizeAndInvSize.zw * Thickness;
You can exchange Thickness with any float or pass it as an input named Thickness to your Custom node. More info on custom nodes here