8 public static class TextureMorphing
12 private const string TEXTURE_MORPHING_MATERIAL =
"Es.InkPainter.Effective.TextureMorphing";
13 private const string LERP_COEFFICIENT =
"_LerpCoef";
14 private const string SRC_TEX =
"_SrcTex";
15 private const string DST_TEX =
"_DstTex";
17 private static Material morphingMaterial;
19 #endregion PrivateField
29 public static void Lerp(Texture src, RenderTexture dst,
float lerpCoef)
31 if (morphingMaterial ==
null)
32 InitMorphingMaterial();
33 SetMorphingProperty(src, dst, lerpCoef);
34 var tmp = RenderTexture.GetTemporary(src.width, src.height);
35 Graphics.Blit(src, tmp, morphingMaterial);
37 RenderTexture.ReleaseTemporary(tmp);
40 #endregion PublicMethod
44 private static void InitMorphingMaterial()
46 morphingMaterial =
new Material(Resources.Load<Material>(TEXTURE_MORPHING_MATERIAL));
49 private static void SetMorphingProperty(Texture src, RenderTexture dst,
float lerpCoef)
51 morphingMaterial.SetTexture(Shader.PropertyToID(SRC_TEX), src);
52 morphingMaterial.SetTexture(Shader.PropertyToID(DST_TEX), dst);
53 morphingMaterial.SetFloat(Shader.PropertyToID(LERP_COEFFICIENT), lerpCoef);
56 #endregion PrivateMethod