I was wondering if there was a way to stop an actor from rendering partially when for example it enters a volume. In my level i have a mesh for my water and ive made a ripple effect with a particle system for when i collide with it(still working on it) and i ran into a problem where if the character enters the water near the water meshes edges the particle effect kind of expands out of the area i want it to be in. So i was wondering if it was possible to sort of border out the water area with volumes surrounding it that would stop the particle effect from expanding out of the water. This wouldnt be a problem with normal water but mine happens to defy gravity a bit since it has no physical edges, its just a box.
Thanks for any help!
You can do this inside the material.
Make a material and give it some instance parameters representing the box edges. (This will be easiest if the box for your water is axis-aligned – meaning that it’s straight-edged along X and Y and not rotated at all. If you need it to work some other way, let me know).
The material would basically do this: get the world position. If the world position is between the upper and lower limits for your box, set the opacity as usual. Otherwise, either set it to zero (for a hard edge) or fade out (you can use a lerp to blend out as the world position approaches the boundary).
I don’t know how much you know about materials so if you need more info, let me know.
Thanks for the answer! I’m quite a newbie when it comes to materials so additional assistance indeed would be great! I can’t access my real assets at the moment so these placeholder assets will have to do for now. Here’s my setup:
The red one’s the waterbox and the blue is the ripple effect i want to border out.
The advice you gave sounds like it would work really well except i don’t really know how to start. Here’s the new material(or should it be in the waterbox’s or the ripple’s material?), it isn’t much but there’s some parameters that don’t do anything right now:
The ripple effect’s material just has a parameter plugged into the opacity input.
I experimented with a sphere mask and it got me to a good place but do you know if there is a way to get a “CubeMask” of some sort since the waterbox is essentially a cube and i think that might solve my issue?
There is currently no CubeMask function but it is fairly straight forward to make. I will add this to a future UE4 release, probably 4.9:
Works slightly different from spheremask. You set the edge falloff in units rather than 0 to 1 hardness. Making it work with hardness would require some more math and not worth it IMO.
Thank you so much! I tried it and i got it working. I control the bounds with a ParameterCollection and i tried setting the size of the bounds via a blueprint ( a blueprint based on my waterbox static mesh), but i was wondering if there was a way to set the size the same as my waterbox’s scale? I tried using Get Relative Scale 3D and Get World Scale and setting that as the new parameter value but I didn’t seem to get the right results with those. I can, however, control the size with just a variable of the vector type but that requires changing the values manually.
Also this is probably stupid but is it possible to move the location of the mask like with the SphereMask since now it’s located in the origin of the world? And is it possible to add multiple instances of this if I wanted to have a few of those waterboxes?
EDIT: I got two of them by duplicating the nodes and adding their output with the 1-x node. But i dont think thats the best way since i have to manually adjust the size. I don’t have the location control yet though.
Yup, to move it just requires one subtract at the very upper left of the above screenshot.
Do “Absolute Worldposition” minus “Location Center” just before the ABS node.
Getting the size is possible. Try using the “Object Bounds” material node. There are a bunch of nodes about getting object scale all which might be useful depending on the exact case.
ObjectRadius: the bound-SPHERE radius with scaling
ObjectLocalBounds: this is the size of the mesh without scaling with additional min/max positions
ObjectBounds: bounds in the world
ObjectScale: this gives you just the scaling factor on the component.
You can see that using some of the above you can create the others in different forms etc.
Thanks! It works fine with one instance of the water but i get this weird problem when i add the two together:
And the color changes when i scale or change its position but it doesn’t change when rotated.
The problem is with the way i add them here:
Do you know anything about this?
Apparently I just had to build the lighting and it seems to be working now. Thank you so much for the help!
np. Minor note but technically using “max” instead of “add” as the final node gives you a more accurate intersection between the two distance fields. I doubt it matters in your case, but if you are ever trying to build a specific shape out of many such fields combining with max will generally be better.
Ok great thanks!
I kind of ran into to a new problem with this. The ripple effect uses refraction, (it’s basically a modified version of the cave effects project’s ripple particle system), so that doesn’t get masked out. So is there a way to hide that too or do i have to give up refraction on my effect?
You just need to lerp the refraction value using your same mask. the only difference is refraction of 1 means do nothing so lerp it so that when your Alpha is 0, the refraction lerps to 1, and when the alpha is 1 lerp to whatever your refraction network is.
Sorry it took me a long time to report back to you, but yea it works perfectly, thanks!