Something like SphereMask, but with a cylinder.

Hello everyone,

So basically want to use a material based, 3 dimensional mask to occlude parts of objects - just like in this video: Location based opacity.
The purpose of this is to dynamically hide parts of objects that would otherwise conceal the player character from the camera, like big columns in a top view game. Think of ActionRPGs like Diablo3 or Sacred.
Theoretically it works absolutely fine, but the sphere has just not the right geometrical form for me. I’d need something like a cylinder right between the camera and the player character that hides the objects that it touches.

Is there any way to define a tube (or any other geometry) as a mask just like the SphereMask in the material editor does it? It’d be super helpful to know!
Thank you very much in advance and sorry for my English.

1 Like

Hi,

I’m looking for the same thing. I’ve looked at the spheremask c++ code to see if I could create a similar utility for other shapes, but I lack the c++ knowledge to get it going.

It would be great if we could have all primitive 3d shapes as material mask.

1 Like

Ok, so I did some more research. I found out that the SphereMask it not really a sphere. What it does, is get the distance between A and B input and check that against the radius value. If you use 3 value input, it will act as a vector, so it will go in 3 dimensions ( someone correct me here if there’s a better explanation ).
For me to make it cylindrical, I took the axis which to stretch the sphere to, and made that value the same for the absolute world location of the object and the location the material is at. That way it will make it sort of cylindrical.

I’ve attached the material function Blueprint. You can attach that to the opacity mask of your material.

I hope this makes sort of sense and will help you further in your process.

1 Like

Wow, many thanks! This will save me a lot of time! :slight_smile:

did you even managed to make that cylinder ?

I created a simple material function to achieve this effect: