FAR patch-parameterization : U,V [Level] -> S,T,PatchID ?

55 views
Skip to first unread message

Nicholas Yue

unread,
Nov 25, 2023, 9:52:41 PM11/25/23
to OpenSubdiv Forum
Hi,

  I am looking at the following

  https://graphics.pixar.com/opensubdiv/docs/far_overview.html#patch-parameterization

  (u_face,v_face) = (u_patch, v_patch) / pow(2,level)

  My reading of the above is face means coarse (i.e. the uv I read from e.g. OBJ file), patch mean associated with some PatchID

  and pondering if the following is possible

  For a given (u_face, v_face) and desired level, work out the (u_patch,v_patch) and PatchID ?

Cheers

David G Yu

unread,
Nov 28, 2023, 1:15:41 PM11/28/23
to OpenSubdiv Forum
Hi,

Start by taking a look at Far::PatchMap which does most of what you want, i.e. determines the refined patch corresponding to a coarse face (u, v) location.

Note that this constructed for and allows you to inspect a specific instance of a Far::PatchTable so it provides access only to patches that are present in the patch table, i.e. it doesn't provide a way to access refined patches at arbitrary levels of refinement.

Thanks!
-David

Nicholas Yue

unread,
Nov 28, 2023, 11:20:11 PM11/28/23
to OpenSubdiv Forum
Thank you David.

I have constructed the following


I can get a handle object which provides

handle->arrayIndex;
handle->patchIndex;
handle->vertIndex;

How should I proceed to get the patchid and s,t value given the indices from the handle ?

Cheers

Nicholas Yue

unread,
Nov 29, 2023, 12:23:40 PM11/29/23
to OpenSubdiv Forum
I think for the next step (get the refined vertices's UV), I can refer to far_tutorial_2_2.cpp for more insight.

With that, I can do some interpolation to get the patch's local (s,t)

Am I on the right track ?

Cheers

Nicholas Yue

unread,
Nov 30, 2023, 6:25:12 PM11/30/23
to OpenSubdiv Forum
Using the handle, I can retrieve the indices of the patch face

            auto vertices = pt->GetPatchVertices(*handle);

When I use those vertex indices directly, I can mangled UVs

I believe those indices need to be offset/transform to get to the right starting point, is that correct ?

Cheers

Nicholas Yue

unread,
Nov 30, 2023, 7:52:04 PM11/30/23
to OpenSubdiv Forum
I have made small progress

```
OpenSubdiv::Far::ConstIndexArray fuvs = refLastLevel.GetFaceFVarValues(handle->vertIndex, channelUV);

for (int vertex : vertices)
{
// I have vertices index via *iter but where can I use this index to look for the
// vertices ?

FVarVertexUV const& uv = fvVertsUV[fuvs[vertex]];
std::cout << boost::format("fuvs[vertex=%1%]=%2% {%3%,%4%}\n") % vertex % fuvs[vertex] % uv.u % uv.v;
face_uvs.push_back(IBI::VEC(uv.u, uv.v));
}
```

However, I am getting duplicate indices which resulted in generated patch

Some how, I have  two indices with 90
```
maxlevel 3
arrayIndex 0
patchIndex 8
vertIndex 32
fuvs[vertex=18]=85 {0.241177,0.704977}
fuvs[vertex=103]=90 {0.361765,0.257065}
fuvs[vertex=56]=87 {0.702099,0.518803}
fuvs[vertex=104]=90 {0.361765,0.257065}
testPoint (0.5 0.5)
```

David G Yu

unread,
Dec 6, 2023, 6:54:09 PM12/6/23
to OpenSubdiv Forum
I think far/tutorial_5_1/far_tutorial_5_1.cpp is a better example for your consideration.

That tutorial shows how to use Far::PatchTable along with Far::PatchMap to evaluate arbitrary locations within a face.

Note that the tutorial evaluates position, to instead evaluate face varying UVs you will want to use the corresponding *FaceVarying methods, e.g. PrimvarRefiner::InterpolateFaceVarying, PatchTable::GetLocalPointFaceVaryingStencilTable, PatchTable::EvaluateBasisFaceVarying, PatchTable::GetPatchFVarValues().

That doesn't directly answer your question about duplicate values, but maybe indicates a different way forward. It's hard to say more about the specific indices you are getting without knowing more about the input topology and face varying topology.

Thanks!
-David

Reply all
Reply to author
Forward
0 new messages