In this post I'll walk through the setup of this lava shader.
If you just want the code & textures, go to the end, under the gif of Kat!
Some possibilities with this shader, using different textures and settings! (Moving super fast to show the flow :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
It also needs a good amount of bloom postprocessing
There are a few similaries with my water shaders, main the edge detection, and the vertex movement for waves, so I'll keep those brief.
Let's go step-by-step:
Project a noise texture over the world position so it tiles nicely, then scroll it using _Time( Split x and y for more flow control)
Add another layer for a bit more depth, the second layer has a different scale.
Main Texture with distortion
Project the main texture also over the World Position, add the distortion with a variable to control the distortion strength.
Just like with the distortion noise, move it over time with _Time
Add an extra distortion based on the red Vertex Color, so you can paint on some variation near objects
Add the layered noise to the main texture, so you can add more color variation in the next step
Lerp 2 colors over the main texture, with a variable to offset the texture. Then multiply for to make it glow
Create a foam/edge line using the camera's depth texture and screen position.
Then add a texture to the edge by smoothstepping using the main texture
Before adding the edge to the main result, take the edge out of the main color so we can color the edge seperately without multiplying with existing colors.
Finally add the edge multiplied by color, then multiplied by brightness for that bloomy glow.
Take the main texture and smoothstep over it to take the brightest part (with the drawn texture this is the "cracks") multiplied by the red vertex color to dim it a little, but you can remove this part if you want the glow to remain all over.
Just like with the edge, multiply with the 1- to take the top cracks out of the main texture
Add it back in with colors and multiplied for glowing
Before adding the edge and top cracks, multiply the colored texture with the red vertex color so it's faded where you painted black.
Sine wave vertex movement just like in the water shader linked in the start, only multiplied by the red vertex color so it moves less on the darker/cooler parts.
That's it! The shader code has every part commented so you can read through that too :)
Painting the Vertex Colors
As mentioned before, the shader needs some vertex color painting to shine, this gif shows what it looks like without vertex colors, then painting on some black using PolyBrush
It's looking pretty good in Astro Kat!