WorldAlignedTexture / ObjectAlignedTexture question

So I’m looking into an idea I had last night about a way you could simulate water within a container without actually simulating fluid at all.

The mesh is two cylinders, one very slighting within the other. I’m looking to figure out a way of having a similar effect to this screenshot, but only aligning the “water line” (opacity) with the world, and the fullness of the container would be driven by a parameter. As it currently stands, moving the meshes up/down would effect the ‘fullness’, rather than just the rotation of the mask aligning with the world.

http://ss.myth.ro/t/Lf18T.png

The idea here is that you could have quite interesting materials for things like a water bottle that would almost look like it’s contents is keeping with gravity.

I’m open to other ideas about how this could be achieved also, but I feel like if this method is possible it could be quite performance efficient too.

Here is my material so far for reference:

http://ss.myth.ro/t/t598g.png

Any ideas? :slight_smile:

Here’s a more efficient implementation that works with vertical movement:

  • No need to blend textures if you just want to create a mask.
  • By using the world position relative to the object position you don’t have any problems with vertical movement.
  • By using the object bounds you can approximate the size of the object to fill it up to various levels.

Some possible further improvements:

  • Use a blueprint to capture world-space movement over time and send that to the material as a parameter. Use that to rotate your mask to simulate sloshing in the direction of movement.
  • Improve fill level approximation for more complex shaped containers, the way I calculate it now is only accurate for spherical containers. For a cylindrical container like in your example a simple scale factor based on the objects orientation might be sufficient.

Thanks so much! Really helpful and super quick response :slight_smile:

No problem, glad to help.

Btw. when you comment after marking something as answered it will automatically mark it as unanswered again. (In case an Epic employee reads this, that should be optional in my opinion)