From 658b262c341f805c7627797a9868c6e7223e64ec Mon Sep 17 00:00:00 2001 From: EsProgram Date: Sat, 15 Apr 2017 03:10:14 +0900 Subject: [PATCH] [B:v1.0.1]:Alpha of HeightFluid is added every time drawing processing --- Assets/InkPainter/Script/Effective/HeightFluid.cs | 6 ++++-- Assets/InkPainter/Shader/Effective/HeightToColor.shader | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Assets/InkPainter/Script/Effective/HeightFluid.cs b/Assets/InkPainter/Script/Effective/HeightFluid.cs index 43c1743..be96445 100644 --- a/Assets/InkPainter/Script/Effective/HeightFluid.cs +++ b/Assets/InkPainter/Script/Effective/HeightFluid.cs @@ -2,6 +2,7 @@ namespace Es.InkPainter.Effective { + [DisallowMultipleComponent] [RequireComponent(typeof(InkCanvas), typeof(Renderer))] public class HeightFluid : MonoBehaviour { @@ -43,8 +44,8 @@ public class HeightFluid : MonoBehaviour [SerializeField] private float normalScaleFactor = 1; - [SerializeField, Range(0f, 1f)] - private float AdhesionBorder = 0.1f; + [SerializeField, Range(0.001f, 0.999f)] + private float AdhesionBorder = 0.01f; private void Init(InkCanvas canvas) { @@ -122,6 +123,7 @@ private void OnWillRenderObject() } var mainTmp = RenderTexture.GetTemporary(mainPaint.width, mainPaint.height, 0, RenderTextureFormat.ARGB32, RenderTextureReadWrite.Linear); height2Color.SetTexture("_ColorMap", mainPaint); + height2Color.SetTexture("_BaseColor", canvas.GetMainTexture(materialName)); height2Color.SetFloat("_Alpha", alpha); height2Color.SetFloat("_Border", AdhesionBorder); Graphics.Blit(heightPaint, mainTmp, height2Color); diff --git a/Assets/InkPainter/Shader/Effective/HeightToColor.shader b/Assets/InkPainter/Shader/Effective/HeightToColor.shader index f84a4ee..19ca481 100644 --- a/Assets/InkPainter/Shader/Effective/HeightToColor.shader +++ b/Assets/InkPainter/Shader/Effective/HeightToColor.shader @@ -4,6 +4,7 @@ { _MainTex ("Texture", 2D) = "white" {} _ColorMap("ColorMap", 2D) = "white" {} + _BaseColor("BaseColor", 2D) = "white" {} _Alpha("Alpha", Float) = 1 _Border("Border", Float) = 0 } @@ -33,6 +34,7 @@ sampler2D _MainTex; sampler2D _ColorMap; + sampler2D _BaseColor; float4 _MainTex_ST; float _Alpha; float _Border; @@ -50,7 +52,7 @@ float4 mainCol = tex2D(_MainTex, i.uv); if (mainCol.a > _Border) { - return lerp(tex2D(_ColorMap, i.uv), float4(mainCol.rgb, 1), _Alpha); + return lerp(tex2D(_BaseColor, i.uv), float4(mainCol.rgb, 1), _Alpha); } return tex2D(_ColorMap, i.uv);