How can you read parametric UVs in vex?

   1718   5   0
User Avatar
Member
8 posts
Joined: 5月 2023
オフライン
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]
Edited by LeoEvershed - 2025年2月25日 09:26:50

Attachments:
parametric_uvs_in_vex.png (2.0 MB)

User Avatar
Member
744 posts
Joined: 9月 2013
オンライン
Put this in a vertex wrangle to get intrinsic UVs for each primitive:

xyzdist(0, itoa(i@primnum), v@P, set(0), v@st);
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
8 posts
Joined: 5月 2023
オフライン
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!
User Avatar
Member
744 posts
Joined: 9月 2013
オンライン
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);
https://procegen.konstantinmagnus.de/ [procegen.konstantinmagnus.de]
User Avatar
Member
3 posts
Joined: 10月 2021
オフライン
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?
User Avatar
Member
5319 posts
Joined: 2月 2012
オフライン
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:

Senior FX TD @ Industrial Light & Magic
Get to the NEXT level in Houdini & VEX with Pragmatic VEX! [www.pragmatic-vfx.com] https://lnk.bio/animatrix [lnk.bio]
  • Quick Links