Skip to content

Best Practices

Here are some tips to assist with the configuration and use of 2D/3D Paint.

Performance improvements

If your app struggle with performance issues, here you can find steps to improve it. Here's steps that may improve the performance:

  1. Brush Duplicate Part: defines the frequency at which brush samples are rendered in case of using SpriteRenderer and RawImage components. This value affects both the number of vertices and the density of the lines. A higher value results in fewer brush samples being drawn, which can reduce the detail and density of the line. Conversely, a lower value will produce more vertices, leading to dense lines. To reduce the number of rendered vertices, set the value to 24, 32 or higher:

    Image title

  2. Raycast Interval: defines the frequency at which raycasts will be performed. A higher value results in fewer brush samples being drawn, which can reduce the detail and density of the line. Conversely, a lower value will produce more vertices, leading to dense lines. To reduce the number of raycasts, increase the value:

    Image title

  3. Smoothing: tool smoothing parameter allows for the drawing of smooth lines for SpriteRenderer and RawImage components. The smoothing level can be adjusted on a scale from 1 to 10. A value of 1 deactivates smoothing, while a value of 10 provides the maximum line smoothness. When the smoothing value exceeds 1, the line drawing process involves rendering additional brush samples and painting lines may have 2 frames delay. To improve the performance, decrease the Smoothing value to 2-4, or turn it off entirely by setting it to 1:

    Image title

  4. Undo/Redo System: undo/redo system can be disabled to increase performance:

    Image title

Painting in World space

Painting in World space uses model normals to avoid painting on back side of the mesh. If your model doesn’t have a Normals, you can generate one in Unity by chossing the Calculate option in the model settings:

Image title

Alternative, if you don't want to use mesh normals, you can decrease Normal Cutout value in PaintManager component:

Image title

Drawing dots instead of lines

To drawing with dots instead of lines, turn off Can Paint Lines in PaintManager component:

Image title

Disable brush rounding

To disable the rounding of the brush, set the Hardness parameter of the brush to 1.

Paint on Sprite with transparency

To paint on Sprite with transparent areas, use Material with Shader XD Paint/Alpha Mask and set Texture as Main Texture and Mask Texture:

Image title

After, choose the Shader Texture Name as _MainTex:

Image title

Painting with colliders

To enable painting using colliders, follow these steps:

  1. Add the ColliderPainter component to a GameObject that has a Rigidbody component. This setup allows painting based on collision events.
  2. The ColliderPainter component offers the following key parameters:
    • Color - defines the color used for painting during collisions.
    • Pressure - adjusts the pressure applied during painting, which affects the brush size.
    • FingerId - specifies the index of the finger used for painting through collisions (useful for multi-touch scenarios).

This configuration enables painting actions to occur when collisions are detected between objects.

Image title

SkinnedMeshRenderer recommendations

If you use Skinned Mesh for painting, it is recommended to use default transforms: root animation and mesh objects position as 0:0:0, rotation as 0:0:0, and scale 1:1:1:

Image title
Image title

Pixel Art

To work with pixel art graphics, set Filter Mode to Point in PaintController and PaintManager components, and set BrushDuplicatePartWidth to 1 in Settings:

Image title