#Can I use vertex colors to define UV islands for animation?

24 messages · Page 1 of 1 (latest)

forest sundial
#

So I have a cube that has 2 UV islands, all split properly, with one vertex colored pure red and the other green. You can see their profile in the attached texture.

What I want to do is be able to change their offsets independently in script. By moving them randomly around my texture map, I can fake a lot of variation with just one map.

Problem is I'm trying to channel mask out the vertex colors in the shader graph, but they eventually get recombined so that any offset moves all the UV.

Anyone know how to manipulate UVs just off their vertex colors, or if there's another way to handle shells independently?

twin drift
#

Not a shader expert, but do you mean you want to independantly control UV coordinates for each part of the mesh? As far as I know, the UV shells can't be manipulated like that. I mean, you could reconstruct the vertex buffer of the mesh, and manually slide its UVs. But thats not super effecient.

It might be easier to just create your cube, and split it into two submeshes (red, and green). Then, in Unity, assign to the Renderer two Materials. Then you can just manipulate each material to be whatever UV offset/tiling you want, without affecting the other submesh.

forest sundial
#

Thanks, yeah that's sort of what I ended up doing, I used the same material in two different material slots so I could manipulate the UVs separately.

Like you called out, the thing I discovered was Unity has no concept of UV shells 😦

blissful cloak
#

I don't see why Unity wouldn't allow you that.

For one thing, in shader code, it's possible without any issue, so maybe it's a shader graph related thing.

#

So either it's a shader graph limitation that doesn't exist in shader code, in which case you should probably just write some shader code.

Or it's a bug in your shader graph, and maybe it's perfectly possible but you need to fix something in your graph.

forest sundial
blissful cloak
#

Or have some neutral equation for 0?

#

If you use vertex colors to distinguish, then it just acts as a mask, so you use that like you would any mask.

#

You say "but they eventually get recombined so that any offset moves all the UV', but that sounds much more like your mask fails and there is an error somewhere in your code.

#

Because some noise * 0 is 0, there is no "recombination" or whatsoever.

#

Anyway, it's definitely not a Unity problem, Unity can perfectly handle that. If you want to move forward from there, show us your shader graph and we can debug it.

#

OK something I can think of is that the UV will have some linear interpolation inbetween.

#

Which is normal.

#

It's this thing, same with UV.

#

Now if your "islands" are not actual islands, i.e. the vertex are linked to each other and not separate sub-meshes, then they will interpolate.

#

Meaning that the noise of your red island will bleed into your green island.

#

But that's a mesh issue, then.

#

Now I'm not super famliar with Maya (by that, I mean that I'm not familiar with it at all), but I know Blender quite well.

One large trick between Blender & Unity is that meshes are not exported as 1-1 vertices, mostly because Blender use internal optimizations that make sense for a rendering engine, but not for a game engine.
One such example is that flat UV in Blender do not create additional vertices, but when exported into Unity, each triangle is handled as a separate and unique set of 3 vertices, without neighbors.

There are most likely similar transformations made by Maya when exporting.

Generally speaking, it's a good thing to check your exported mesh to see what it's actually made of, because your shader code is going to have you go nut if your mesh is not what you actually expect it to be.

forest sundial
# blissful cloak OK something I can think of is that the UV will have some linear interpolation i...

I don't have my shadergraph anymore because I moved on to solving the problem with separate material IDs instead, you what you called out IIRC is exactly where I was getting stuck. Basically after multiplying the R and G channels by their respective offsets, when I recombined them the resulting color was yellow? and not isolated anymore.

One large trick between Blender & Unity is that meshes are not exported as 1-1 vertices, mostly because Blender use internal optimizations that make sense for a rendering engine, but not for a game engine.

Thanks for the tip! Don't think this impacted me though, UVs looked fine.

Now if your "islands" are not actual islands, i.e. the vertex are linked to each other and not separate sub-meshes, then they will interpolate.

Right, so in Blender not sure if this was the correct way, but I made sure to add the Face Corner attribute and edges were UV seamed. The vertex colors can then be seen clearly cut off at geometry edges, not just interpolated.

lilac crestBOT
#

noisewar thanked xahellz

blissful cloak
#

Seams will create additional geometry, effectively splitting your vertices into islands.