Search Unity

Question Texture Blend in Vertex Paint Shader

Discussion in 'Shader Graph' started by Tibsterx, Dec 27, 2020.

  1. Tibsterx

    Tibsterx

    Joined:
    Mar 4, 2020
    Posts:
    10
    Hi, I am trying to build a vertex paint shader. I have seen the tutorials using the RGBA channels to do it, but we are trying a different method.
    The part I am stumped on, is how to make an appealing transition or blend between textures.
    First, we are manually using Mesh.SetColor in our code to set a red value on each vertex.
    Then, in the shader, we check the red value. For each r value between 0-255 we would assign a different texture.
    upload_2020-12-26_21-38-38.png
    Here is a simple example using just two textures.
    upload_2020-12-26_21-39-5.png
    And this is what it does.
    I am hoping to add noise or blending along the transition. Since we will potentially be using every red value from 0-255, we can't use gradient values from the vertex color itself. Any help would be much appreciated, thanks!
     
  2. Olmi

    Olmi

    Joined:
    Nov 29, 2012
    Posts:
    1,553
    Those colors in Shader Graph (and in Unity shaders in general) aren't in 0-255 range, but in 0-1. But you can of course scale your values to whatever range you need.

    I am not sure what I'm seeing in the second image, but in order to get smooth transitions, whatever value is controlling the transition must have a gradient and not an abrupt change.

    Are you sure your test object is correctly created/modified? Maybe you could bring in a test object from Blender or other 3D app.