EsProgram/InkPainter

Modifying the alpha of brush at runtime causes abnormal paint behavior

vizkidd opened this issue · 1 comments

bug

When changing the brush's alpha at runtime causes only the last or the latest painted brush to simulate fluidic effects (see screenshot) (Modifying scale works fine)

(Note: How can I change the width and height in scale separately?)
(Note2: Changing the alpha in HeightFluid changes the alpha of all the painted brushes ☹️ )

This is how I change alpha in the Update() function

//vars
public InkCanvas inkCanvas; //set in inspector
private static readonly System.Random random = new System.Random();
float dampedAlpha;

//functions
private void Update()
{
	if(Input.GetMouseButton(0))
	{
		var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
		RaycastHit hitInfo;
		if(Physics.Raycast(ray, out hitInfo))
		{
                    dampedAlpha = Mathf.SmoothDamp(dampedAlpha, (float)RandomNumberBetween(0f,1f), ref vel, Time.fixedDeltaTime);
                    Brush tempBrush = brush; 
                    tempBrush.Color = new Color(brush.Color.r,brush.Color.g,brush.Color.b,dampedAlpha); 
                    inkCanvas.Paint(tempBrush, hitInfo);
                  }
          }
}

private static double RandomNumberBetween(double minValue, double maxValue)
{
    var next = random.NextDouble();
    return minValue + (next * (maxValue - minValue));
}

Steps to Reproduce:

  1. Attach "InkCanvas" Component to plane.
  2. Attach "HeightFluid" script to the plane.
  3. Uncheck "Performance Optimize" in HeightFluid script
  4. Change Properties of brush to:
Color Blend Type = Alpha Only
Normal Blend Type = Add
Height Blend Type = Use Brush
  1. Create a custom script, modify the alpha values in Update() and paint.

Thanks for the report!
currently investigating, so please be patient.
I'm sorry for contact late.