How to pick exact colour from a vertex?

Hi, I want to pick a colour from a vertex, if you are familiar with maya it’s ‘grab colour->selected vertex colour’. The colour picker picks from the screen which gives me the wrong value, I need the value that is on the vertex. Does anyone know how I could do this?

Cheers in advance

I’ll just be more specific in what I’m trying to do here. Basically I’m using vertex colour (green channel) to index into the uvs of a palette texture and offset it accordingly. Let’s say I have 10 boxes in a scene and I assign a vertex colour of 0.1, 0.2, 0.3, 0.4…up to 1 - I would expect to be able to index 10 different colours in the palette texture. I understand though that unlike Maya, Blender doesn’t use linear values for vertex colours?? In which case how do I convert those sRGB values to linear, becuase everything I’ve tried so far hasn’t worked :frowning:

*Note - I should mention that inputting flat values from a node gives me the expected result, but using vertex colour is proving a bit more troublesome.

Basically when “attribute” node get vertex color, there is a gamma correction done. Try a “gamma” correction of 2.2 / ~0.45 for reverse.

Yeah i actually tried that already but i still got a wrong result after de-gammaing the vert colors. I’ll post an image of the shader later on and maybe you can see something obvious that’s wrong. I’m just basing it off a stingray setup i made for maya that’s working fine. It’s definitely something wrong with how it’s processing the colours.

Cheers

Yeah, pow 2.2 is just an approximation; Blender uses a different forumla for sRGB->linear. Pow 2.2 should be good enough for plus or minus 5% though, just can’t use equality, have to be fuzzy. There are places you can find the conversion formula to make a node group with some Googling. There are even multiple posts on BlenderArtists with pics of the node group…

Might consider using UV to store your per-vertex values instead. Not paintable, but easier to assign, use for math. And for your use, it actually makes more sense, and is probably more intuitive, than vertex color.

Funny you say that. I did originally have it stored in a uvset but it was switched to vert colours as it was decided we needed uvs for something else, so we’re stuck with that now unfortunately. Saying that I still would expect the vert colours to be stored linearly and retrievable as such, the gamma correction must be applied to those values somewhere. The project is Maya based anyway and the pipeline is working fine in that but I wanted to use those assets as an excuse to learn Blender in my spare time. Just got stuck at the first bump in the road. I’m sure there’ll be a way just gotta stick at it!

Btw you got a link to any of those conversion formulas? Gonna give that a try next

Try https://entropymine.com/imageworsener/srgbformula/ . Works for me.

What about multiple UVs?

Me too, I think Blender’s color management philosophy is irritating in how much hand-holding it does that just makes everything more complicated, like a smart appliance that isn’t smart enough to do what you want but is smart enough to not do what you tell it to. Maybe if they ever get around to making a vertex color node it’ll have a “color mode” drop down.

Absolutely! That’s a great analogy :slight_smile:

A drop down or something to be able to specify what color space you want the vertex colours output to be would be great. This just seems a massive faff to do something very simple. I use UE4 and other game engines a lot and in those I use vertex colour extensively. They also expect those colours to be linear so it’s kind of standard for me. As I work in games I use vert colours more as a utility than for rendering and I think that’s the difference.

That link looks like what I want and I found a good thread on it too …

…but not sure how to put the ‘if’ condition into shader nodes?

I understand this is pretty niche but maybe if anyone from the dev team is reading they might be able to implement something like this? For games development I can see it being pretty useful, and I hear the blender team is pretty good on listening to feedback ^^

Incidentally this is the shaderfx graph I’m trying to recreate, it’s very simple, just uses vcol green into the U co-ord

An “if” is just a lerp, where you’re either lerping 0 (original value) or 1 (new value).

Let’s say, “if a then b else c” where a is a boolean value, 0 or 1, just like the output of a math greater than node. Then the expression that gives you “if a then b else c” is (a*b)+((1-a)*c).

Well, 2.81’s out, with a vertex color node, but nope, no color space options.

Although you could probably use the alpha channel instead for linear output. Untested though.

Thanks for the breakdown, you really know your stuff! Luckily I didn’t have to delve that deep. Looks like the vertex alpha was what I needed. I found a good plugin here to copy the green channel into the vertex alpha …

…then used that as the uv input and - bosh - it’s working just how i wanted. Eventually I would still like to get a linear output from the RGB too (do you know where to make requests btw?) but this is a decent workaround for now. Here’s the maya/blender result…

Thanks for all your help :slight_smile: