Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modifying the alpha of brush at runtime causes abnormal paint behavior #54

Open
vizkidd opened this issue Apr 2, 2018 · 1 comment
Open

Comments

@vizkidd
Copy link

vizkidd commented Apr 2, 2018

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.
@EsProgram
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants