Home Unreal Engine

Vert colour blending material

polycounter lvl 19
Offline / Send Message
adam polycounter lvl 19
Hello!

I am trying to set up a material where all of its colour data comes from the material itself (read: no diffuse maps), that can then be vertex colour blended up to 5 times.

My material looks like this:
WhQqNvQ.png

The mesh it is applied to looks like this whenever I try and paint a colour on it. In this case I am trying to paint purple on to the green here.

qNxKu0M.png

If I tell the paint tool to show "RGB" only, I get this:

TGpTkzs.png

From what I can deduce, I am painting vertex colours but I have no set up my material to properly overlay vertex colour on top of the diffuse colours.

Any ideas on how I might achieve this or what I've done wrong?

Replies

  • LMP
    Options
    Offline / Send Message
    LMP polycounter lvl 13
    I'll try reproducing your mat in UE4 and seeing if I can't take a crack at this.
  • MooseCommander
    The reason the whole mesh appears green is because you are using Alpha blend as your "top" blend layer, and alpha always defaults to a value of one, so it will always pick the highest option, which in this case is green.
  • LMP
    Options
    Offline / Send Message
    LMP polycounter lvl 13
    4WswFhh.jpg
    R775905.jpg

    Results of my first experimentation. I can get things to paint, and show different values while painting in various channels. But if there is alpha it results in green. Note the magenta in the RGB only image, when compared to the color image, where there is alpha, there is green, like MooseCommander said.
  • LMP
    Options
    Offline / Send Message
    LMP polycounter lvl 13
    Another experiment...

    I can get blended colors if I only paint with values below 1 for the RGB, but I'm not sure this is the goal. As the result is rather muted. Could you give an explanation of what your final result goal is?

    TGmCU9Y.jpg
    H6Eyydt.jpg
  • LMP
    Options
    Offline / Send Message
    LMP polycounter lvl 13
    I can paint all the colors that are LERPed fairly cleanly when I paint in "Blend Weights" mode, and set it to 5 (one minus ARGB)
    AKizqut.jpg
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    MooseCommander has hit it.
    Flood with alpha 0 to get the green to go away, OR reverse your alpha and 1-alpha blends.

    BE AWARE you will get leaky blending of the two colors that are tied to alpha in transition zones. I.E. if you are painting green on top of anything, you'll get some orange fringe here and there, because that's how the math works.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Rainbow T-rex eats a blue torus XD
    AKizqut.jpg[/QUOTE]
  • adam
    Options
    Offline / Send Message
    adam polycounter lvl 19
    Hey! Aaah so many good suggestions. I ended up just plugging the vertex colour node in to the basic colour slot, allowing me to paint whatever colour i wanted anywhere on the mesh (which was white). It's pretty much what I wanted to do, so that works.

    I had to turn down the Paint brush tool's alpha as per Andreas Stromberg's reply here - https://twitter.com/Stromberg90/status/567815002468659201 in order to get the colour to appear on the mesh when not in 'RGB' view.
  • adam
    Options
    Offline / Send Message
    adam polycounter lvl 19
    Tomorrow I am going to see if I can't clamp the colour gradiation some how. I am not using texture maps so its not a 'texture blend' which I could just apply a blend mask to. Virtuosic (Ryan Smith) recommended I look at Multiply and Clamp to achieve that.

    Edit:

    I can do the top blend, thats default.

    I'm going to see if I can't clamp that gradiation for something like the middle and bottom.

    U0DhELJ.png
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Cheers Adam,

    Are you talking about how the vertex colors are blending between vertices?
    If you're painting in full color, I don't know that you can get that blend, as its a hardware level lerp, and you're not wanting a linear gradation.

    If you go back to painting masks you could get an adjustable gradation like that a number of ways.
    Most straightforward but also smooth method that comes to mind is something like this:

    X = your basic linear gradation
    C = some constant to control the sharpness
    output = ConstantClamp((C Sin(PI(x-0.5))+1)/2

    play with a graph version here: https://www.desmos.com/calculator/kje7gqjjgu

    So node wise you'd take your black and white gradient, add -0.5, multiply by pi, plug that into a sine node, multiply that by your sharpness parameter, then run it into a constant bias scale node (bias = 1 scale = 0.5) then all that into a clamp (between 0 and 1). Then run the output into the alpha of a lerp for your colors.

    now how you'd reliably do it with a full color gradation not being driven by a lerp, I'm not sure
  • Clark Coots
    Options
    Online / Send Message
    Clark Coots polycounter lvl 12
    Vailias, while you're on the topic of the Constant Bias Scale Node, would you mind explaining what that does? My understanding is it's a multiply and add node combined, but I don't really get it...

    Also, Adam R&D UE4, vertex painting, and no texture maps for next Assassins Creed confirmed.
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    Constant bias scale is really just short form for an add multiply, yes.

    Think like manually unpacking a normal map. Your source data is from 0-1, black to white, but you need it in the range of -1 to +1.
    So you need to bias it, and scale it.
    in this case, you add(bias by) -0.5 then multiply(scale) by 2.
    graphical example to play with: https://www.desmos.com/calculator/nkawgowtio

    The black dashed line is the normal distribution of values in a full gradient. (just all the numbers from 0-1)
    The red line is those same numbers after the constant bias scale operation where the b slider is bias, and the c slider is the constant.

    For what I recommended to Adam, its basically the reverse of a normal map unpack

    The sine function outputs values from -1 to +1 over the period of 2Pi (because the function is in radians). But what is useful for the blending is just the 0-1 range where a 2 point lerp is well defined. So the constant bias scale for a bias of 1 and a scale of 0.5 will make a -1 to 1 data set into a 0-1 data set.


    If you recall geometry, adding a number to a function moves it up and down the graph, multiplication squashes and stretches the figure, while adding to the domain of the function moves it horizontally. So a constant bias scale both moves and stretches the graph at once. Images are really just numeric data, even though we display them as colors.

    If you look at the gradient results he wants, imagine them as a height map rather than a color gradation. If you look at it that way, you'll see what's changing is the steepness of the slope around the halfway point (0.5).
    I suggested with the sine option as it has a natural pivot point to its overall slope, regardless of wavelength ( the function varies about its zero point), it also gives smooth, and in my opinion predictable, results. So you'll only need one variable to get a wide variety of looks. Really you could even drive the gradation sharpness with another paint channel, but you'd have to come up with another method of blending more than 2 colors.
  • ZacD
    Options
    Offline / Send Message
    ZacD ngon master
    I definitely want to see that in action, I might have to test it out.
  • Clark Coots
    Options
    Online / Send Message
    Clark Coots polycounter lvl 12
    Ah thank you Vailias. That makes more sense to me, it's nice to see a graphical representation of whats going along side your explanation. I have a couple more questions.

    Why is a Normal Map in -1 to 1 space? Are 3 channel images always that way? I assume alpha or single channels in an RGB image are 0-1?

    If you were to take something thats -1 to 1 and constant bias scale it with incorrect values, going into a Lerp alpha, would the Lerp give an error because it's not receiving 0-1 information?

    Given you can scale the information to whatever you want, does this lead to lost or fill in the blank information? Similar to sizing an image up or down in resolution you lose/fake/average pixel color.
  • Vailias
    Options
    Offline / Send Message
    Vailias polycounter lvl 18
    To avoid derailing Adam's thread, my reply is posted over in the How you make dem mats? Thread. Where it will be more on topic.
Sign In or Register to comment.