Download

Top down game hiding foliage that obscures the camera

I’d love to know what approaches people are taking to mask occluding objects in a top down game. Basically, anything that hides the character should be made see-through at the point it occludes them, allowing the player to see their character at all times.

Obvious examples are the roofs to buildings or tree canopies, and my intent is to have a circle “vision” where the camera sees through objects to reveal the player behind. A good example would be the game Divinity: Original Sin 2. There are various potential approaches to this, but I have been struggling.

One approach I have taken so far has given mixed results. I am raytracing from the camera to the character to identify occluding objects. If I hit one, I manipulate the material to make a circular mask at the location of the ray hit to give that area opacity, allowing it to be seen through. This technically works - but I do not think having all my potential occluders materials be masked transparent ones is very efficient, it makes the shadows look bad, and it doesn’t appear to work with the foliage system - which is crucial!

If anyone has an approach that works with the foliage system, or anyone has taken an alternative approach to this sort of problem, I’d love to hear it.

Looking around on youtube, there’s a decent example of the sort of thing i’m trying to replicate:
https://youtube.com/watch?v=Sg52K_cCRuw
It should be a case of raycasting to a point and inserting circular masks on materials that intersect the ray, but I’ve not had this work to an acceptable degree :frowning:

Do it analytically in material tbh. No reason to raycast anything. Define some sort of easy procedural shape(box, cylinder, capsule, we), position it between camera and player, aligning it with camera-player line and hide all fragments within this shape. Do it in base pass of every object that needs to be hidden.

Sounds good - do you have any hints? Materials aren’t my strongest suit, wasn’t sure how to avoid the need for a trace.

This is tutorial thoroughly covers how to make the effect.
https://youtu.be/GXbE0IqbA7w