Better Sphere mask ? Mask several materials on multiple meshes by another mesh.

17b5b2215b4274046d80e6e36d96326f6466bd68.jpeg

Hi, I would like some help creating this effect : https://youtu.be/yqg1bbiiEgE?t=7m50s

Description of the effect : - I want the materials of walls, props, etc… To fade and become transparent on a certain radius when the player is behind.

I tried some tutorial about sphere mask, but couldn’t apply a sphere to my needs : I want a similar rendering from a topdown perspective and something smart enought to fade the upper levels of a building and let unfaded lower levels (= must be opaque under player feet).

Capsule works like many spheres between its start and end points, so maybe you need to use few sphere masks along a line between player and camera locations.
But in case you need to hide whole floors above player, you should use something like
Clamp( 0, 1, dot( (world position - player location), (0,0,-1) )
It will give you set of 0 values above player location, and >0 below it.

Not sure how you are thinking this work, but sphere mask is a component in the material editor. It’s not a real mesh in the editor, or at least that’s how all tutorials i watched explain sphere masks.

So i have no idea how you would place multiple sphere between camera and player :confused:

Could you explain further ?

well, i’m not tried this on practice, but theoretically :slight_smile: it should look like:

  • create material parameters collection (mpc) and set player location as vector parameter inside it.
  • update this parameter from character blueprint
  • reference this mpc inside some basic material of your environment.

From now you can create 2 sphere masks - in camera location and character location (you can get camera location right inside material with “camera position” node). For example you use sphere mask with radius = 500.

distance(playerlocation, cameralocation) - distance between player and camera. if distance == 2000, you need at least 3 additional sphere masks - on 500, 1000 and 1500 uu from camera.
location of 1st one is - camera location + (camera direction vector500), 2nd - camera location + (camera direction vector1000), and so on…

oh, maybe this is not really great setup… you can use only 4 masks instead of 5:
1st one on distance 250, 2nd - 750, 3rd - 1250 and 4th - on 1750.

something like that…

Of course, if your camera always have the same direction and distance from character, you don’t need to pass character location to material. you can calculate it with the same math - camera location + (camera direction vector * distance to player character)

Oh, I didnt mention that your basic environment material must be masked and you will subtract this sphere masks from its opacity.

Thanks,

I was looking for a less hardcoded method because right now, all sphere mask need to be specified at the start fo the level… Doesn’t seems very modular and easy to use.
I’ll pass those answers to my coworker and see if we can get this working.

you can trace from camera to character and not use sphere masks if nothing between them.