検索 - User list
Full Version: How can you read parametric UVs in vex?
Root » Technical Discussion » How can you read parametric UVs in vex?
LeoEvershed
I'm wondering if there's an easy way of accessing the parametric uv (implicit uv) in vex?

I've seen these UVs referred to as intrinsic primitive UVs, parametric UVs or implicit UVs in different places in the documentation.

I want to write the parametric UVs to a vertex attribute in houdini. I've tried doing this with vex but the solution is clumsy and only works on quads:

vector bottomLeft = primuv(0,"P",@primnum,set(0,0));
if (v@P == bottomLeft) {
    v@uv = set(0,0);
}
vector bottomRight = primuv(0,"P",@primnum,set(1,0));
if (v@P == bottomRight) {
    v@uv = set(1,0);
}
vector topLeft = primuv(0,"P",@primnum,set(0,1));
if (v@P == topLeft) {
    v@uv = set(0,1);
}
vector topRight = primuv(0,"P",@primnum,set(1,1));
if (v@P == topRight) {
    v@uv = set(1,1);
}



I want to extract the exact parametric UVs that houdini generates for each polygo. This page can be used as reference: https://www.sidefx.com/docs/houdini/model/primitive_spaces.html [www.sidefx.com]
Konstantin Magnus
Put this in a vertex wrangle to get intrinsic UVs for each primitive:

xyzdist(0, itoa(i@primnum), v@P, set(0), v@st);
LeoEvershed
Konstantin Magnus
Put this in a vertex wrangle to get intrinsic UVs for each primitive:

xyzdist(0, itoa(i@primnum), v@P, set(0), v@st);

Cheers! I forgot you can use normal group semantics in the primgroup parameter and not just pre existing groups. That works great!
Konstantin Magnus
Nowadays the pointprimuv function returns intrinsic UVs:
https://www.sidefx.com/docs/houdini/vex/functions/pointprimuv.html [www.sidefx.com]

pointprimuv(0, i@ptnum, i@primnum, v@uv);
stereocolor
I just ran into an issue when trying to use pointprimuv on a nurbs grid, I only the first component, v is all 0.

I managed to work around it by first storing the u value in a wrangle, then swapping the U and V using a primitive properties sop, storing the "new u" value in another wrangle, then swapping it back again.

Am I missing something obvious or is this a bug?
animatrix_
stereocolor
I just ran into an issue when trying to use pointprimuv on a nurbs grid, I only the first component, v is all 0.

I managed to work around it by first storing the u value in a wrangle, then swapping the U and V using a primitive properties sop, storing the "new u" value in another wrangle, then swapping it back again.

Am I missing something obvious or is this a bug?

NURBS have poor support in Houdini, especially in VEX, so I would not be surprised if this is a bug.

For example, if you start using functions like xyzdist() on NURBS geometry, the performance will tank compared to polygonal geometry.

As for pointprimuv() specifically, I had actually implemented my own version of this and submitted it to SideFX as an RFE before the function was later added to Houdini.

I also showed my original implementation in this Tokyo HIVE presentation if you want to see a practical use case:

This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.