# Alternate two shaders with transition

**URL:** https://discussions.unity.com/t/alternate-two-shaders-with-transition/713220
**Category:** Shaders & Materials
**Tags:** Shaders
**Created:** [August 31, 2018, 9:08am UTC](https://discussions.unity.com/t/alternate-two-shaders-with-transition/713220 "2018-08-31T09:08:21Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Antigone5](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/antigone5/32/358961_2.png) [@Antigone5](https://discussions.unity.com/u/Antigone5)
#### Post date: [August 31, 2018, 9:08am UTC](https://discussions.unity.com/t/alternate-two-shaders-with-transition/713220/1 "2018-08-31T09:08:21Z")

</div>

Hi, I have two different shader adapt to an object. I would like to use a script C# for alternand these two shader with a transition, when I press the E key.  
I saw that I could use :

> **[Unity - Scripting API: Material.Lerp](https://docs.unity3d.com/ScriptReference/Material.Lerp.html)**

but I can not adhere to the shader. (I use shader forge to do the .shader;))  
You can help me please  
Thank you !

---

<div class="post-metadata">

### Author: ![bgolus](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/bgolus/32/391570_2.png) [@bgolus](https://discussions.unity.com/u/bgolus)
#### Post date: [August 31, 2018, 5:40pm UTC](https://discussions.unity.com/t/alternate-two-shaders-with-transition/713220/2 "2018-08-31T17:40:37Z")

</div>

Material.Lerp can only blend between two materials using the exact same shader, and only for values that can be easily interpolated (ie: textures will just snap from one to the other, not change smoothly).

If you have two shaders that are entirely different, you may need to have a third shader that can do the transition, or look into implementing dithered cross fading for both shaders.

---

<div class="post-metadata">

### Author: ![tmcthee](https://avatars.discourse-cdn.com/v4/letter/t/f6c823/32.png) [@tmcthee](https://discussions.unity.com/u/tmcthee)
#### Post date: [August 31, 2018, 6:36pm UTC](https://discussions.unity.com/t/alternate-two-shaders-with-transition/713220/3 "2018-08-31T18:36:18Z")

</div>

It might be a bit messy, but could you use two identical objects, each with one of the materials? Then “cross-fade” the alpha on the materials.

---

<div class="post-metadata">

### Author: ![Antigone5](https://dub1.discourse-cdn.com/unity/user_avatar/discussions.unity.com/antigone5/32/358961_2.png) [@Antigone5](https://discussions.unity.com/u/Antigone5)
#### Post date: [September 4, 2018, 8:37am UTC](https://discussions.unity.com/t/alternate-two-shaders-with-transition/713220/4 "2018-09-04T08:37:44Z")

</div>

I found a solution. I created a shader with the texture that I can interchange with a lerp and a slider. then I just have to use the animator to change the slide. and I can therefore swap the map of the object 🙂
