# Making a shader that would "fill" an open mesh?

I made a material that mixes two shaders using an empty which acts like a kind of mask for those shaders. If I move my empty up, there will be more blue shader. If I move it down, there will be more transparent shader.

My goal here is to make a glass that would be filled with water; using a single mesh with this special material, and moving my empty to "fill" the glass.

It is working quite well, but... As the material goes along the mesh, it shows up like if the mesh missed a face; has its "cap not filled". I was wondering if it was possible to tweak my blue shader so the mesh would always seems closed ?

Thanks !

• Commented Nov 25, 2015 at 15:06

Staying inside Cycles alone might not produce the desired results..

Here i'm using the Z component of the Geometry's position socket to compare with a scalar value (Representing the distance from the ground)

Most likely you'll need to animate a boolean intersection with a plane, one slice of will be the glass/transparent material, the other slice will be the solid/diffuse material (or whatever you want).

Here i've separated them spatially to indicate they this method uses two X Objects to and two planes, both planes point in opposite directions:

The closest I get without making it complicated is this:

It uses the Normal of the upper cut to decide how much to mix between glass and transparent. The normals pointing downwards (on the cutting surface) are the faces that are mixed to Transparent most. The exact shader mixing is something you'll need to decide on yourself.

• for a proper fill effect you might have to make a shrunk version of the X (offset inwards), and only animate that with the boolean intersection / plane. The outer regular X shell would then stay static. Commented Nov 25, 2015 at 13:02
• Ok, thanks for your reply ! I was wondering if it was possible without using booleans but apparently no. Thanks ! Commented Nov 25, 2015 at 14:29
• You didn't mention wanting to avoid the Booleans in your question, it might be possible.. but the creation of that extra set of internal faces to resemble the liquid surface will still need to be done with a real mesh I think.. Wait around for a better answer Commented Nov 25, 2015 at 15:03
• Commented Nov 25, 2015 at 15:04