Shader Graph Stylized Lava

Here's the Shader Graph explanation of the Lava post, very similar to the last post I know, but new tutorial coming next week!

If you just want the graph, it's attached to this post, all parts are grouped with labels.

You do need post processing to make this look presentable! Bloom at least, but a bit of color correction also goes a long way :D

 NOTE: This shader uses vertex colors for a better effect, I recommend getting PolyBrush from the Package Manager for this!
I have an article on Polybrush here  

I made this Shader Graph on stream, it's a bit long, but if you want to watch, I turned it into a highlight, it's over here:  

Let's walk through the graph setup:

First noise layer

World Position

Start by taking the World Position, we only need the X and Z axis (top-down) so Split the value and create a new Vector2 we will use as the base UV's for our textures.

Scrolling Noise

Multiply the World Position with an exposed Scale Vector1. Then take a Time node, and multiply with two Speed Vector1 (Speed Distort X & Speed Distort Y), Add these to the scaled World Position and into a Texture Sampler to create the first scrolling noise texture.

Second Noise Layer

Do the same thing again, only this time the Scale variable is multiplied by 0.5, so the texture is bigger.

Add these two together, and multiply by 0.5 to even the value out.

Distortion over Main Texture

Just like with the noise, the uv's are based on the World Position, and move based on two new exposed variables for X and Y speed

You'll notice two lines are added in from the bottom, this is the distortion from two sources

First the Distortion based on the layered textures is added to the UV of the Main Texture, controlled by a new exposed Vector1(Distortion Strength)

Then extra distortion is added via the red Vertex Color, to give the impression that the lava flows different where you paint red. This extra distortion is also controller by a new exposed Vector1 (Vertex Color Distortion Strength) for the distortion strength.

Add the noise layers to the main texture

Use a Lerp Node to color the Noisey Main Texture with 2 new exposed Colors(Main Tint Start & Main Tint End).

Multiply the value of the main texture with a new exposed Vector1(Start/End Tint Offset)

Also Multiply with a new Vector1(Brightness Under Lava) to control the glow/brightness of this colorize lerp



 Remember to turn on the Depth Texture in the Pipeline settings, it's turned off by default. 

Also, the shader needs to be set to transparent (Render Queue 3000) for the depth texture to work

We just need the Scene Depth node, set to Eye Sampling Mode. Then subtract the Vector1(Edge Thickness) from the screen position, and subtract that from the scene depth.  Inverted using One Minus because the depth shows up as white in this view, and we want the edges to be white. 

Saturate the value to clamp it.

Textured Edge

Smoothstep the Depth Edge based on the main texture (inverted), with an new Vector1(Edge Blur) to optionally blur the hard cutoff

Colored and Brightness Edge

Finally Multiply the textured edge with a new Color(Edge Color) and multiply with a Vector1(Edge/Top Brightness)

Glowing Top

Take the brightest part of the main texture so we can colorize and control it's brigthness seperately.

Smoothstep over the main texture based on a new Vector1(Cutoff Top), and add a new Vector1(Top Blur) to optionally blur the hard cutoff.

Multiply by a new Color(Top Layer Tint), and multiply with the same Edge/Top Brightness value as the textured edge.

Before adding Top/Edge Glowing Parts

Before the Edge and Top parts are actually added into the main color output, use a One Minus node on the uncolored Edge and Top and multiply with the main texture, so that when we add these parts, they are not overlapping/blending with existing colors

Fade Over Red Vertex Color

Fade the whole result over the red vertex color to give the impression of cooler parts in the lava.

Multiply by the Red Vertex Color.

And there's finally the final Color Output of the shader :)

Vertex Movement Waves

Sine Wave

All that's left now is the optional vertex movement, you probably shouldn't add this if you're going to interact with the lava

First take a Vertex Position node and split it, we're going to need all parts seperately.

Multiply the X and Z as the topdown base for our waves (like a diagonal line), multiplied by the Vector1(Wave Amount).

Create a sine wave using Time node multiplied by the Vector1(Wave Speed), add the XZ Vertex result.

Multiply the sine wave result with Vector1(Wave Height).

Vertex Colors again

Multiply the sine wave with the vertex color red so it doesn't move (as much) where the lava looks cooler. Add to the Vertex.y.

Finally reconstruct the Vertex Position in a new Vector3 using the X and Z of the split Position Object node, and the new Y result.

Plug the result into the Vertex Position of the shader output

That's it, the shader is done!

Full Graph Picture (big) 


Two textures:

Have fun!

Become a patron to

Unlock 135 exclusive posts
Be part of the community
Connect via private message