How to get consistent UV coordinates for faces, with or without material applied?

Hi, we’re having issues using UV coordinates extracted from some SketchUp models in our renderer.

After some tests, I noticed that the issue occurs when we deal with faces that do not have textured materials applied directly on them, but on their parent group/component (so the faces inherit the material).

We use SUUVHelperGetFrontUVQ to retrieve the texture coordinates.

For a simple face with a material directly applied to it, we get for instance:

{u=0.15841117727088630 v=2.7062410102159320 q=1.0000000000000000 }
{u=0.15841117727088630 v=0.061517649560194336 q=1.0000000000000000 }
{u=0.89278617727088627 v=0.061517649560194336 q=1.0000000000000000 }
{u=0.89278617727088627 v=2.7062410102159320 q=1.0000000000000000 }

The values are in the expected range and they match the tiling in the SketchUp model. All good :+1:

For another face with a material applied, this time, to the parent group, we get:

{u=0.0000000000000000 v=0.0000000000000000 q=1.0000000000000000 }
{u=115.68750000000000 v=0.0000000000000000 q=1.0000000000000000 }
{u=115.68750000000000 v=198.31250000000000 q=1.0000000000000000 }
{u=0.0000000000000000 v=198.31250000000000 q=1.0000000000000000 }

The range of those values do not look like usual texture coordinates (more like world-space coords?) and they have a different scale than the previous case. That’s the part where I get confused :upside_down_face:

Here’s that particular model in SketchUp

  • Top face: material applied to the group
  • Bottom face: material applied directly to the face

Here’s the result in our renderer:
(The top face looks untextured buth if we zoom in, we can see that the texture is tiled hundreds of times, which makes sense due to the large UV coordinates that we get back from the SDK).

So here’s my question: why are those coordinates so different in those two cases? And most importantly, how to get consistent texture coordinates?

(pinging @thomthom since you often appear in threads about texturing, hope that’s okay!)


Some more insights after more testing:

  • The same inconsistency occurs with the Ruby API.
  • The same inconsistency occurs if we use SUMeshHelperGetFrontSTQCoords instead of SUUVHelperGetFrontUVQ.

Yes, we have also run into similar UV troubles.

Could this Sketchup API Github issue be related? Here: