Home Unreal Engine

Trying to create a liquid material contained inside glass (erlenmeyer flask?)

Hello again!

I was looking at trying to create an interesting effect for this object:
INdCr.jpg
My original intention was to create something with Cascade like a typical electric or energy effect (still might do so), but I got to thinking how I'd want to make something a little more challenging, and got the idea for seeing if there's a way in UDK to get a look where this tank is filled with a liquid with motion (bubbles, surface motion like boiling water). Best reference example I could think of would be an Erlenmeyer flask (though if it was boiling):
1oMl1.jpg

So I was wondering if anyone had any ideas or tutorials that would give me a hint as to how I'd set up such a material and implement it inside the glass container, if such a thing is possible.

Thanks!

Replies

  • maxivz
    Options
    Offline / Send Message
    maxivz interpolator
    id add some polys to make the top of the liquid and thyen use textures + materials to make it look like you want, try some distortion within the udk material for the liquid part
  • osman
    Options
    Offline / Send Message
    osman polycounter lvl 18
    Not sure if you´ve played HL2(shame on you if you haven't) but they had something that might help you out. It was in in the start, where you meet dr.kleiner.

    Found a video:
    http://www.youtube.com/watch?v=Wdvo6y0XF1c&feature=player_detailpage#t=350s

    You could probably open that asset up in source and see how they've built it.
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Problem is that in HL2 it was full, so you could animate it easily from the Distortion channel, on the other hand, I'm guessing the author wants it to be half full, and actually the top bending pending on view.
  • Soul_of_Solace
    Ace-Angel wrote: »
    Problem is that in HL2 it was full, so you could animate it easily from the Distortion channel, on the other hand, I'm guessing the author wants it to be half full, and actually the top bending pending on view.
    Quite so, I was hoping to be able to have them partially full if possible, and vary the heights across the different capsules in the scene. Though I did imagine that would probably be a bit more complex. But I'm definitely wanting to see what I can accomplish.

    I also do not have access to Source at the moment.
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Is the glass a separate mesh by any chance? And if yes, could you show the UV's?

    Also, does it have thickness or is a single plane? Pending on how you set it up, there many solutions, so just fill in my questionnaire and I'll see what's possible in my lab.
  • Soul_of_Solace
    The glass is a separate cylindrical mesh, and it is just a single plane with no thickness to it, and here are its UV's (for some reason I laid them out like this so the bottom half of the texture could be a different color, though that might have been unnecessary):
    T9XQX.jpg

    I'm certainly open to solutions of any kind and am more than willing to change what is there (making a new geo or changing the UV's) to make it work.

    Thank you!
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Well, first thing comes to mind is this (note I'll be talking about a procedural, feel free to use textures as you see fit).

    Also, I'm going for the most expensive solution, but hopefully you can come up with your cheaper solution since the basic idea applies.

    Change material type to Translucent.

    Take a TexCoord node and Mask out whichever direction your want the gradient to fade out (R or G) pending on your UV's. Multiply a Constant by it, Power it, and Clamp at it end.

    With the Mul you will dictate the 'amount' of liquid you want, with the Power the hardness near the end top and the Clamp will make sure it all doesn't glow like a radioactive waste.

    Mul all this by a color of your choice.

    Now here is the tricky part, put up a Lerp and insert the Fresnel in the Alpha, you're going to have to do this for pretty much all the other parts, basically your inner 'fluid' vs. the outer 'thickness' of the tube.

    On the other hand, if you don't want this (you want complete fluid) then for the color it won't need a fresnel.

    In the distortion slot however, keep the Lerp/Fresnel build, put a constant of either 1 or 0 zero for the interior, but for the edges, Multiply a Fresnel node by a Reflection, set the Fresnel value for the latter to something really low, like 0.5, etc.

    As for the top, part, I'm honestly temped to just say stick in a flat plane and mask it with the effect, but there would be other issues there.

    You could try and mask only a little part at the top, and bump offset the effect, add fresnel, etc, stuff to fake that 'bend' of light towards the eye, but I'm not sure if the extra math and nodes for a tiny small strip will be worth it.
  • Santewi
    Options
    Offline / Send Message
    You could also duplicate the glass model (cylinder), scale it down a bit, and place it inside the glass. Change the Z scaling if you want less/more fluid. The glass is going to look a bit thick though, of course you could set the fluid object's scale to something like 99% of the glass but you are probably going to get a lot of Z-fighting by doing so. Then use WorldPositionOffset or tessellation to get the movement on the top.

    I think I've seen this at least a few times in games.
  • divi
    Options
    Offline / Send Message
    divi polycounter lvl 12
    yeah, making an actual model for the liquid is probably the easiest and best approach. you could mask the movement to only affect the upwards facing faces as well.
  • Soul_of_Solace
    Well, this is as far as I've been able to get until I cannot figure out what else to do. I'm totally stumped about the Lerp and Fresnel aspect and how to get this thing transparent so it's not black above the line.

    I also created another mesh for the liquid inside the glass, but I'm already having problems with Z-fighting with the camera position.
    rxAiD.jpg
    Despite my constant turning to the Material Compendium (http://udn.epicgames.com/Three/MaterialsCompendium.html), I still am not totally understanding how these calculations are being interpreted.
    Now here is the tricky part, put up a Lerp and insert the Fresnel in the Alpha, you're going to have to do this for pretty much all the other parts, basically your inner 'fluid' vs. the outer 'thickness' of the tube
    What goes in the A and B slots of the Lerp? and what goes into the "Normal" of the Fresnel?
  • fearian
    Options
    Offline / Send Message
    fearian greentooth
    As an off-the-top-of-my-head thought train... You will need a mesh for the glass, and a mesh for the liquid. You can have the liquid mesh distort and fuzz out the edges slightly, and stick a particle emitter for the bubles inside. Then one thirs mesh, a plane, lightly above the waters surface with an enimated and alpha'd out ripple effect.

    Edit: Having a liquid mesh also means you can give it some animation for a psuedo physics effect, ala jigglebones in TF2 - [ame="http://www.youtube.com/watch?v=7MPojMf_WSQ"]coffee pot skin jiggle bones test - YouTube[/ame]
  • Soul_of_Solace
    ^^^An animation effect like that is very much desirable and kind of what I had been imagining. I do have a liquid mesh now, but I wouldn't know how to set it up to do that. I've set up bone structures in the past but wouldn't know how to begin with something that would ideally be a bit random.

    I have at least made some progress getting the thing to be transparent now, but still need to figure out the distortion part.
    khoN9.jpg

    EDIT: ok, I think I've got the basic distortion network down, I definitely am getting that subtle "fish-eye" effect now within the glass:
    yW9PW.jpg

    Question: I am wondering if there is some kind of trick I can utilize with the mask to make it oscillate up and down to give off that look like the liquid is moving on the sides at least

    EDIT2: Got some bubbles (via flipbook texture and Cascade) in for effect.
    hke6a.jpg
  • AbominableSoul
    I would take a look at the water materials that UDK comes with.
    they have very very good ways of setting up liquid movement.

    you can then change the speeds at which the liquid moves.

    if you are feeling like having a static movement is way too boring, you could always create a material instance and then have it do funky things as the player gets closer or farther away or hits a button.
    like changing colour :D

    but first thing first, if you want it to look like its moving, i highly recommend looking at how the UDK materials are set up for water.
  • AbominableSoul
    p.s. a material instance will also mean variation, so that not all the tubes have the exact same animations at the same time.

    i say this because i see a 2nd object in the back of that last picture you posted.
    if you have lots of them lining the hallway (thats what it sort of looks like you have planned), it can become very repetitive and takes away from a more natural feeling environment if they have the same identical animations.
  • Soul_of_Solace
    You are quite correct about variation, which was the idea I was hoping to do with the tubes given that to fill them with the exact same amount of liquid and consistency/color would be too repetitive. And you are quite right. The Material Instances are an amazingly handy tool to diversify things (height, color, etc.) :D
    jRIDv.jpg

    Now I need to start working on the "lid" of the liquid, in addition to getting some slight normal/distortions around the glass so that the liquid has a more sludgy feel to it than a "cloudy" one. I definitely saw some Epic liquid/goo materials that looked very interesting, though quite complex, that I'll certainly do my best to reference as I continue constructing the network.
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Use vertex colors for the distortion on the top, like this:

    [ame="http://www.youtube.com/watch?v=ovelfgNiyJk"]3D Vector Displacement - UDK (DX9 WorldPositionOffset) - Test #2 - YouTube[/ame]

    Then marry it to a Sine or Cosine for the slight ripple effect, but you will need quite a few points of vertices to make it look good.
  • fearian
    Options
    Offline / Send Message
    fearian greentooth
    Ooh thanks for posting the material, I Think it might be what I'm looking for to make some emissive effects!
  • Soul_of_Solace
    Ok, so I've spent time trying to wrap my head around how Vertex Displacement works. I've got some idea of the mechanics, but the implementation is still eluding me. I'm getting inconsistent results in terms of the movement not moving in the direction I'd want it to (it seems to move side to side instead of up and down), the power of the movement (in the Static Mesh preview, it is much more noticeable and visible than it is in the level itself).
    t5wSH.jpg
    That's basically what I've managed to set up that somewhat works. I still don't know how I'm going to match the liquid plane to match the texture since it doesn't look like they're really melding together well.

    How do I know which vertex colors affect height? I was just painting random colors in Maya, do some colors move the verts in different directions than others?
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Only use one color, I suggest Red, then take the Red Channel from the Vertex Node and voila, unless Epic has changed the way Vertex colors are handled, this method should work.
  • Soul_of_Solace
    Ace-Angel wrote: »
    Only use one color, I suggest Red, then take the Red Channel from the Vertex Node and voila, unless Epic has changed the way Vertex colors are handled, this method should work.
    I'm still very stumped. I've been changing channels and masks trying to just get the offset itself to work (before even trying to get the sine issue going) and I'm not able to even offset the baked vertex's in the Z axis.
    iKaNo.jpg
    The upper image is nothing happening when trying to just use the Red channel. The lower image is some deformation when using all channels, however, the deformation is only occuring in the XY plane, not the Z axis which is what I'm trying to get.

    This is starting to get very frustrating. There isn't much tutorials or information given on how to set up a vertex displacement node network out there either, at least, nothing that applies to using baked vertices.
  • Soul_of_Solace
    lol, of course it is as simple as just plugging the whole vertex shader in (to check for the offset itself). I guess just plugging in an individual channel like Red does not seem to work:
    riOGc.jpg
    Now to get it set up so that the sine is only shifting the vertices upwards instead of side-to-side is tricky
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Hmm, seems like abit has changed since my hayday, because I usually do this and it works: http://udn.epicgames.com/Three/WorldPositionOffset.html

    OK, so it looks like you have the basics of your material down, Mul the Vertex node by a Constant of 2 to exaggerate so you can see it better for the testing, then Mul the entire thing by the effect the Time-Sine node and see if the material works.

    If this works, then so far, so good, meaning the issues is with the World Position node. Try Masking different channels or using other Position nodes instead, although in all cases, World Position should be used and SHOULD be working.
  • Soul_of_Solace
    Thank you sir! Yeah, I was looking at the WorldPositionOffset udn page as well for information. Two things were messing me up though. Using just one channel from the VertexColor node did not work, and the preview in the Static Mesh viewer was way way off from how it actually looks in game (the mesh is pretty much exploded into tiny pieces in the preview, yet, in-editor it looks fine.

    It's also amazing how quickly a solution can present itself with a little perseverance. Here is the material network I finally figured out for the ripple effect:
    GqnUN.jpg
    Of course, seeing is believing. I'm gonna upload a video to show it in motion, once vimeo lets me :shifty:

    EDIT: Finally uploaded. Still needs some work though, might think about redoing some of the baking and getting a better sense of a pattern that would go well with the movement. Also need to work on some improved shader quality for the liquid itself so it looks more like a liquid and less like cloudy water

    http://player.vimeo.com/video/47790456
  • Ace-Angel
    Options
    Offline / Send Message
    Ace-Angel polycounter lvl 12
    Glad you got it working :D
  • Soul_of_Solace
    Made some adjustments. Added in normal maps and more distortion effects. Problem I'm running into now is that both Vimeo and Youtube screw up the video by compressing it to hell (even after I Media Encoded the file to YouTube or Vimeo settings) so that those nice details are all blurred out:

    [vv]47848595[/vv]

    Going to have to try and bring out those details even more to counteract that issue then.
  • cptSwing
    Options
    Offline / Send Message
    cptSwing polycounter lvl 11
    Kudos! Very nice looking.
  • Mark.N
    Options
    Offline / Send Message
    The liquid itself is looking really proper, good job there.

    If I were you I'd focus on two more simple additions to really make the whole prop shine.

    1: Add some cube mapping to your glass material to get some reflections coming in from the outside world. This should go a long way in making your glass material pop out more and be distinct from the liquid.

    2: Another particle system that creates bubbles that come up and pop on the surface. This could be somewhat optional depending on how viscous you want your liquid to appear, but should be relatively simple to setup.
  • AbominableSoul
    that looks great man.

    i dunno if its just me, but the bubbles seem to be moving very quickly for how little surface movement there is.

    Or its just the quality of the video.

    I dunno. it looks great, but the movement of the liquid looks a little off to me.
  • Santewi
    Options
    Offline / Send Message
    Are you using a particle effect for the bubbles?

    If you are, you could make them appear on the bottom (either with scaling them up when they spawn or changing the opacity), have them lay down there for a few seconds and then use velocity over life to make them go upwards.
Sign In or Register to comment.