Projecting curves or meshes directly onto other meshes results in faceted looking surfaces (left image). However, when projecting to the the limit surface using OpenSubDiv (OSD), we'll receive a smooth alignment to its Catmull-Clark subdivision surface (right image).
The main functions for accessing the limit surface are osd_lookuppatch()
and osd_limitsurface()
. To get started, we could either use the ray node, the intersect()-, xyzdist() or – like in this case –the uvdist()
-function, which all return the closest primitive number and the UV position on that particular polygon face.
Next we feed in a primitive number and the UV position on the primitive into osd_lookuppatch()
to receive a patch number and the U and V coordinates on the patch. Both, the patch number and the UVs, are then fed to the osd_limitsurface()
which returns the smooth world positions that are located right on the subdivision limit surface.
int prim_hit;
vector uvw;
uvdist(1, 'uv', v@uv, prim_hit, uvw);
int patch;
float patch_u;
float patch_v;
osd_lookuppatch(1, prim_hit, uvw[0], uvw[1], patch, patch_u, patch_v);
osd_limitsurface(1, 'P', patch, patch_u, patch_v, v@P);
In depth technical explanations and more production-ready examples on this subject are available by Yunus 'animatrix' Balciouglu on the SideFX website.