8

I'm getting intermittent appearances of seams in the textures that I apply to spheres in SceneKit. It's always at the "back" of the sphere, where the two edges of the texture meet. It looks as though the texture doesn't quite connect with itself, and you can see the background through the thin line. The problem seems to exist on all devices and across all recent iOS versions. My experiments have indicated that the resolution of the texture seems to be a factor, but I haven't nailed down exactly what that impact is.

I've attached a screenshot to illustrate, on a white background for clarity, but the seam isn't inherently white it just allows the background to show through:

Planet Seam

Does anyone know why SceneKit would be rendering the textures this way? I've got a fairly simple implementation, just creating a sphere and a material and applying a diffuse and normal map to it. Here's my code:

// create planet
SCNNode *baseNode = [SCNNode node];
[baseNode setName:name];

// Planet
SCNSphere *planet = [SCNSphere sphereWithRadius:5];
SCNNode *planetNode = [SCNNode nodeWithGeometry:planet];
[planetNode setName:@"planetNode"];
[baseNode addChildNode:planetNode];

SCNMaterial *material = [SCNMaterial material];
material.shininess = 1;
material.normal.intensity = 0.5;
material.normal.contents = normalMap;
material.diffuse.contents = diffuseMap;

planetNode.geometry.materials = @[material];

Does anyone have any experience with what might cause this "seam" to appear, and how I might get rid of it? My textures are generally either 1000x500 or 2048x1024, depending on the situation, and the seam has appeared at both resolutions. Is there an ideal resolution for SceneKit textures, or something well-known that could cause this behavior?

Nerrolken
  • 1,975
  • 3
  • 24
  • 53
  • 1
    I had a quick look at this, and couldn't reproduce what you're seeing. I grabbed some moon textures from [here](http://coryg89.github.io/technical/2013/06/01/photorealistic-3d-moon-demo-in-webgl-and-javascript/), even resampled them to 1000x500, but to no avail (as in they worked fine). Could it be that your texture has a row/column of transparent pixels? – lock Mar 18 '17 at 03:50
  • @lock No, but I'm dynamically resizing the textures in code (lowering the size/quality on older and slower devices to reduce memory strain) so I guess maybe it's showing up there. I'll hunt down that avenue and see what I can find, thanks. – Nerrolken Mar 18 '17 at 04:13
  • i could not reproduce this either. could you somehow upload your test project? – Hashmat Khalil Mar 22 '17 at 07:23
  • 1
    i got this problem to and found out that when my material had size of 2513.274170 by 200.000000 float then i could see similiar seam. When i rounded it to 2500by200 seam disappeared. – Damian Martyniuk Jan 03 '20 at 01:24

1 Answers1

1

The answer ended up being frustratingly simple: I was rescaling the textures for quality reasons, and this line was the result of a fractional resolution, like 1025.25f * 2048.5f.

Rounding the values to int before scaling the texture fixed the problem.

Nerrolken
  • 1,975
  • 3
  • 24
  • 53