Search Unity

Vertex Color Mask??

Discussion in 'Shaders' started by domkia, Jul 20, 2014.

  1. domkia

    domkia

    Joined:
    Aug 19, 2012
    Posts:
    99
    Is it possible to write shader that uses vertex colors as masks. In example mesh has RGB colors and I want to apply specific texture or color to R, G or B part of mesh. I didn't found much info so If anybody knows how to do it I would love to get some pointers or even code snippets. Thanks :)
     
  2. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Bookmarked!

    When I get some time, I can give this a shot for you if you like. It can't be that hard... ;)
     
    domkia likes this.
  3. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    I would like your example mesh, if you can upload it for me, that would be great! :)
    In the meantime, I will use my own mesh for testing.

    EDIT: Do you get flickering on vertex colors? My mesh fllickers... :(
     
    Last edited: Jul 22, 2014
  4. domkia

    domkia

    Joined:
    Aug 19, 2012
    Posts:
    99
    Thank you for helping :) Here is a mesh with vertex colors made in blender, exported as .Fbx
     

    Attached Files:

  5. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Thanks!

    EDIT: I also worked out the flickering: DX11 obviously hates vertex colors...

    My progress so far: I have got the red channel to mask the texture, but changing the mask color just fades out the red atm...
     
    Last edited: Jul 23, 2014
  6. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    My progress so far: I have now got the Hue to shift and change the mask, but there is a couple of bugs still to iron out... Mainly to do with any other colour other than blue doing weird things... o_O

    EDIT: I now have to basically work out some sort of masking test that fails depending on what colour is set.