# Something like SphereMask, but with a cylinder.

**URL:** <https://forums.unrealengine.com/t/something-like-spheremask-but-with-a-cylinder/315000>\
**Category:** Rendering\
**Tags:** unreal-engine, mask, top-down, question\
**Created:** [April 14, 2015, 12:01pm UTC](https://forums.unrealengine.com/t/something-like-spheremask-but-with-a-cylinder/315000 "2015-04-14T12:01:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Datarecovery09](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Datarecovery09](https://forums.unrealengine.com/u/Datarecovery09)\
**Post date:** [April 14, 2015, 12:01pm UTC](https://forums.unrealengine.com/t/something-like-spheremask-but-with-a-cylinder/315000/1 "2015-04-14T12:01:42Z")

</div>

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](https://www.youtube.com/watch?v=CkEueafOvFg/).  
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.

---

<div class="post-metadata">

**Author:** ![MrMastermindNL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrMastermindNL](https://forums.unrealengine.com/u/MrMastermindNL)\
**Post date:** [April 17, 2015, 8:11am UTC](https://forums.unrealengine.com/t/something-like-spheremask-but-with-a-cylinder/315000/2 "2015-04-17T08:11:17Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![MrMastermindNL](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@MrMastermindNL](https://forums.unrealengine.com/u/MrMastermindNL)\
**Post date:** [April 18, 2015, 2:04pm UTC](https://forums.unrealengine.com/t/something-like-spheremask-but-with-a-cylinder/315000/3 "2015-04-18T14:04:43Z")

</div>

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.

 ![39239-spheremask_material_function.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/7/6d7e5f9b18e6e035e7c678eabcaec94615f71d96.png)

---

<div class="post-metadata">

**Author:** ![Datarecovery09](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Datarecovery09](https://forums.unrealengine.com/u/Datarecovery09)\
**Post date:** [April 18, 2015, 10:09pm UTC](https://forums.unrealengine.com/t/something-like-spheremask-but-with-a-cylinder/315000/4 "2015-04-18T22:09:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![MarcoMariaRossi](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/marcomariarossi/32/1069093_2.png) [@MarcoMariaRossi](https://forums.unrealengine.com/u/MarcoMariaRossi)\
**Post date:** [November 20, 2018, 8:08pm UTC](https://forums.unrealengine.com/t/something-like-spheremask-but-with-a-cylinder/315000/5 "2018-11-20T20:08:01Z")

</div>

did you even managed to make that cylinder ?

---

<div class="post-metadata">

**Author:** ![SteveProteau](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveProteau](https://forums.unrealengine.com/u/SteveProteau)\
**Post date:** [May 16, 2024, 10:39pm UTC](https://forums.unrealengine.com/t/something-like-spheremask-but-with-a-cylinder/315000/6 "2024-05-16T22:39:16Z")

</div>

I created a simple material function to achieve this effect:

  
 ![Fade Effect](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/7/7/2777bf43ef5676899f96563aed4b9479bd126108.jpeg)  
 ![MF_FADE](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/1/2/f1264eae38bf02e1af2df49ae07ff18c058e2bd9.png)  
 ![MF_FADE2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/6/a/56a2cb317b501d7af69e9afd9eb7916a3cc051fd.png)
