I have a project where I have a sphere with a png texture that represents a planet (or a moon in the videos I'm attaching).
Wrapped around that sphere I have a hexasphere (implemented using the results of my question from last year: How to orient a hexagonal tile on a geodesic sphere (Goldberg polyhedron)?).
Almost everything works just fine however I've noticed that in some situations, the hexasphere flickers at some points.
From my experiments, it seems that the problem is the lighting I am using.
The hierarchy of nodes I have is as follows:
bodyContainer OMNI planet OMNI (sphere, radius:0.987 with image texture as it's only (diffuse) material) hexasphere AMBIENT (hexasphere, radius: 1.0 as described in the linked question)
There are two light sources, both placed at the centre of the "sun" in my larger model. OMNI is an Omnidirectional light source with default settings. AMBIENT is an Ambient light source.
The reason that "body" uses OMNI is that I want the planet or moon to have a light and dark side which changes as the body orbits the sun.
The hexasphere that is co-located with the body by being a sibling of the body in the same container. It needs to use the AMBIENT light source so that it is equally visible on the dark side of the planet or moon.
What I'm noticing, it that when I move the camera further away from the planet, the parts of the hexasphere closest to the camera seem to flicker, and I seem to be able to see through to some of the hexasphere's cells on the opposite of the sphere.
Here are some videos to show what I'm seeing.
This first shows the scene in it's full 'glory' with all nodes in play as described above:
This next one shows the same hierarchy, however I've changed the planet body to use the AMBIENT light instead. Note that there is no flicker, but also, I've lost the dark/light side of the planet.
In this 3rd video, I've replaced the body texture with a simple translucent blue color, and reverted to using the OMNI light. It looks great, but the flickering is back.
Finally, I've changed back to the AMBIENT light again, but kept the blue body texture. Note that the flickering is gone again.
I'm quite positive that this is something I can fix, but I don't understand yet how. Is this simply a weakness in the lighting mechanisms in SceneKit?
Is there something special I should be doing to allow the outer hexasphere to render cleanly (i.e. without the flickering), with the ambient light, whilst having the inner sphere that is using an omni light?
I've found one solution that appears to work, however I'm not sure if this will result in a lower quality visual overall. If I set the material property
litPerPixel to NO, then the problem I've outlined goes away. I'm just not sure that the presumed "lower quality" rendering might cause other problems elsewhere.