# Changing shaderMaterial texture

**URL:** <https://discourse.threejs.org/t/changing-shadermaterial-texture/20978>\
**Category:** Questions\
**Tags:** materials, textures, shaders\
**Created:** [November 24, 2020, 10:48pm UTC](https://discourse.threejs.org/t/changing-shadermaterial-texture/20978 "2020-11-24T22:48:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mohamed\_Limaima](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mohamed_limaima/32/14610_2.png) [@Mohamed\_Limaima](https://discourse.threejs.org/u/Mohamed_Limaima)\
**Post date:** [November 24, 2020, 10:48pm UTC](https://discourse.threejs.org/t/changing-shadermaterial-texture/20978/1 "2020-11-24T22:48:25Z")

</div>

Hello guys,

I had a plane in my scene has a shaderMaterial, i’m trying to change the texture but the problem here is when i select a new texture my plane change to black …

I have recreate this simple scene here for the demo, choose a new texture from a select option.

[This is the link](https://codesandbox.io/s/stoic-tereshkova-fts1d?file=/index.html)  
Note please: you can refresh the frame if you find the scene white.Tx

---

<div class="post-metadata">

**Author:** ![prisoner849](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/prisoner849/32/535_2.png) [@prisoner849](https://discourse.threejs.org/u/prisoner849)\
**Post date:** [November 25, 2020, 7:13am UTC](https://discourse.threejs.org/t/changing-shadermaterial-texture/20978/2 "2020-11-25T07:13:54Z")

</div>

Hi!

```javascript
  onChange() {
    this.selectOptions.addEventListener("change", (e) => {
      let loader = new THREE.TextureLoader();
      let target = e.target.value;
      let newTexture = loader.load(`src/images/img${target}.jpg`);
      this.material.uniforms.textureImg.value = newTexture;
      this.material.uniforms.textureImg.value.needsUpdate = true;
    });
  }

```

1. ImageLoader =\> TextureLoader
2. `image` =\> `images`, plus `src/` at the start of the path
3. after setting a new value to a uniform, update just that uniform and not a material awhole

Moreover, you don’t need this part:

```javascript
      extensions: {
        derivatives: "#extension GL_OES_standard_derivatives: enable"
      },

```

---

<div class="post-metadata">

**Author:** ![Mohamed\_Limaima](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mohamed_limaima/32/14610_2.png) [@Mohamed\_Limaima](https://discourse.threejs.org/u/Mohamed_Limaima)\
**Post date:** [November 25, 2020, 9:14am UTC](https://discourse.threejs.org/t/changing-shadermaterial-texture/20978/3 "2020-11-25T09:14:02Z")

</div>

Thanks man!
