Skip to content

Multi-user painting #1

Open
Open

Description

@iamtheonly

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?

Activity

  1. IRCSS commented on May 2, 2020

    @IRCSS
    Owner

    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.

  2. iamtheonly commented on May 2, 2020

    @iamtheonly
    Author

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

    Looking good so far :)

    GIF

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions