Face.position_material and uvh.get_front_UVQ
-
While working on the ThruPaint plugin, I encountered two issues with the API related to face texturing with FOUR UV specifications
1) face.position_material
When you pass a point set of 4 UV points, it seems that SU distorts the texture to match a perspective view, and does not really do a tapering of the texture image.
In the picture below, the UV specs for the 4 corners are (0, 0), (1, 0), (1, 1), (0, 1) for all three faces. This corresponds to a distorted texture which remains aligned with the 4 edges.
It works fine with a rectangular face (left) and with a sheared face (right)
When the face is tapered (middle case), it looks like SU is using a perspective distortion instead of tapering the texture along the edges. As a result, the texture patterns are not equally spread, here in the V axis. When you texture a full mesh, based on quads but with each face having its own shape, it results in non-alignment of pattens.
I did not find a way to change this behaviour with the method
position_material
and did not see any other API doing that.2) uvh.get_front_UVQ
When you specify 4 points to
position_material
(say at the corners of a quad) and then you get the UV of these corners byget_front_UVQ
, you get different values. The values which are different are usually 'strange'. This seems to corresponds to the perspective distortion that SU has applied.I found out that you can retrieve the original UV, by dividing the U and V values by the 3rd coordinate (i.e.
.z
) of the UV point returned (so I guess the 'Q' value). This Q value is 1.0 when the texture is not distorted.uvh = face.get_UVHelper(true, true, tw) uv = uvh.get_front_UVQ(pt) uv.x /= uv.z uv.y /= uv.z uv.z = 1.0
In conclusion, I am not sure there is any way to change the behavior of texture distortion of SU, but just in case someone has an idea, this would be really useful
Fredo
PS: I guess specialized UV mapping applications handle distortion properly.
-
Can't you add the final step
uv.z=1.0
to normalize things again... -
This is two issues I encountered myself. In addition, There is not way to find out if a texture is projected or not. Nor set the Projected property. Nor is it possible to detect if a texture is Positioned or not.
-
@tig said:
Can't you add the final step
uv.z=1.0
to normalize things again...You're perfectly right. Good remark.
I updated the post.Stangely, Position.material ignores the Q value when applying the texture (you can set it to whatever value you wish with no effect).
Fredo
-
Google claimed the Q value was not used - which in a way it isn't, when you apply a texture. But it sure is used when retrieving it. Really wish we could get some clarification to how the UV mapping system works.
-
I absolutely agree about the missing method to get/set the projected property.
Fredo,
as for the problem with tapered textures, I think this is a question of bilinear texture mapping versus projective (http://www.cs.cmu.edu/~ph/texfund/texfund.pdf p. 14 & p.17), but isn't projective mapping default in most other applications?
I can't think of any better solution than splitting the face into smaller quads.
Advertisement