Skip to content

Commit

Permalink
[B:v1.0.1]:Alpha of HeightFluid is added every time drawing processing
Browse files Browse the repository at this point in the history
  • Loading branch information
EsProgram committed Apr 14, 2017
1 parent 26ee068 commit 658b262
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Assets/InkPainter/Script/Effective/HeightFluid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Es.InkPainter.Effective
{
[DisallowMultipleComponent]
[RequireComponent(typeof(InkCanvas), typeof(Renderer))]
public class HeightFluid : MonoBehaviour
{
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion Assets/InkPainter/Shader/Effective/HeightToColor.shader
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
_MainTex ("Texture", 2D) = "white" {}
_ColorMap("ColorMap", 2D) = "white" {}
_BaseColor("BaseColor", 2D) = "white" {}
_Alpha("Alpha", Float) = 1
_Border("Border", Float) = 0
}
Expand Down Expand Up @@ -33,6 +34,7 @@

sampler2D _MainTex;
sampler2D _ColorMap;
sampler2D _BaseColor;
float4 _MainTex_ST;
float _Alpha;
float _Border;
Expand All @@ -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);
Expand Down

0 comments on commit 658b262

Please sign in to comment.