Author Topic: Match a shape coordinates with vertex colored UV island  (Read 203 times)

Hello everyone!

Very often there are different individual things (for example: a Logo on a Tape Recorder), which I place in textures in particular places by transform coordinates. These places depends on UV islands, which I usualy paint in different vertex colors to find them using baked color map from mesh and "Color to Mask" node. But, also very often, especially after adding any new details on my model in Blender - UV island change their places on UV map and I have to move these individual things (Logo) to the new island place by transform node and spend a lot of time fot this. How can I attach a shape coordinates to, for example, center of vertex painted UV island? Is it possible that Logo will get new place automatically, or I need move it by hand everytime?

I hope I'm understanding you correctly.
Let's say these are my color IDs, and I want my logo to fit within the red square:

You can generate a UV for that color ID, and then map your logo with that UV later. This is how you can generate a UV for the red square:

Now I'm going to use a very simple pixel processor to map my logo onto that UV:

Here's my function for the pixel processor:

There might be a node that does what my pixel processor does, but I can't find it. It's called something like "UV lookup" I think.

This graph will always map your logo onto the red surface, regardless of the surface size and shape! If it changes size, the logo will change size with it.

I hope that helps!
"Better than some, no worse than others."

Hello Robin.
Thank you for your answer and sorry for the long response, didn't check the forum several days.
Yes, your method is working well, but unfortunately only for squared logos. In case of not squared logos - it seems that I need to solve two issues somehow: how decrease logos size proportionally (without stretching according to UV island size) and how consider if the UV-island was rotated after updating.
But, anyway, thanks for your help! You showed me a good direction. It seems that I need to research pixel processor deeper to find its more complicated structure, then in your example, to solve these issues.

Good news! Detecting rotation and fitting into a non-square aspect ratio are both possible.
I'll try to make you an example soon, but it might help to know how you're going to use it. Just so I don't do anything that doesn't apply in your challenge.
"Better than some, no worse than others."

Maybe these pictures help to understand my idea better:
1. I created a mesh with some vertex painted faces:
2. Then I import it to SD and want to place my Logo picture in the center of vertex painted area (I already use new method here):
Now we see the first issue with stretching.
3. Then I decided to add anything to my model and, after reunwrapping, its UV map changed and vertex painted islands moved to another place and rotated:

4. And now I need my logo to be in new place with no stretching and with correct rotation:

Oh, well I wouldn't know how to detect that kind of 90° rotation. You could possibly solve it by testing for difference between preset rotations or something, but here I think it's much easier to set up a simple switch for the user to rotate the map the right way.
When it comes to the non-square logo, I would imagine the easiest thing to do is stretch out the image just the right amount before squashing it down into the rectangle.
But I can't leave without saying that this probably isn't the right way to solve your problem at all.
Ideally you'll control your UV space so that aligning the logo won't be a problem. Remember, you decide where the unwrapped polys go!

In case it helps, I'll leave a screenshot of my attempt at detecting some form of rotation. Perhaps you'll glean a useful technique.

"Better than some, no worse than others."

Well, you are right, it seems that there are too many hard-to-detect things here. For example, it is hard to imagine how to detect in SD if an island was rotated of 180°, because in this case it will look the same in UV map. Now I use for islands, wich highly individually textured, the approach with list of particular X and Y coordinates, and particular size in UV map. It seems that it is the best way at the moment.
Anyway, thank you for yor help and spent time!