User Tools

Site Tools


Dual Material

Dual Material is the result of two Materials fused in one. This allows you to lerp between the two donor Materials. Currently only float and color values are used.

Why not use Unity's Material Lerp?

Unity already provides a method with the same functionality, but it has one flaw: it does not interpolate linear but with an easeInOut easing - this renders it useless for Tweening engines.


Make an instance of a new DualMaterial and provide in the constructor the two donor Materials. Please note that both Materials need to use the same Shader.


//Create new Dual Material
var dualMat = new DualMaterial(FirstMaterial, SecondMaterial, "Awesome Material");
//Lerp to 0.5
dualMat.Lerp = 0.5f;
//Get the Fused Material and do something with it
dualMat.FusedMaterial.mainTexture = otherTex;

DoTween Tweening

And this is how you could Tween it with DoTween:

//Tween the Material lerp to 0.75 in 2.5 seconds with a InOutQuint easing
DOTween.To(()=> dualMat.Lerp, x=> dualMat.Lerp = x, 0.75, 2.5f).SetEase(Ease.InOutQuint);;
tutorial/howto/dualmaterial.txt · Last modified: 2016/02/10 21:08 by admin

Page Tools