# Smooth transition between textures with GSAP

**URL:** https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631
**Category:** Questions
**Tags:** textures, animation
**Created:** [March 22, 2021, 2:20pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631 "2021-03-22T14:20:04Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![Lonely\_Wanderer](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lonely_wanderer/32/15923_2.png) [@Lonely\_Wanderer](https://discourse.threejs.org/u/Lonely_Wanderer)
#### Post date: [March 22, 2021, 2:20pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/1 "2021-03-22T14:20:04Z")

</div>

I need to make a transition between several textures using GSAP, I know how to do that via fragment shader but it’s not an option because I can only mix two textures that way and also I am looking for more flexible timing options. How do I change the value of the texture loaded by the TextureLoader from GSAP?

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [March 22, 2021, 2:38pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/2 "2021-03-22T14:38:03Z")

</div>

Animating texture data on the CPU will be hopelessly slow. Transitioning between different textures should be implement in shaders.

---

<div class="post-metadata">

### Author: ![Lonely\_Wanderer](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lonely_wanderer/32/15923_2.png) [@Lonely\_Wanderer](https://discourse.threejs.org/u/Lonely_Wanderer)
#### Post date: [March 22, 2021, 2:39pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/3 "2021-03-22T14:39:41Z")

</div>

Any idea how to change between four or five textures from fragment shader? as mix() only allows two value transition.

---

<div class="post-metadata">

### Author: ![Mugen87](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/mugen87/32/5645_2.png) [@Mugen87](https://discourse.threejs.org/u/Mugen87)
#### Post date: [March 22, 2021, 2:57pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/4 "2021-03-22T14:57:45Z")

</div>

I guess you are looking for:

> <https://stackoverflow.com/questions/7207158/interpolating-three-textures-in-one-fragment-in-glsl-webgl>

You can apply the concept of this post when using more than three textures, too.

---

<div class="post-metadata">

### Author: ![Lonely\_Wanderer](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lonely_wanderer/32/15923_2.png) [@Lonely\_Wanderer](https://discourse.threejs.org/u/Lonely_Wanderer)
#### Post date: [March 22, 2021, 3:39pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/5 "2021-03-22T15:39:17Z")

</div>

Yes, but this doesn’t actually do any transition between the textures but blends them together, even if you implement the transition (e.g using time uniform). Yes it makes a transition but the textures aren’t in their pure form (i.e they are kind of blended).

---

<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: [March 22, 2021, 3:45pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/6 "2021-03-22T15:45:21Z")

</div>

Put textures in an array and on each iteration set uniforms with items of desired indices.  
For GSAP, use `repeatXXX` properties: [https://jsfiddle.net/prisoner849/dns0xhkz/](https://jsfiddle.net/prisoner849/dns0xhkz/)

---

<div class="post-metadata">

### Author: ![Lonely\_Wanderer](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/lonely_wanderer/32/15923_2.png) [@Lonely\_Wanderer](https://discourse.threejs.org/u/Lonely_Wanderer)
#### Post date: [March 22, 2021, 5:22pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/7 "2021-03-22T17:22:43Z")

</div>

My man!!  
Works like charm.  
Thanks.

---

<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: [March 22, 2021, 9:25pm UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/8 "2021-03-22T21:25:21Z")

</div>

@Lonely_Wanderer You’re welcome 🍻

---

<div class="post-metadata">

### Author: ![trusktr](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.threejs.org/trusktr/32/13726_2.png) [@trusktr](https://discourse.threejs.org/u/trusktr)
#### Post date: [August 29, 2024, 6:57am UTC](https://discourse.threejs.org/t/smooth-transition-between-textures-with-gsap/24631/9 "2024-08-29T06:57:18Z")

</div>

Fixed the demo by locking the Three.js version:

https://codepen.io/trusktr/embed/preview/JjQBvRK?default-tabs=js%2Cresult&height=300&host=https%3A%2F%2Fcodepen.io&slug-hash=JjQBvRK
