These scripts (and a shader) allows you to draw on textures at runtime with lightning-fast speed, unlike if you trying to do the same on CPU using GetPixels
and SetPixels
.
Stable drawing at high FPS (1000 on Nvidia GTX 1060). Same result, but using CPU to change texture runs at 10-15 FPS (trust me).
Also, there is an example with a "scratch" shader:
All essential scripts and shader lies under Scripts
and Shaders
folders. Brushes lies under Textures/brushes
folder.
- Put
MouseDrawController.cs
script on your camera, set brush texture, color and size in it - Put
DrawZone.cs
script on mesh that you want to draw on
You can also inherit DrawZone.cs
and create your own behaviour of script, example given in ScratchZone.cs
Brushes are black/white images. White area draws, black doesnt.
You have to unwrap your mesh properly, so left bottom corner of mesh must be (0, 0) on UVs, and the top right corner of mesh must be (1, 1).
Just like this:
Thanks for your attention! I will be pleasured to see any feedback :)