Is this possible

is kinda … I was always trying to find a way to mask water materials so that it doesn’t show up inside the mesh of boats etc.
It’s seems pretty limited the way it is right know but if is possible then it shouldn’t be too hard to figure out how to do the same thing for any shape.

I was wondering if it would be possible to adapt the technique used to make edge foam but instead use it to detect where the transparency should start in order to mask the inside… or is that what you already tried in your previous attempt?

In my previous attempt i was simply rendering the sphere at a custom depth and above the water so is why it also was blocking the water where it shouldn’t have

I don’t know about using the depth fade node, i’m sure there is an even better method out there to detect the mesh shape and mask it accurately but my knowledge of UE4 is too limited

**We ran into same while working on Bioshock Infinite. **

The problem scene - (opening sequence) - Booker and Twins are on the boat* - Booker exits the boat and is given full camera freedom ( includes the ability to look back at the boat).
Issue #1 - The ocean was calculated with a vertex shader (vertex animation), which meant the waves pierced the hull and ignored the space in which air was suppose to occupy.
Issue #2 - After exiting the boat, became even more evident as they began to row away from the lighthouse, the water did not appear to be affecting the boat (foam, splashes, etc.).

Issue #1 Performance Solution: Since the player (Booker) was confined to the boat, we were able to simply change the rendering priority of the boat (and all objects within it) to a sort priority that was 1 level higher.
Issue #2 Solution: When out of the boat, there was no getting around the interaction and volume. I unfortunately am not able to give “all” the details, but I can steer you in one of the several right directions. When dealing with vertex information, it is impossible to add unique alpha maps (textures - such as the shape of the hull of the boat) into the equation. “I mean, it is possible, but dangerous and extremely performance heavy. Not to mention “in UE3” you had to modify a bit of code to do it”. So with that in mind, the big question is, how do you mask off the vertex information to fit the shape of the boat? One solution is: There needs to be a texture map (alpha) of the shape of the boat. Then, needs to be applied to a special material that can be projected through a light or dynamic decal onto a surface. You then need to bind the location of the dynamic actor (i.e. - the light or dynamic decal that is projecting the alpha texture) to the location of the boat. You then need to modify it so that the projected material (alpha texture) acts as a rendering mask for the ocean priority only. You then place a second (and much cheaper mesh) under the boat with another type of ocean material that is bound to the boats location. material has a modified boat hull gradient falloff which is then driving a tessellation deformation (or just a deformation), which then conforms the underlying mesh with the top ocean plane “effectively stitching them together”. Further modifications can be made so that the mask behaves as the boat rocks and drops farther into the ocean or raises out of it.

solution is (roughly the same “if I am not mistaken” - as the one used on the opening sequence). After I brainstormed with the Lead VFX - Stephen Alexander - he took the concept and implemented it. So I am not sure of all the details he chose to implement, nor did I bother investigating his kismet setup and shaders. (Was busy trying to stay on top of all my tasks) :slight_smile:

As a side note, is not the only way to accomplish unique “boolean volumes”. There are other methods, just gotta reach way outside the box to find them :slight_smile:

You can see the end result of the implementation at 2:30 seconds:

Thank you JBaldwin, very interesting read

I have made some good progress, however i have some using my masks on particles, right now i’m setting up the masks in the particle’s material but they don’t seem to get masked, i have tried on gpu and regular particles

It’s as if the particles will not spawn inside the mask, but already spawned particles won’t get masked

Any ideas?

@JBaldwin Thanks for the insights, always nice to read how others solve similar problems.

Particle spawning should be completely independent of the material. Did you check in another viewmode if they really aren’t there? My initial guess would be that the way you calculate your mask is not updated when the particles move, leaving the initially masked particles masked forever and the other never to be masked. Try plugging the mask into the emissive slot or enlarging them to usually be partially masked to more easily debug them.

PS. Did you post another question before? I got an email from the forum telling me so, but there was nothing in thread…

I did some more testing and the mask seems to be working, but something is wrong with my material instance, the Location parameter doesn’t update and the mask stays at 0,0,0, perhaps it has to be done differently for particles?

It was the same question but i decided to try something else before posting

The strange thing is that if i get the parameter value of the location and print it on screen it really works, it follows my player around, i’m not sure why the mask isn’t moving, it works well with all my other actors

I’m doing a series of tests to try and understand why i’m unable to change parameters in the particle’s material

Here for example is a simple graph that i would expect to change the particle’s material color to blue when i press T, but the color never changes, it changes if i do it directly in the mat instance, i’m not sure why it isn’t working, i have masked all my actors way

Hey Khena, looks like the Create Dynamic Material Instance node at the top of the picture doesn’t have an asset selected for “Source Material”. :slight_smile:

Hi !

is how i always set the graphs and it usually works, i did try with specifying the mat and it didn’t help!

The strange thing is that if i put a “Set Vector Parameter Value” node in the construction script it works, i’m really confused, i must have missed something

works perfectly

Turns out that the material had to be set after the parameter node

Ok that makes more sense. I was going to post earlier (sorry I should have…) that the DynamicMaterialInstance is creating a new instance of the material, so the material instance you had set in the Particle Editor wouldn’t get updated with the new value. I was going to test it out first before posting but got sidetracked…

Good to hear it’s working properly now! :slight_smile:

little read there!

I’ve been also toiling away at problem some time ago, though not to hide water but to punch holes in ceilings for embedded hallogen spots and other light fixtures, i got a bit stuck and left it for later.
Currently i managed to create a shader that uses the coordinates of specific blueprints to create round holes at the coordinates of relevant blueprints. However i haven’t managed to create any custom shapes.
My end goal is to just have a blueprint section that i can just place in any of my light models and have it apply the effect, including custom values for square light fixtures like embedded fluorescent lamps


solution was also limited to the amount of holes i put support into the shader, every hole needs a seperate mask “input” on the DMI shader.

Currently the radius is fixed, and the hole is spherical.
here is the blueprint i’m using to create the holes:

If somebody can help me with how to mathematically define rectangles (or other custom shapes) i would probably be able to get more use out of application.

Initially i thought it would just be as easy as just projecting a decal mask that overwrites the alpha of the shader it lands on, however decals support normals/diffuse/emissive but not opacity…
Maybe can be enabled in code however i’m not a programmer myself…

If i can define all these variables i intend to use a custom struct value to quickly add public variables that allow for quick specification of the hole that needs to be created, like for instance “is sphere” , “is box”, “use decal mask”, “radius”, “width”, “length”, “decal size”, “transform” all combined into a “holeinfo” struct.

First of all I’m not sure if is the best solution in your use case. Assuming your ceiling lights never move it is probably a lot more efficient to just model the holes into the actual geometry. However if you have a good reason to want to do them like here’s some pointers:

First of all I would place your hole shape math into a function instead of copying it a bunch of times. That should make your shader a lot easier to update.

Second regarding your question if you could use decals: no, in UE4 decals are applied deferred after the scene was rendered, so they can alter the various g-buffer channels, but you can’t reveal the anything underneath.

Here’s an example of a square hole mask function. I made the assumption that your ceiling is always horizontal so it ignores the Z axis, but you can simply translate the concept to three axis to create a cube mask:

You can also do something similar to create a custom UV set. Plug into a black and white mask as the UVs and you can cut holes in any 2D shape you could want:

I agree with Arnage that the easiest solution would be to model the holes unless you are going for something specific

is what i have used to make a dynamic box mask and it worked for me

Hmm interesting, i’m definitely going to try out!
The reason i want to have the holes to be dynamic is so that it is easy to populate and tweak office ceiling with lights without having to adjust the models or bsp’s
With Houdini engine would be able to solve problem quite easily with proper even, though at the moment i dont have access to software.

We’re working on it, stay tuned!

Now that i can mask my water plane, i’m trying to make it look thicker, but even if my plane is actually a thin box, once i mask it i can see inside it, there is no way that i can think of to make it look thick and not hollow

Can you guys think of a way to make a masked box look not hollow or is just not possible?

Here is an example, once masked we can see inside the thin water surface box

waterplane.jpg

Technically a water surface has no thickness, so even if you gave it a side it wouldn’t be very correct. The reason it often looks like it has a thickness is due to two :

  • The very edge is often blurred because it is very close to the camera.
  • The surface tension causes the surface to curl up where it connects to the glass.

Both of which are very expensive to do anywhere near accurately. However, both cause the edge to be less defined, while you now have a very hard edge that’s distracting and calling attention to the inaccurate transition. A cheap trick to approximate is to just alpha blend the edge for a very short distance. As your material is already translucent, and you also already calculate the distance for the mask, should be practically free for your use case.

Arnage!

By alpha blend do you mean a sort of fade out toward the player? I’m not sure how effect would look but i could give it a try

is the effect i’m after, where water seem to press against glass and creates the illusion of being thick, just as you said in your second effect example