WorldSpace UV texturing

Looking to learn how to make a shader that does something similar to this
https://imgur.com/a/o6pBrqk

i know it uses the z buffer somehow but i cant seem to get the effect replicated properly regardless of what i try

There is a number of things that come together here:

  1. Using the stencil buffer to check whether you are inside or outside the volume.
    make stencil shadow?

  2. Using a CommandBuffer to adjust the g-buffer after opaque (deferred) rendering is done.
    Unity Blog (Specifically the decals section)

  3. Determining the world position and normal from the g-buffer.
    Shader to map camera space to world space

  4. Apply world space (triplanar) mapping.
    Mapping texture to world position instead of object position?

The guy said he uses a directional light and sampler2d_cameradepthtexture to access the depth buffer, then calculates the world uvs using the depth buffer from that

https://www.patreon.com/posts/quick-game-art-16714688

That shows you how to do world space texturing (which is called triplanar shading)