Fixing some serious errors in the code that did not have any effect because of luck
Now just using one material and one sphere for both texture and atmosphere shading