I had a look at different styles of lava effects as research for our level, it has to fit with the toon style look that we are going for, i have made an attempt at doing lava though it didn’t turn out the way i thought it would. i had a look at this Tutorial in how they did stylized water. My original line of thinking was using this tutorial as base i could make lava instead of water it didn’t turn out right and there was some compatibility issues with the way the depth texture is calculated for the toon effect that didn’t work with this style of shader.

In the end i adapted a method i used before to make lava for a 2D game into this project, the basis of the 2D lava shader is using a slightly modified dissolve effect to generate the bright molten bits then apply it back on to the lava texture and scroll it over time in a certain direction to simulate lava flow. The modified dissolve effect is done by generating some noise then multiplying the result by the textures alpha to get the textures shape, subtracting that result by another noise sample with different offset values, multiplying the results by a color and then adding it back on the original texture to achieve the above results
for this project the concept is the same but in 3D, there was a problem that needed to be solved. the default noise node provided by unity did not work correctly out of the box, there some some issues with using the default tiling and offset node which resulted in the texture stretching along the Z-axis.

The Tiling and Offset node provided default by unity has the UV input as a vector2. This does not account for the Z-axis as the texture is now stretched across any faces of the geometry that are not facing the camera. To fix this problem i had to create a custom node to replace the default tiling and offset node. Reading this Article about UV Based nodes in unity i made a custom Scale & Offset node that takes in the UV coordinates as a vector 3.

The final results can be seem in the above image, there were some issues that need to be solved before the transition from the original 2D lava to 3D can happen. In the process of developing this shader I’ve also explored Triplanar Texture Mapping and 3D noise generation as possible solutions.
Triplanar Mapping is quite a complex topic the gist of it is to solve texture stretching issues over complex geometry. here is an Article that explains it in more detail.
Using the custom Scale & Offset node with unity’s noise texture works pretty well. it means i can reduce the complexity of generating 3D noise and use unity’s instead.
Fixed up a small bug that prevented the second layer from moving, the speed and direction input into the node that generates the second layer was flipped so it was receiving incorrect values, both layers now move independently with the bottom layer slower than the top for a better look.
