SUPoint2D uv_coords[4] only support 4 uv coords?

Hi Experts,

In the Sketchup document about SUMaterialInput Struct Reference, it mentions that the conventional method for applying a material to a face is to use 1 to 4 UV coordinates.

My question is what if the face has more than 4 vertices? For example, a face have 6 vertices, and each vertex has a related uv vertex coordinate. How to set 6 vertices UV coordinates to the structure struct SUPoint2D uv_coords[4]; ///< Texture coordinates.


not a solution, but an observation…

a texture’s bounds and a face’s bounds are both rectilinear and only have 4 corners…


For the model below, the top face and the bottom face have 6 vertices.

when converting the obj file to skp file, also the face in obj file has 6 vertices and each vertex has uv coordinate, how to consume 6 uv coordinates to skp 4 uv coordinates?
Currently I discard the fifth and sixth uv coordinates to handle such kind of case. It seems the texture is good. I am not sure if it is correct solution.

@tt_su Could you please take a look at the issue?

SketchUp doesn’t store UV coordinates per vertex. Instead there is a UV mapping transformation matrix per face. These are controlled by the UI via four pins:


The APIs map using the same manner.

When you UV map via the API it’s up to four points. You can use less, depending on what you are intending to do.

Number of points in UV mapping will give you:

  1. A position where the UV mapping origin is. Direction is taken from the model axis and size is taken from the texture size.
  2. Two points will control origin and uniform scale.
  3. Three points will control origin and non-uniform scale and skew.
  4. Four points let you map a texture such that the texture plane isn’t planar to the face’s plane.

There is a design quirk with the C API what IMO makes it a bit more challenging to work with textures than the Ruby API.

The Ruby API doesn’t force you to provide 3d world points that match the vertices of the face - they just need to be on the plane of the face.

The C API for some reason (this function was added before my time) expects the input points to be anchored to the vertices of the face. This forces some extra calculations to be made in some cases to position the texture exactly where you want.

If you are writing an importer from another format what provide UV coordinates you can use just the first four and discard the rest. SketchUp computes the transformation matrix based on those four points. The catch is that you could have cases where the first four vertices of a face might be co-linear. So to be robust you want to pick a set of points that doesn’t form a degenerate triangle or quadrilateral.


I logged an issue for C API improvement - allowing input that aren’t bound to the vertices when UV mapping.

@tt_su Thanks for detailed information.