Lava Lamp Shader/Material

So I decided to experiment around with creating a lava lamp shader, not having much success so far.

I’ve got a texture (black background with white circles) that moves plugged into the emissive channel with a panner to move the texture, this however only moves the texture up, I tried adding a second texture with the panner reversed…but this didn’t work.

What I want is the texture to bounce around within the model itself (like how a lava lamp works).

I’ve attached screenshots of the model and the shader setup.


I was thinking about applying a method like one I used in a water shader I made (never finished), which uses the world position offset, but that would move the model as well.

If anyone has any suggestions or tips of how I can getting this looking really awesome I would appreciate it.

Thanks,
Dan

Putting a texture on a lamp will look very 2D no matter what you do, but to add distortion to the globs you already have, you can use a panning noise normal map, multiplied down to .02, masked to only RG channels, then added to a basic texture coordinate, and plugged into the UVs of your texture. The normal map will displace the globs on your lava lamp and give it a really neat distortion effect. It’s one VFX trick everybody needs to know. If you use this same technique on particles, then have the particles float around inside the lava lamp and just use a glass material on the outside, you can effectively make a 3D-looking lava lamp. Depending on how far you want to take this, you can use lit, masked, subsurface models with actual placed lights and have the individual globs cast a shadow.

The only way to go better than this is with volumetric decals. But those are highly expensive and experimental, no game I know of uses them.

Just look lava lamps and pick the nicest effects that you want to achieve.

What I would do:

  1. Simulate dozen blobs at cpu bouncing at inside lamp. When blobs collide they might combine, give fraction of their mass or just bounce off. Heated blobs go up and sunk down when cooled and then lamp reheat them and they go up again.
  2. In material raytrace against all blobs. Use somekind metaball combining pattern but treat like opaque.
  3. Shade nearest surface with bottom lamp as light source. Fake bounces as ambient.
  4. Add some amount of “fog” from lava water.
  5. Calculate glass fresnel to get opaque and multiple lava stuff with that. Output to emissive channel.
  6. Shade rest of lamp as normal opaque glass material.

Live reference.

Would something like that render in realtime? I wasn’t aware UE4 can handle soft bodies in realtime.

It would need custom node for material but I do think it should run realtime. Performance would be dependant of number of blobs but raytracing against spheres are dead cheap. Combining blobs just need some finetuning and creative mind.

Just look some nice ideas from shaderToy. Shader - Shadertoy BETA

Thanks for the suggestions.

Using a particle was something I thought about testing out, just hadn’t got around to it yet.

The other method I was going to try was to use a bunch of meshes in the lamp with a vertex shader and then use some kind of method to move them about inside the lamp, but I’ll try the particles first and see what I can get going.

I’ll be playing around with it during the week, hopefully I’ll get some kind of update posted up here (pretty busy with multiple projects).

Thanks,
Dan

Here’s a way to do basic blobs with volumetric decals. Create a material parameter collection and add a vector parameter for the location of each blob. Add one, or many, scalar parameters to control their radius. In a volumetric decal material, create a spherical distance field for each blob.

find the smoothmin of all the blobs and feed the result to opacity mask.

Here, the vector parameters are set based on the world location(divided by the scale of the volumetric decal) of 10 invisible spheres that I’m applying varying forces to.

Amazing, simply amazing xnihil0zer0

Haha, thats great man! :slight_smile:

Sweet thanks xnihil0zer0 that will come in handy.

So I haven’t had any real time to work on this lately (too much going on atm and family stuff).

I will post up here when I get a chance to experiment around with this some more.

hello,
both solution and result are brilliant thank you so much.
however i have no clue what the smoothmin is about. and cannot seem to find it out.
some help? sorry if im asking something too basic and thanks again, in advance.

Would you be willing to make a more detailed video or something of how you set this up? I’ve been trying to create a lava lamp material, but it’s just not working out.

You could also try using paralax occlusion mapping to fake a sense of depth and to give the bubbles some volume.

Oh how awesome that lava lamp effect is, so much better than what i have at this moment, but I just have a singular flat circle and not the awesome dynamic blobs you have. I have a feeling its because I don’t understand "Here, the vector parameters are set based on the world location(divided by the scale of the volumetric decal) of 10 invisible spheres that I’m applying varying forces to. " and how to set that up in the level blueprint and what objects i need in my scene.