At first glance the question seems trivial: Can two SCNNodes, which use geometries with materials using different textures, share the same shader?
One would think that the answer would be an obvious yes, but I'm not sure how this is accomplished.
In order to have two SCNNode objects that have a SCNGeometry object each, with different textures, one needs to create an SCNMaterial object to define these two textures, and give them to the SCNGeometry objects.
Two different SCNMaterial objects, two separate shaders (even if their source code is identical). I see no way of making them share the same shader.
One would think that creating a single SCNProgram object and assigning it to both materials would do the trick, but besides this being an exceedingly complicated solution (because AFAIK SCNProgram does not offer anything readymade, and you need to implement every single detail manually; all attributes, all uniforms... everything must be done by the programmer), there's a blog post that claims that the shader doesn't actually get shared, and instead each material will take its own copy of the shader, thus effectively having multiple shaders rather than one.
As for the easier solution, using shader modifier snippets on the material, unless SceneKit performs some really smart optimizations (which isn't, of course, documented at all), every single material will get its own shader instance.
This means that if you use 100 different textures in your game (even if they are part of one single texture atlas), each applied to its own SCNGeometry object, you will have 100 distinct shaders, one for each texture, even if every single one of those shaders is completely identical to each other.
Please correct me if I'm wrong. I can't believe that eg. SpriteKit is doing this. I can't believe that if you have a thousand different sprites (with different textures), then you have a thousand instances of the same shader, one for each sprite. This would be horrendously inefficient.
If it's not like this, then how does this work? How can I create different SCNMaterials with different textures, assigned to different SCNGeometry objects, and have them all share the one and same shader (preferably using shader modifier snippets)?