This is the effect im looking to recreate: How would one achieve this? The video i pulled this from does this using Ray Marching, however thats reliant on having a DistanceToObject function. If my object is terrain of some sort, this wouldn't work because theres no DistanceToTerrain function you could create, similarly for complex shapes as well. I know this is achievable with stencil buffer but that creates a very obvious hole that you'd have to add additional meshs to to look complete, not a solid hole. Any ideas?
There's no solution to what you're looking to do without using distance fields. Stencils are an inherently 2D thing. You can kind of fake the appearance of volume in some very controlled and contrived setups, but to match the above example is 100% distance fields or nothing. Even ignoring the 2D limitation, Unity's shadows aren't always affected by stencils properly as Unity ignores the render queue order when rendering depth textures like the camera depth texture and shadow maps, so you'll be at the mercy of whatever random order Unity decides to render objects there. Now you can generate a 3D texture that holds the SDF of any object you want, mesh or otherwise, to support complex shapes. Unreal makes significant use of these, but there's nothing built into Unity to do this. There are free projects around with implementations though. Like this one: https://github.com/xraxra/SDFr For simple shapes analytical models are far more efficient than an SDF. A sphere for example is just the distance to a point.