# How to do an Magnetism Behavior with Particle Texture

**URL:** <https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028>\
**Category:** Questions\
**Tags:** gui, material, mesh\
**Created:** [August 13, 2022, 6:13pm UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028 "2022-08-13T18:13:51Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![wilfred](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wilfred/32/29350_2.png) [@wilfred](https://forum.babylonjs.com/u/wilfred)\
**Post date:** [August 13, 2022, 6:13pm UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/1 "2022-08-13T18:13:51Z")

</div>

hi guy

My expectation is I need the snow and the mesh to follow the mouse cursor where ever it goes  
like the magnetic flow

this is my play ground

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

Can anyone help me with this

---

<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:** [August 13, 2022, 6:21pm UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/2 "2022-08-13T18:21:57Z")

</div>

To be honest I’m not too sure what you are asking.

It sounds like you want the cube to scroll with the camera when it moves?

And you want the snow to do what?

---

<div class="post-metadata">

**Author:** ![wilfred](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wilfred/32/29350_2.png) [@wilfred](https://forum.babylonjs.com/u/wilfred)\
**Post date:** [August 13, 2022, 6:53pm UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/3 "2022-08-13T18:53:01Z")

</div>

sorry for the inconvenience @Pryme8

what I’m looking forward is like the below hyperlink, if you take a look at this website there is a snow particle system effect and a mesh henceforth when you hover on it there is an magnetic like thing going on, that’s what I’m trying to figure it out

> **[Richard Mattka | Portfolio](http://richardmattka.com/)**
>
> Richard Mattka is an award-winning Creative Director, Tehcnologist and Author. Currently available for Freelance, exploring AR/VR, Interactive, Film, WebGL, Shaders, 3D, and Visual FX👽

if you see my Playground I’ve made the snow particle system effect and a sample mesh and what I need is that magnetic effect when I hover

---

<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:** [August 13, 2022, 8:41pm UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/4 "2022-08-13T20:41:50Z")

</div>

Hmm I dont see that effect on Mobile. Will have to wait till I get on a PC to look.

---

<div class="post-metadata">

**Author:** ![wilfred](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wilfred/32/29350_2.png) [@wilfred](https://forum.babylonjs.com/u/wilfred)\
**Post date:** [August 13, 2022, 8:43pm UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/5 "2022-08-13T20:43:45Z")

</div>

thank you and I’m eagerly waiting @Pryme8

---

<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:** [August 14, 2022, 2:50am UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/6 "2022-08-14T02:50:53Z")

</div>

Now that I have looked at it that whole scene looks to be ray marched. I also don’t really see a magnetism effect, but if you are talking about making the particles kind of linger around the sphere that would be doable.

To recreate this specific effect from your example though you would have to dive deep into some shader code.

---

<div class="post-metadata">

**Author:** ![wilfred](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wilfred/32/29350_2.png) [@wilfred](https://forum.babylonjs.com/u/wilfred)\
**Post date:** [August 14, 2022, 7:19am UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/7 "2022-08-14T07:19:21Z")

</div>

Where will I find that 😟

---

<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:** [August 15, 2022, 1:56pm UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/8 "2022-08-15T13:56:46Z")

</div>

shadertoy and the shader book are some of the best way to learn such kind of tricks.

@wilfred all the demos you shared are almost fully shader based. You should definitely try to look into those.

---

<div class="post-metadata">

**Author:** ![carolhmj](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/carolhmj/32/25918_2.png) [@carolhmj](https://forum.babylonjs.com/u/carolhmj)\
**Post date:** [September 14, 2022, 1:05pm UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/9 "2022-09-14T13:05:25Z")

</div>

Shader resources, for reference:  
[The Book of Shaders](https://thebookofshaders.com/)  
[The Art of Code - YouTube](https://www.youtube.com/c/TheArtofCodeIsCool)  
[Inigo Quilez - YouTube](https://www.youtube.com/c/InigoQuilez)  
[Ray Marching, and making 3D Worlds with Math - YouTube](https://www.youtube.com/watch?v=BNZtUB7yhX4)  
[Coding Adventure: Ray Marching - YouTube](https://www.youtube.com/watch?v=Cp5WWtMoeKg)

Ray marching/SDFs are a suuuuper fascinating subject and can be used to create super cool effects 🙂

---

<div class="post-metadata">

**Author:** ![wilfred](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/wilfred/32/29350_2.png) [@wilfred](https://forum.babylonjs.com/u/wilfred)\
**Post date:** [October 22, 2022, 4:59am UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/10 "2022-10-22T04:59:35Z")

</div>

yo!, Thank you till the core you just made my day blessed, and god bless you tq 😉

---

<div class="post-metadata">

**Author:** ![jeremy-coleman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/jeremy-coleman/32/15493_2.png) [@jeremy-coleman](https://forum.babylonjs.com/u/jeremy-coleman)\
**Post date:** [October 23, 2022, 6:55am UTC](https://forum.babylonjs.com/t/how-to-do-an-magnetism-behavior-with-particle-texture/33028/11 "2022-10-23T06:55:02Z")

</div>

the think term you’re looking for is “3d parallax effect”

here is a simple example  
.[GitHub - mtluiz/3D-Parallax-Threejs: Creating parallax effect with threejs and vanilla javascript.](https://github.com/mtluiz/3D-Parallax-Threejs)

it looks to me like your website example is doing that, except tilting the opposite direction and randomly animating the particles.

i found a random babylon example here  
.[https://playground.babylonjs.com/#6TK7PT#0](https://playground.babylonjs.com/#6TK7PT#0)

however, oddly no one mentioned that babylon has a built in surface magnetism behavior. I dont think this is what you’re looking for though. .[https://playground.babylonjs.com/#2YZFA0#275](https://playground.babylonjs.com/#2YZFA0#275)
