Skip to content

osd_lookuppatch

int  osd_lookuppatch(<geometry>geometry, int face_id, float face_u, float face_v, int &patch_id, float &patch_u, float &patch_v)

If you don’t specify a texture attribute, the function uses intrinsic polygon interpolants.

int  osd_lookuppatch(<geometry>geometry, int face_id, float face_u, float face_v, int &patch_id, float &patch_u, float &patch_v, string attribute)

If you specify a texture attribute, the function uses the UVs in that attribute to translate the face coordinates onto the OSD patch.

Given the face_id and texture coordinates for a point inside the face (face_u andface_v), this function will return the corresponding patch_id (Catmull-Clark subdivision face) and the patch interpolants (patch_u and patch_v). The reverse function to map from patch to face is osd_lookupface.

<geometry>

When running in the context of a node (such as a wrangle SOP), this argument can be an integer representing the input number (starting at 0) to read the geometry from.

Alternatively, the argument can be a string specifying a geometry file (for example, a .bgeo) to read from. When running inside Houdini, this can be an op:/path/to/sop reference.

face_id

The primitive number of the Houdini polygon face.

face_u, face_v

The coordinates in the subdivision patch to map onto a Houdini primitive. These should have values in the range 0 to 1. Not all values are valid for triangles. The texture coordinates should be specified according to the attribute passed in. If you pass invalid coordinates, the function will fail and return 0.

&patch_id

The function overwrites this variable with the corresponding OSD patch number. This is also the same integer value used to identify the face when performing PTex texture mapping.

&patch_u, &patch_v

The function overwrites these variables with the corresponding U/V coordinates on the OSD patch.

Returns

1 on success or 0 on an error.

Examples

examples

// This function can be used to move points generated by a scatter SOP to the
// subdivision limit surface. The scatter SOP needs to store the "sourceprim"
// (the Output Attributes tab). Texture coordinates also need to be
// transferred from the source geometry.
void
movePointToLimitSurface(string file; vector P, uv; int sourceprim)
{
int patch_id = -1;
float patch_u, patch_v;
if (osd_lookuppatch(file, sourceprim, uv.x, uv.y,
patch_id, patch_u, patch_v, "uv"))
{
vector tmpP;
if (osd_limitsurface(file, "P", patch_id, patch_u, patch_v, tmpP))
P = tmpP;
}
}