Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Ever participated in one our Game Jams? Want pointers on your project? Our Evangelists will be available on Friday to give feedback. Come share your games with us!
    Dismiss Notice

Standard shader with vertex colors

Discussion in 'Shaders' started by defaxer, Apr 5, 2015.

  1. jvo3dc

    jvo3dc

    Joined:
    Oct 11, 2013
    Posts:
    1,444
    We had a small issue with a model with small triangles and MSAA. The interpolation of the vertex colors is by subpixel now, which can lead to some artefacts. To set the interpolation by pixel instead, change the register that contains the input color for the pixel shader to TEXCOORD10_centroid instead of COLOR.
     
    Last edited: Oct 19, 2018
  2. Tzan

    Tzan

    Joined:
    Apr 5, 2009
    Posts:
    728
    Does the shader created by the graph system have a Detail Texture slot?
     
  3. MadDevil

    MadDevil

    Joined:
    Nov 4, 2014
    Posts:
    4
    @bossa_dave, can you show us how you did it in shader graph?


    -Thanks :)
     
  4. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,411
    just use the vertex color node in shadergraph
     
  5. d3gator

    d3gator

    Joined:
    May 28, 2009
    Posts:
    21
    Hey guys, the shader is awesome.
    Where i can download latest version?
     
  6. willgoldstone

    willgoldstone

    Unity Technologies

    Joined:
    Oct 2, 2006
    Posts:
    772
    Hey all

    I have been chatting with @Tzan and he prompted me to check on this from our Graphics team - regarding official solutions for vertex colors. The answer is that basically - long story short this is now roadmapped and part of SRP and Shader Graph. We will begin work on it once we've stabilized the SRPs around march and expect to ship support for it in the fall.
    We just have so many other things that beat it priority wise sadly - but I wanted to give you the honest answer that'll allow you to plan ahead. I'm told it involves C++ level changes that we can't just fix in C# land so sadly it's a waiting game on this one - I'd love to give you a workaround but I don't have a solid supported solution for you.

    Hope that helps,

    Will
     
  7. Lars-Steenhoff

    Lars-Steenhoff

    Joined:
    Aug 7, 2007
    Posts:
    2,602
    good news!
    While your at it, please also make vertex position animation and vertex color animation a possibility in the animator

    and also the abilty to import vertex animation from maya
     
  8. Player7

    Player7

    Joined:
    Oct 21, 2015
    Posts:
    1,535
    Good to hear, it's like you guys do read the forums, just a shame the implementation timeline is out of sync with our requests :)

    Honestly vertex coloring painting/shaders should have come supported out of the box with Unity for years already as it's very useful for games..anyway SRP/Shader graph supporting in the future is good, hopefully probuilder tools improves on the tooling for it aswel thanks.
     
    jrumps and Alvarezmd90 like this.
  9. wimvanhenden

    wimvanhenden

    Joined:
    Dec 21, 2018
    Posts:
    1
    Just for Unity 2018 and up in the file UnityVC.cginc change all references:

    half4 tangentToWorldAndPackedData[3]

    to

    float4 tangentToWorldAndPackedData[3]

    And it works fine.
     
  10. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    144
    Is there a way to make the vertex colors emmisive if they're above 1.0f value?
     
  11. Marco-Sperling

    Marco-Sperling

    Joined:
    Mar 5, 2012
    Posts:
    593
    Vertex colors are in the range of [0.0 - 1.0], it is a four byte value.
    They can't go above nor below - not in Unity, not in any authoring software I know of. The mesh formats typically don't support that either nor would the mesh importer of Unity I guess.
    What you could do:
    Use RGB channels of vertex color to color your mesh. Use A channel to scale a constant emissive factor that would set your emissiveness to maximum at A=1.0f and to minimum at A=0.0f.

    Another way to tackle that issue might be looking into "custom vertex attributes".
     
    JimmyCushnie likes this.
  12. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    144
    I see. But I'm asking because I noticed something about Oot3D's vertex colour shader. It's not just adding darkness to the geometry. It's also lighting it up. So the vertex colours aren't 'Lerped' but they're put on top and blended in instead.
    Let me show u:





    That's no light. (It could be done with vertex light, but the shader actually does the trick. You can clearly see the orange colours pop a little more.)
     
  13. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,098
    You could use some other data, like an alpha channel to contain a multiplier, then you would apply this value in the shader to your color. Now you got colors that go over the 0-1 range and you can get them glow with Bloom etc. That would probably do what you want?
     
  14. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    144
    Maybe, I don't think that's how the shader seems to work because a lot of water and waterfall streams use vertex colour alpha to fade them out. Even in the screenshot I posted above, the water has alpha on edges to 'fake' soft edge.
     
  15. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,098
    @Alvarezmd90 I thought you were talking about some generic issue and answered to that. Where above exactly? (Didn't see anything unless it's pages back in time...)
     
  16. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    144
    Above your last comment I posted two screenshots. One of which has vertex colours disabled and one enabled. It's to show that the vertex colors seem to have some sort of blend mode instead of simply lerping it.
     
  17. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,098
    Well, you could implement easily a blend mode in a shader?
     
  18. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    144
    Really? No clue how that's done. :confused:
    I mean, I know how to make the shader itself have a blend mode. But it's an entirely new concept for me to put a blend mode on one layer and have it add or overlay onto the main layer of the shader.
     
    Last edited: Mar 31, 2020
  19. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,098
    Well you could easily implement blends, where shader composites texture B over texture A with a desired blend mode if that's what you want? Or any data that's available in the shader... Add "blend" would be a + operator for two values :). But many of those stock Photoshop blends are quite easy to implement and majority of the math for every 25 or so blend modes is out there.
     
    Alvarezmd90 likes this.
  20. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    144
    Yes and I think it's Photoshop's overlay blend mode. As both the darks and lights put a contrast over the scene. Right now, the vertex color shader just multiplies the color over everything. So just the darks get used. (Even though they're not as dark as the 2nd screenshot from noclip.website)

    https://noclip.website/#oot3d/entra...N(F=GNIfQl:2ZUmH9|Un6ZmV]iahUd/{=UPdBI9aoO9WP

    You'll see it better on that site. When toggling it on and off, some parts actually light up.
     
  21. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,098
    Yes I can see it, but is the question that you want to implement it to some shader you want to create, or add it to some existing shader?
     
  22. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    144
    I want to add this technique to the shader featured in this topic. I always use the specular one (to fully disable specular reflection).
     
unityunity