https://github.com/siberder/UnityDrawOnGPU
⚡ Fast drawing on textures at runtime using GPU
https://github.com/siberder/UnityDrawOnGPU
drawing gpu shaders unity
Last synced: about 1 year ago
JSON representation
⚡ Fast drawing on textures at runtime using GPU
- Host: GitHub
- URL: https://github.com/siberder/UnityDrawOnGPU
- Owner: siberder
- Created: 2020-04-12T17:45:12.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-12T22:27:26.000Z (about 6 years ago)
- Last Synced: 2024-11-10T17:45:22.696Z (over 1 year ago)
- Topics: drawing, gpu, shaders, unity
- Language: C#
- Homepage:
- Size: 32.7 MB
- Stars: 12
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Drawing on textures at runtime with GPU in UNITY
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`.
## In action

**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:

## Usage
All essential scripts and shader lies under `Scripts` and `Shaders` folders. Brushes lies under `Textures/brushes` folder.
### Scripts
- 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
Brushes are black/white images. White area draws, black doesnt.
### Mesh requirements
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:

## Conclusion
Thanks for your attention! I will be pleasured to see any feedback :)