Multiple location based opacity

Hi there,

Sorry but I have a newbie question here,
I followed the “Location Based Opacity” tutorials - YouTube and everything worked perfectly.
Although it only works for one BP. So my question now is how I make this work for multiple actors?
Thank you in advance :slight_smile:

P.S. Image attached. Both spheres should reveal the white object.

You basically have to do exactly the same thing, only multiple times. So you have to transfer a set of locations to the material instead of just one and you have to duplicate the shader nodes (or turn them into a function that you can use multiple times) for each potential occluder.

It is working. Thank you very much for the reply :slight_smile:

Hey,

could you elaborate on how exactly you accomplished multiple spheremasks?

Nvm I figured it out on my own. Basically you copy every node up to the sphere mask, create a second vector parameter in the paraCollection and connect both sphere mask with a add node. You can also use these spheremasks in a lerp to load different textures.

I don’t know if it’s OK to bring up this thread after it’s been quiet for so long but I was wondering how you might do this? How would I set up a material function to dynamically handle any number of potential occluders? I mean if I knew that I wanted two occluders/two sphere masks I’d just create a parameter for each of them. What if I wanted to be able to spawn more after the game starts and add each occluder to the material as it spawns? Is this even possible?

Did you find the solution?

Yes and no. The best way to do this would be to use an array of vectors so you could dynamically add and remove sphere masks. This would be the solution IF UE4 materials supported loops and arrays.
Until they add this feature there is no way to do this through blueprints, unfortunately. Not sure about C++ but I can’t see why you wouldn’t be able to.

This is not really a UE4 limitation though, shaders in general do not support dynamic arrays. Additionally there are hard limits on instruction counts depending on your hardware and the graphics API used, so you always want to ensure that there is a limit to the number of loops in a shader.

Didn’t know that. I’ve only ever worked with UE4. I just wonder how other games outside of UE4 do it. I’d love to take a look at some of their fog of war solutions.

Considering the large number of possible influencers this indeed wouldn’t really work for a fog of war type scenario. Most games tend to use a dynamically updated texture for those. Keep the texture fairly low res and then smooth out the edges in your shader and it should be fairly cheap.