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:
-
Brush Duplicate Part: defines the frequency at which brush samples are rendered in case of using
SpriteRenderer
andRawImage
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: -
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:
-
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:
-
Undo/Redo System: undo/redo system can be disabled to increase performance:
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:
Alternative, if you don't want to use mesh normals, you can decrease Normal Cutout
value in PaintManager component:
Drawing dots instead of lines
To drawing with dots instead of lines, turn off Can Paint Lines
in PaintManager component:
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
:
After, choose the Shader Texture Name as _MainTex
:
Painting with colliders
To enable painting using colliders, follow these steps:
- Add the
ColliderPainter
component to a GameObject that has a Rigidbody component. This setup allows painting based on collision events. - 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.
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:
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: