foobarbecue
foobarbecue

Reputation: 7060

Strange lines ("seams") appearing when applying texture to threejs model

I am rendering a model imported from a .ctm file into threejs v71. I'm then adding a texture using a MeshBasicMaterial with map.

The original model was made in Agisoft Photoscan, exported as .obj, and then converted to OpenCTM format using the official OpenCTM viewer program. The .ctm model itself is here.

It looks correct, except that strange "seams" appear on the texture when I load the .ctm . The .obj loads fine in three.js with no seams. What are these, and how do I get rid of them?

Here's a screenshot:

enter image description here

These "seams" are not present in the texture file:

enter image description here

UPDATE: I noticed that the seams are also visible when viewing the .ctm in the ctm viewer, so this is probably an OpenCtm conversion problem rather than a threejs loading issue.

Upvotes: 4

Views: 2170

Answers (3)

foobarbecue
foobarbecue

Reputation: 7060

To my chagrin it seems this is a longstanding bug in OpenCTM.

The other answers must not be reproducing the situation described in the question.

Edit: I now fully understand this problem and have a workaround for it. The issue is that most programs (Photoscan, Blender) have "per-loop" vertices instead of actual "per-vertex" textures. This just means that when a vertex is shared by two polygons, there can be multiple UV coordinates for that vertex. CTM can only have one UV coordinate per vertex and that's what causes the problem at texture seams.

My workaround in blender is:

  • Seams from Islands
  • Select an edge on seam, select similar --> seam. Now all seams should be selected
  • Mesh --> Edges --> Edge Split
  • Export to .obj, use ctmviewer.exe to import and export to .ctm.

The seams are still visible if you look closely but no longer obvious multicolored bands.

Upvotes: 2

dead_PyKto
dead_PyKto

Reputation: 88

Or you can just remove the alpha-channel from the texture image file (or use JPG format during export).

Upvotes: 0

Albin Nilsen
Albin Nilsen

Reputation: 1

I had the same issue with my Agisoft Photoscan model/texture, so I opened the texture in Photoshop and noticed it had transparency between all the patches of texture. I filled all the gaps using content aware fill and saved the texture out as a .tif without layers. This solved the issue for me.

Upvotes: 0

Related Questions