2

I'm messing around with SceneKit. I feel like I'm doing everything as instructed, but the animation I end up with looks like a glitchy mess. The geometries have this odd kind of shattered quality to them. Shapes that should be behind over shapes are showing up in front. Etc.

Check out these screenshots. The pill shapes are all the same size and the smaller ones should always be behind the larger ones.

Any ideas? I'd post code, but it seems like this might be something that an experienced SceneKit-er might know just based on these screenshots.

Image #1 Image #2 Image #3 Image #4 Image #5

Josh Knowles
  • 395
  • 4
  • 19
  • this could come from precision errors in the depth buffer. Do you have extreme values for the `zNear` and `zFar` values of the camera? Or have you changed the `writesToDepthBuffer` or `readsFromDepthBuffer` properties of materials? – mnuages Apr 18 '17 at 07:48
  • @mnuages Maybe! These are my camera settings: camera.zNear = 0 camera.zFar = 10000 camera.xFov = 25 camera.yFov = 25 – Josh Knowles Apr 18 '17 at 15:39
  • @mnuages I have not changed the write/read depth buffer settings. – Josh Knowles Apr 18 '17 at 15:40
  • @mnuages Well, well! Setting zNear back to "1" (instead of "0") appears to fix the problem. Thanks! – Josh Knowles Apr 18 '17 at 15:43

1 Answers1

3

I had a bad zNear value.

camera.zNear = 0

According to Apple's documentation -- https://developer.apple.com/reference/scenekit/scncamera/1436592-znear -- this is bad.

This fixes the glitchiness:

camera.zNear = 1

Josh Knowles
  • 395
  • 4
  • 19