IRCSS / TexturePaint

Painting directly in mesh textures in Unity 3d with shaders

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Multi-user painting

iamtheonly opened this issue · comments

Hey!

I'm working on a prototype of a game where more than one user can paint to the same texture. I'm trying to use your project as a code base, but can't figure out how to add multiple painters. Could you point me into any direction here based on your project?

Hey,
For adding multiple painters, you simply need to add multiple mouses. If you look at the TexturePaint.shader Line 72-77, you will see the sign distance calculation used to determine per pixel if it is within the brush radius and should be colored. I go more in depth in this blog post, in the painting section on how that works.

So what you need to do to have a second mouse, is basically passing on another _Mouse2 from the CPU as uniform to the shader and in the fragment shader duplicating all calculations you are doing for mouse 1. In the file TexturePaint.cs line 131 you can see the place where I pass on the _Mouse vector and you could duplicate what I am doing there to pass on a second mouse.

Btw if you don't want to use a mouse, you can obviously pass on any other position. I rewrote this repo for VR months ago, and passed the world position of the controllers instead of the mouses to the shader.

Awesome, thanks for your help, I really appreciate it!

Looking good so far :)

GIF