Jump to content

How do you get UV density and UV distortion as attributes?


DASD

Recommended Posts

1.
How do you get UV density and UV distortion as a vertex attributes?

2.
How would you get UV overlap as a vertex attribute?

3.
How would you get UV direction (flipped UVs) as a vertex attribute?

 

(I can think of ways to build this stuff, but I am looking for solutions that already exist. Packages like Maya give you this kind of information by default. I would imagine Houdini does too. )

Link to comment
Share on other sites

The UV density would be the ratio of UV space to object space I suppose, which is also related to how you would compute the distortion.

The larger the difference is between the shape (not size) of the UV polygon compared polygon shape, the more distortion you have, which is always >0 for organic models,

unless you cut out every uv polygon separately (which is a lot worse for texturing purposes)

Link to comment
Share on other sites

With distortion I mean how far the UV triangle shapes deviate from their 3D polygon shape. And with density I mean how small or large UV triangles are relative to each other (compensated for the original 3D polygon size).

For an optimal unwrap distortion would be low and density variation would be low too.

Edited by DASD
Link to comment
Share on other sites

  • 1 year later...

Sometimes when you are searching for something and you find a topic you visited a long time ago, but no new posts were made in the meantime..
I guess that is a call to action :P

The following code outputs 2 vertex attributes related to distortion;
one is the angle difference between uv and world, vertex corners
the other gives the edgeLength ratio difference between the in and outgoing edge of every vertex.

Afterwards you can of course use an attribute promote to get the average primitive or point distortions of course
or you can merge the distortion into a single attribute by taking the maximum value for example
 

//run over vertices:

//get neighbouring verts
int locVert = vertexprimindex(0, @vtxnum);
int prNumVerts = primvertexcount(0, @primnum);
int vtx0 = primvertex(0, @primnum, (locVert - 1) % prNumVerts);
int vtx1 = primvertex(0, @primnum, (locVert + 1) % prNumVerts);

//printf("%d - %d - %d\n", vtx0, @vtxnum, vtx1);

//get world posData
vector p0 = vertex(0, "P", vtx0);
vector p1 = vertex(0, "P", vtx1);

p0 = v@P - p0; //get position edges
p1 = p1 - v@P;

float posEdgeL0 = length(p0); //get position edge lens
float posEdgeL1 = length(p1);

p0 /= posEdgeL0; //normalize pos edges
p1 /= posEdgeL1;

//get uv posData
vector uv0 = vertex(0, "uv", vtx0);
vector uv1 = vertex(0, "uv", vtx1);

uv0 = v@uv - uv0; //get uv edges
uv1 = uv1 - v@uv;

float uvEdgeL0 = length(uv0); //get uv edge lens
float uvEdgeL1 = length(uv1);

uv0 /= uvEdgeL0; //normalize uv edges
uv1 /= uvEdgeL1;

//get edgeRatios
posEdgeL0 /= posEdgeL1;
uvEdgeL0 /= uvEdgeL1;

//compare world and uv data
float worldDot = dot(p0, p1);
float uvDot = dot(uv0, uv1);
f@uvDistortAng = abs(worldDot - uvDot); //this value should be between 0 and 2
f@uvDistortLen = abs(posEdgeL0 - uvEdgeL0); //you may want to normalize this value in a different node later


Edited by acey195
  • Like 3
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...