Notifications
Clear all

[Closed] Parametric UV-Mapping

Hi!

I want to write a script that unwraps the UVs of a polygon selection similar to the parametric UVs of NURBS objects.

The idea of the script is shown in the attached images. In the second image you can see the polygon selection of the object that should be unwrapped.

When the script starts, the user selects four corner vertices of the map, which should have these uv coordinates: 0,0 – 1,0 – 0,1 – 1,1 (shown in the first image).

Then the script interpolates the UVs of all other vertices to apply a mapping as shown in the third image. Appearently the map is distorted due to the triangulation of the polygons.

How can I avoid the distortion of the maps without using NURBS surfaces?

Is there an easy way to identify all border-edges of a polygon selection?

Thanks,
Christian

25 Replies

This distorsion is only visual (if yours uvs are correct of course).
That is just a problem of display…
The only means to avoid it is to increase the number of segments.
That is the reason for which it works very well in NURBS: there are more segments and the structure is very regular what avoids the distortions.

Yes. Here is the code:

fn getOutlineEdges obj theFaces = (
	local faceEdges = polyOp.getEdgesUsingFace obj theFaces
	local outlineEdges = #{}
	for e in faceEdges where (((polyOp.getFacesUsingEdge obj e)*theFaces).numberSet == 1) do outlineEdges[e]=true
	outlineEdges
	)

(
local obj=selection[1]
if classof obj==Editable_Poly do (
	local theFaces = polyOp.getFaceSelection obj
	local theOutlineEdges = getOutlineEdges obj theFaces
	polyOp.setEdgeSelection obj theOutlineEdges
	subObjectLevel=2
	)
)

This example is for Editable_Poly only.
It is a bit more complex for a mesh because the structure is different and the function getFacesUsingEdge don’t return the expected result.

I am interested by your project.

Indeed I wrote a script which acts in a similar way :
http://users.skynet.be/arketip/arketip_morphMapENG.htm
But my script was conceived to work with flat surfaces only.
It will give you can be some ideas…

How would you make to attribute mapping coordinates to a volume?

If you can create a script that works on a volume that would be terrific

Hi Arketip,

your script is GREAT!! I tried to map the model of the arc in my first posting and it worked. Then I tried to map the road on the terrain model in the attached image. I had to map it in three steps and there are almost no distortions in the texture!

But I want to understand how it works Can you tell me what is the reason why I have to map the road in different steps?

Thanks!
Christian

Hi, Happy to see that you like my script.

The reason is pretty simple: lets say you have a road with a form ’ J ’
The length of the left border and the right border of the road is not the same… And my script uses this distance to balance the UVs. The length is balanced along the whole road.
In this case the deformation would be only in turns.
In this case, the deformation has to appear only in the bends and never in the straight lines.
This is the reason.

You speak about interpolation in your project…
Do you believe that it is possible to improve my script to put on it on volumes?
Have you another method or this is just an hypothesis?

Your script looks really professional! But I don’t understand how you detect the corner vertices.

My idea is to first let the user select the four corner vertices. Then the script interpolates all the vertices along the border edges using the distance to the next both corner vertices.

The two attached images shows how I would map the J-shaped road.

I can’t really imagine what you mean with applying this method to volumes. I think you have to add the ability to break some of the edges apart. I think the best method to do this would be Peltmapping…

1 Reply
(@arketip)
Joined: 11 months ago

Posts: 0

Magic
Seriously this part of the script is the most difficult to write. It is a combination of various calculations. It was necessary to make tests to find the good balance.
The automatic corners detection is really indispensable to make this kind of script pleasant to use.

These pictures explain clearly your method
It is exactly as it that works my script.

You see that the red line is shorter than the opposite (and especially the bend part) That’s why it is necessary to run the script in 2 steps.

The problem of the volume occurs when one vertex is between the 2 opposite edges : What happens if this internal point is not situated inside the plan formed by 2 opposite edges?
How to calculate the uv coordinate?
That is the question…

Yes, this is indeed very useful… I will get deeper into this topic to understand how your script works

In the first step I would interpolate all the UVs of the vertices along the border edges (with u or v = 0). Then, in the second step, the inner vertices are left and can be interpolated from the outer vertices.

You have to do some kind of unwrapping to the object. This means you have to virtually transfer the volume object to a planar surface. Then you can detect the edge vertices and apply the mapping. But I guess this cannot be computed without heavy distortions…

What kind of geometry you are thinking of?

1 Reply
(@arketip)
Joined: 11 months ago

Posts: 0

Here is an picture which shows how my script works at present:

this kind of geometry :

As you see, the surface of the grid is interpolated with the flat edges.
In this case the script have the same effect than an planar mapping…

In my oppinion, there is no solution for this kind of geometry. I have no idea how to unwrap the object in your picture without distortions or without seams. That means you will have eighter distortions in your texture or seams in your mapping…

You can try to create the desired mapping manually but I cannot imagine how it should look. Maybe you could post a picture of how your final map should appear on your object?

Here is how my final map should appear on the object :

(the object was simplified)
At the left, I show to you the final object. And at the Right, a simple planar projection.

and the unwrap associed:

The script has to recognize the 3d shape of the object in order to unwrap it in this way. To apply a U or V coordinate to a vertice, the script has to consider the path from one border edge to the opposite border.

In the attached image, you need to calculate the total length of the “a” and “b” lines in 3d space, then apply the u and v coordinates proportionally to the vertices on the red lines. I think the result would be the same as your manually unwrapped map.

How does your script handle 3d objects? It works with non-planar shapes yet as shown on your website (first image). So it seems to be quite easy to implement the ability to handle irregular 3d objects…

You are probably right but I shall need a little of time to imagine the routine which allows me to make that.

The example which I gave here was very simple. The edges of the object are flat. It is easy to define a slice plane through this object. But if the edges don’t have a flat shape then that would be more complicated…

Thanks for the idea

Page 1 / 3