1using System.Collections;
7 [RequireComponent(typeof(InkCanvas))]
10 [SerializeField]
private float lerpCoefficient = 0.1f;
12 [SerializeField]
private float callTimer = 0.1f;
14 [SerializeField]
private bool @fixed;
16 private Material material;
19 private Texture defaultMainTexture;
20 private RenderTexture paintMainTexture;
21 private Texture defaultNormalMap;
22 private RenderTexture paintNormalMap;
23 private Texture defaultHeightMap;
24 private RenderTexture paintHeightMap;
28 canvas = GetComponent<InkCanvas>();
34 material = GetComponent<MeshRenderer>().sharedMaterial;
41 StartCoroutine(TextureLerp());
49 if (defaultMainTexture !=
null && paintMainTexture !=
null)
50 TextureMorphing.Lerp(defaultMainTexture, paintMainTexture, lerpCoefficient);
51 if (defaultNormalMap !=
null && paintNormalMap !=
null)
52 TextureMorphing.Lerp(defaultNormalMap, paintNormalMap, lerpCoefficient);
53 if (defaultHeightMap !=
null && paintHeightMap !=
null)
54 TextureMorphing.Lerp(defaultHeightMap, paintHeightMap, lerpCoefficient);
57 private IEnumerator TextureLerp()
59 const int CALL_COUNT = 10;
62 yield
return new WaitForSeconds(1f);
64 for (var i = 0; i < CALL_COUNT; ++i)
66 yield
return new WaitForSeconds(callTimer / 10);
67 if (defaultMainTexture !=
null && paintMainTexture !=
null)
68 TextureMorphing.Lerp(defaultMainTexture, paintMainTexture, lerpCoefficient / CALL_COUNT);
69 if (defaultNormalMap !=
null && paintNormalMap !=
null)
70 TextureMorphing.Lerp(defaultNormalMap, paintNormalMap, lerpCoefficient / CALL_COUNT);
71 if (defaultHeightMap !=
null && paintHeightMap !=
null)
72 TextureMorphing.Lerp(defaultHeightMap, paintHeightMap, lerpCoefficient / CALL_COUNT);
Texture paint to canvas. To set the per-material.
Action< InkCanvas > OnInitializedAfter
Called by InkCanvas initialization completion times.
Texture GetMainTexture(string materialName)
To get the original main texture.
RenderTexture GetPaintNormalTexture(string materialName)
To get the paint in normal map.
RenderTexture GetPaintMainTexture(string materialName)
To get the main texture in paint.
Texture GetHeightTexture(string materialName)
To get the original height map.
Texture GetNormalTexture(string materialName)
To get the original normal map.
RenderTexture GetPaintHeightTexture(string materialName)
To get the paint in height map.