Devlog 8 – Lava Shader and The Calm Before The Storm

Lets talk more shaders! The next set of updates are gonna be RIGHT MASSIVE, so I’ll make smaller updates while I’m working on the new content.

I’m not particularly happy with the way the magma looks, so I’m going to create a new shader and particle effects to really make it look like lava. Of course I am going to be abiding by the comic book art style!

Lets start off with the basics. I want this to be a triplanar shader so that multiple blocks can connect to each other and look seamless, as well as providing an easy way to get around wacky UV mapping badness with rescaled meshes.

An overview of the Triplanar Effect

Triplanar effects are quite costly, the GPU has to do 3 times the work, so I am planning on moving on from triplanar shaders once we actually start making levels using probuilder. Luckily, I have made it fairly easy to remove a the triplanar effect.

Now lets take a look inside the actual lava sub-shader:

Starting off is the black rocks that appear in the lava. Like everything else in this shader, the texture and colors are calculated using Perlin noise, which is great at making procedural textures!

First, I take the value and step it, which basically means that any value over [Edge] will be white, and anything under will be black. This produces the hard edges of the toon style I’m looking for. I’ll take this value and multiply it by everything else when I’ve created it. What this should do is produce black splotches that slowly flow across the lava field.

Right now it’s just black and white because the other pieces of the lava shader aren’t in place yet.

Next, I’ll do the same thing with 2 different sets of noise. One of them is called the base layer and is responsible for the majority of the lava’s color and shape. The second layer is a detail layer and will provide the hotspots and slight color-shift of the lava. This effect works very well when the two sets of noise are moving in different directions and at slightly different speeds.

Now, I can overlay the black rocks again:

And of course, because everything is a variable, I can change some values to get different effects:

Finally, I will add a distortion to everything. This will make it seem more like a liquid that flows around obstacles. The distortion effect is also fairly simple. Generate another layer of noise, and use it to offset the direction of the existing noises path.

Moving on to the particles: I just spawn a few random little squares that fly upward. They have a gravity modifier so they fall down as well, and some of them have trails. The range of colors they can be is from a yellow to light red.

And that’s a cool looking lava effect done! Stay tuned for more technical stuff later on!

Published by Loochis Loo

I am an aspiring programmer who likes to create fun applications. I also do some electronics projects.

Leave a comment