# How Can I Blend Two Materials Based on Vertex Color or Heightmap?

**URL:** <https://forum.babylonjs.com/t/how-can-i-blend-two-materials-based-on-vertex-color-or-heightmap/58053>\
**Category:** Questions\
**Created:** [April 25, 2025, 11:42am UTC](https://forum.babylonjs.com/t/how-can-i-blend-two-materials-based-on-vertex-color-or-heightmap/58053 "2025-04-25T11:42:29Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![xivol](https://avatars.discourse-cdn.com/v4/letter/x/34f0e0/32.png) [@xivol](https://forum.babylonjs.com/u/xivol)\
**Post date:** [April 25, 2025, 11:42am UTC](https://forum.babylonjs.com/t/how-can-i-blend-two-materials-based-on-vertex-color-or-heightmap/58053/1 "2025-04-25T11:42:29Z")

</div>

Hi everyone,

I am working on a terrain system in Babylon.js and want to create a shader / material setup where two different materials (e.g. grass and rock) blend together based on either vertex color / heightmap values. 😇

The goal is to get more natural-looking terrain transitions without relying on large texture splat maps or multiple draw calls. Is this possible using ShaderMaterial or Node Material Editor? 🤔

I’ve seen the `mix()` function used in GLSL to blend between textures; but I’m not sure how to cleanly integrate that into Babylon’s material system. 😇

I also came across some height-based blending demos using custom shaders, but I’m unsure how to hook them up to dynamically loaded terrain meshes with varying vertex colors. Ideally; I’d like to avoid duplicating geometry or splitting the mesh for performance reasons. 🤔  
Checked [https://doc.babylonjs.com/features/featuresDeepDive/materials/node\_material/nodeMaterial\_](https://doc.babylonjs.com/features/featuresDeepDive/materials/node_material/nodeMaterial) [Splunk course](https://www.igmguru.com/big-data/splunk-training) guide related to this and found it quite informative.

Is there a recommended workflow or example project that shows how to do vertex-based or height-based texture/material blending in Babylon.js? 🤔

Thank you !! 🙂

---

_[View the full topic](https://forum.babylonjs.com/t/how-can-i-blend-two-materials-based-on-vertex-color-or-heightmap/58053)._
