Mix textures by vertex color with height mask?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By librepyxel

Hello everybody!
I’ve been trying to figure out how to make a shader for mixing textures by vertex color but with utilizing a splat texture (height map) and I just can’t figure it out. In UE it’s a special function called “hlerp” but I can’t find how it works and I would love to reproduce it in godot. I hope somebody knows how that works.
Here’s a video with the effect I’m looking for:
https://www.youtube.com/watch?v=_OuhNUOzeoo

This video not only shows splatmapping, but also a blending trick that makes uses of a bumpmap for each of the 4 textures. It’s described here: Advanced Terrain Texture Splatting

I had this exact effect working in my terrain plugin, but I used a splatmap instead of vertex colors. Shouldn’t be too difficult to adapt for vertex colors. Here is the full shader (with all other features, not just splatmap): https://github.com/Zylann/godot_heightmap_plugin/blob/master/addons/zylann.hterrain/shaders/simple4.shader
It’s made for heightmaps and tailored to the way my system works, so if you intend to use that on something else, you may need adjustments.

Zylann | 2019-02-22 21:02