I’m trying to figure out some GPU based solution for seeing through obstacles that occlude player character. It’s for a topdown/isometric game. Here is what I have for now, prototyping stage:
The material has a SphereMask in position of camera + offset towards camera forward vector, so it’s around between camera and player. The mask serves as an alpha for DitherTemporalAA plugged into Pixel Depth Offset.
This is my first idea: Every object that can be an ‘occluder’ (e.g. trees, buildings, etc.) have this masked ‘transparency’ material logic (I’d probably collapse it to a function) added to its material.
It works, but as you can see, the fade-off starts too early because of sphere mask radius. If I decrease the radius, it won’t work at all. That’s why it’d be great to have something like CapsuleMask, where besides capsule position + radius we could also control capsule height. This way we could have a mask like that, so it would work perfectly for seeing through obstacles:
… I suspect that I could solve this by setting multiple sphere masks uniformly distributed between player and camera and adding all of them in material, but is there a better solution? Something like a capsule mask/cone mask that works similarly to the SphereMask…? But is it possible? I’d be grateful for some hints.
PS. I’ve tried CPU based solutions like line/multiSphere traces + hiding/changing object material, but I need a solution that will hide only a part of object, exactly around player character. This is because with the CPU solution, when camera detects e.g. tree leafs, then it hides whole tree instead of only the leaf area that is occluding player.