Community
Bifrost Forum
Welcome to the Bifrost Forum. This is the place for artists using Bifrost to ask and answer questions, browse popular topics, and share knowledge about creating effects procedurally using Bifrost. You can also visit the Bifrost Community on AREA to download an array of ready-to-use graphs, read Bifrost news and updates, and find the latest tutorials.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

'Deform' a mesh to it's UV coordinates.

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
mitch.s
735 Views, 8 Replies

'Deform' a mesh to it's UV coordinates.

Hi everyone

How can I 'deform' a mesh to it's uv coordinates. I say deform because the topological properties of the result mesh must be the same as the input mesh. (vertex order/count,... etc)

This seems very similar to MJ's (mjcj91) 'create_mesh_from_uv' compound but it isn't quite the same.
Although it's major great stuff, MJ's compound creates a new mesh with different topology properties.
This is NOT what I need in my case.

What I need is much more simple (I think...)
I just need to extract the first UV value for each vertex. (u,v)
(The 'first' because a vertex may have more than 1 uv of course)
Value which I will then use to simply set the x,z coods of the vertex. (u,v) -> (x,y,0)

It would also be nice to be able to plug in the desired uv-set...

My request may seem useless on itself, but I need it as a part of a workflow (that I omitted for clarity)

Thanks in advance

8 REPLIES 8
Message 2 of 9
mitch.s
in reply to: mitch.s

 

I think that the answer may lay somewhere inside the 'get_mesh_UVs' compound.
'get_mesh_UVs' returns all uv's (incl. multiple uv's per vertex) as it should of course.

But what is needed is some kind of custom 'get_mesh_FIRST_UVs' so that the number of uv's returned equals the number of vetrices on the mesh.

I believe that the desired result can be achieved by tweaking something inside
get_mesh_UVs / get_indexed_geo_property_as_float2 / ...
Untitled.jpg

That is basically where the uv-array is built from the meshes' uv property.

This looks quite advanced for a mere mortal / bifrost-noob that I am...
Does someone knows how to pick only the FIRST pair of uv coordinates from a vertex?

Many thanks

Message 3 of 9
bugsdabunny
in reply to: mitch.s

There is a compound called first_in_array or you use get_from_array and choose the first index, ie the 0th index

Message 4 of 9
Christoph_Schaedl
in reply to: mitch.s

I havnt tried it but i assume Daniels deformer is doing what you want. 

https://github.com/dtlindsey/bifrost-dl-core/tree/main/Compounds/deformers

 

----------------------------------------------------------------
https://linktr.ee/cg_oglu
Message 5 of 9
mitch.s
in reply to: Christoph_Schaedl

Thanks guys for those quick answers.

FYI:
From the dl_to_uvs docs
Capture.JPG
So I would presume that this is not what I need.

Message 6 of 9
Christoph_Schaedl
in reply to: mitch.s

If your mesh isnt cutted like the uv borders its impossible to not change the vert count. 

----------------------------------------------------------------
https://linktr.ee/cg_oglu
Message 7 of 9
mitch.s
in reply to: mitch.s

I did a test just to be sure:

dl_to_uvs seems to use every facevertex to build its mesh
Capture.JPG

In and Output topology are not the same. (= are not blendable via blendshape)


I'm starting to wonder whether it is possible...
There seems to be no way to differentiate/filter/choose in a granular way how point components and face_vertex_uv components relate to each other.

This very simple concept of 'move every vertex to it's (first) uv position in 3d space' seems to have a very advanced solution in Bifrost Graph. (or none)

The key must lie somewhere inside the 'get_mesh_UVs' compound. But my knowledge of Bifrost Graph doesn't reach far enough to alter it and make a 'get_mesh_per_point_UVs' compound...

Message 8 of 9
mitch.s
in reply to: mitch.s

Hi all

 

To illustrate, I made a very naive implementation of this in python.

 

import maya.cmds as cmds

sels = cmds.ls(sl=1)
mesh = sels[0]
for vtx_id in range(cmds.polyEvaluate(mesh, v=1)):
    cur_vtx = '{}.vtx[{}]'.format(mesh, vtx_id)
    cmds.select(cur_vtx)
    cmds.ConvertSelectionToUVs(fv=1, tuv=1) # Get UVs from VTX
    uvs = cmds.ls(sl=1)    
    if not uvs:
        continue                
    uv_1st = uvs[0] # Keep only the 1st UV

    uv_coordinates = cmds.polyEditUV(uv_1st, query=True )    # get UV coods
    cmds.xform(cur_vtx, t=[uv_coordinates[0], uv_coordinates[1], 0], ws=1) # set uv coods

 

As you can see, it's very easy and straightforward.
It works exactly as intended. Topology (vertex-order, count, ...) stays the same so the result mesh is 'blendable' via standard Blendshape deformer.
Capture.JPG

May be a 'MayaScript to BifrostGraph Challenge' ...

Message 9 of 9
mitch.s
in reply to: mitch.s

Ok, So I found a solution.
Thought I might share it with you.

The original idea was to only use the already available uv data in order to avoid more processor-intensive stuff.
I couldn't find a way to get uv's per specific vertex in the current way that mesh data is structured in bifrost (please correct me if I'm wrong)

So in the end, I resorted to using the more calculus intensive Geolocations anyway.
This works as intended.
The output contains the uv_mesh (MJ's way), as well as the uv_deformed_mesh that is calculated via closest-location.

Capture.JPG

Capture.JPG

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums