# How to create a procedural voronoi texture in code (not in nme)?

**URL:** <https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728>\
**Category:** Questions\
**Tags:** texture\
**Created:** [November 15, 2022, 6:26pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728 "2022-11-15T18:26:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Clear\_Sky](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clear_sky/32/28133_2.png) [@Clear\_Sky](https://forum.babylonjs.com/u/Clear_Sky)\
**Post date:** [November 15, 2022, 6:26pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728/1 "2022-11-15T18:26:12Z")

</div>

> **[Babylon.js Playground](https://playground.babylonjs.com/#K9GLE6%2349)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL 3D scenes

similar to this example, how do i make a voronoi texture (need to use it to move some vertices around but too difficult to do in nme so will do in normal code, just need to find a way to input position and get respective voronoi noise output, or even a lookup texture array)

---

<div class="post-metadata">

**Author:** ![Pryme8](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/pryme8/32/7212_2.png) [@Pryme8](https://forum.babylonjs.com/u/Pryme8)\
**Post date:** [November 15, 2022, 8:29pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728/2 "2022-11-15T20:29:08Z")

</div>

How familiar are you with shadercode? Are you doing it on a mesh or a texture (3d or 2d)?

This is family easy just need to know what your end goal is.

It’s easier to do dynamic textures then shader materials, but the shader code is quite similar each way, it’s just the implementation is different. (You can even mix the two)

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 15, 2022, 8:37pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728/3 "2022-11-15T20:37:19Z")

</div>

Probably this link may be helpful - [Babylon.js/voronoiNoiseBlock.ts at fdbf393d1d7699dc7cc69cec1dca0819ebd2622a · BabylonJS/Babylon.js · GitHub](https://github.com/BabylonJS/Babylon.js/blob/fdbf393d1d7699dc7cc69cec1dca0819ebd2622a/packages/dev/core/src/Materials/Node/Blocks/voronoiNoiseBlock.ts)

---

<div class="post-metadata">

**Author:** ![Clear\_Sky](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clear_sky/32/28133_2.png) [@Clear\_Sky](https://forum.babylonjs.com/u/Clear_Sky)\
**Post date:** [November 16, 2022, 1:18pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728/4 "2022-11-16T13:18:03Z")

</div>

i know how to work with node trees but i dont know shadercode at all. My end goal is to input many vectors into a function or a object and get respective voronoi texture value at that location/pixel.

---

<div class="post-metadata">

**Author:** ![sebavan](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/sebavan/32/57_2.png) [@sebavan](https://forum.babylonjs.com/u/sebavan)\
**Post date:** [November 16, 2022, 5:59pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728/5 "2022-11-16T17:59:07Z")

</div>

I think @Cedric had an amazing implementation ? but not sure if I recall correctly

You could also look into our voronoi block to extract the shader part you need ?

---

<div class="post-metadata">

**Author:** ![Cedric](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/cedric/32/2742_2.png) [@Cedric](https://forum.babylonjs.com/u/Cedric)\
**Post date:** [November 16, 2022, 6:02pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728/6 "2022-11-16T18:02:58Z")

</div>

I used Voronoi for mesh destruction but it was not 2D.  
Looking at implementation in the block or on [Shadertoy.com](http://Shadertoy.com) is a good start I start.

---

<div class="post-metadata">

**Author:** ![Clear\_Sky](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/clear_sky/32/28133_2.png) [@Clear\_Sky](https://forum.babylonjs.com/u/Clear_Sky)\
**Post date:** [November 16, 2022, 7:27pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728/7 "2022-11-16T19:27:17Z")

</div>

I saw it but im confused, which language is all the shader code written in?

---

<div class="post-metadata">

**Author:** ![labris](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/labris/32/12576_2.png) [@labris](https://forum.babylonjs.com/u/labris)\
**Post date:** [November 16, 2022, 7:30pm UTC](https://forum.babylonjs.com/t/how-to-create-a-procedural-voronoi-texture-in-code-not-in-nme/35728/8 "2022-11-16T19:30:17Z")

</div>

GLSL language.  
Some docs are here - [Introduction to Shaders | Babylon.js Documentation](https://doc.babylonjs.com/features/featuresDeepDive/materials/shaders/introToShaders)
