# Adapting shadertoy shader as a material

**URL:** <https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237>\
**Category:** Questions\
**Created:** [May 4, 2025, 4:34pm UTC](https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237 "2025-05-04T16:34:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bvaisman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bvaisman/32/20835_2.png) [@bvaisman](https://forum.babylonjs.com/u/bvaisman)\
**Post date:** [May 4, 2025, 4:34pm UTC](https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237/1 "2025-05-04T16:34:51Z")

</div>

Hi everybody,

Despite some years practicing BJS, i’ve never made or used a shader. But I mean it is probably one of the best ways to make great materials so I’d like to learn a little bit.

I’d like to adapt this one ([Shader - Shadertoy BETA](https://www.shadertoy.com/view/WdXBW4)) to create a material for a sphere but i do not know how to do it because i don’t find any fragment or vertex shader in the code.

Could somebody help me on a simple PG ?

Thanks in advance,

Boris

---

<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:** [May 4, 2025, 5:04pm UTC](https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237/2 "2025-05-04T17:04:01Z")

</div>

You are welcome! 🙂 - [Babylon.js Playground](https://playground.babylonjs.com/#2J1EKR)

---

<div class="post-metadata">

**Author:** ![bvaisman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bvaisman/32/20835_2.png) [@bvaisman](https://forum.babylonjs.com/u/bvaisman)\
**Post date:** [May 4, 2025, 5:52pm UTC](https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237/3 "2025-05-04T17:52:29Z")

</div>

Great !!! 🥰

Ok, i will now try to transform the constants into variables to be able to change the parameters of the clouds.

Thanks very much !!

---

<div class="post-metadata">

**Author:** ![bvaisman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bvaisman/32/20835_2.png) [@bvaisman](https://forum.babylonjs.com/u/bvaisman)\
**Post date:** [May 4, 2025, 6:31pm UTC](https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237/4 "2025-05-04T18:31:45Z")

</div>

Ok, I’ve managed to transform any constant into variables, so that is great.

But i’ve got two other problems.

1- When i try to apply the shader to a big sphere, it does not work very much, the sphere is almost black.

2 - there are some artifacts in the top and the bottom of the sphere

Here’s my PG : [https://playground.babylonjs.com/#2J1EKR#2](https://playground.babylonjs.com/#2J1EKR#2)

---

<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:** [May 4, 2025, 7:17pm UTC](https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237/5 "2025-05-04T19:17:33Z")

</div>

In this case it is better to use postprocess like this - [https://playground.babylonjs.com/#2J1EKR#8](https://playground.babylonjs.com/#2J1EKR#8)  
To put it into background use the second camera like it is shown here - [https://www.babylonjs-playground.com/#0503TW#18](https://www.babylonjs-playground.com/#0503TW#18)

---

<div class="post-metadata">

**Author:** ![bvaisman](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/bvaisman/32/20835_2.png) [@bvaisman](https://forum.babylonjs.com/u/bvaisman)\
**Post date:** [May 4, 2025, 9:43pm UTC](https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237/6 "2025-05-04T21:43:08Z")

</div>

I’d prefer not to do like that because i have to save and open the scene so it has to be unique. Is it possible to do it with a shader material ?

---

<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:** [May 5, 2025, 12:04am UTC](https://forum.babylonjs.com/t/adapting-shadertoy-shader-as-a-material/58237/7 "2025-05-05T00:04:46Z")

</div>

You need to use the sphere’s normals or positions for proper spherical mapping in vertex shader and adjust the UV coordinates to work with spherical mapping in fragment shader.

Example - [https://playground.babylonjs.com/#2J1EKR#10](https://playground.babylonjs.com/#2J1EKR#10)
