#init_spline {
  "grid",
  #declare a=0;
  #while (a<dimension_size(grid_scale,1))
    <grid_scale[a].y,grid_scale[a].x>
    #declare a=a+1;
  #end
  }       

#macro universe_texture(bgcolor)

  #declare grid_size=eval_spline("grid",clock);  
  #render concat ("Grid Size is ",str(grid_size,1,3),"\n")
  #declare size1=5^(int(grid_size));
  #declare size2=5^(int(grid_size+1));
  #declare grid=mod(grid_size,1);
  #declare col1=1-min(1,(1-grid)*2);
  #declare col2=1-min(1,grid*2);
  
  texture {
    pigment {
      color rgb bgcolor
      }
      finish {
      ambient 0
      diffuse 1
      brilliance 2
      //specular 0.5 roughness 0.05
      }
    }
  texture {
    pigment {
      function { z/size1 }
      color_map {
        [0.00 rgbt <1,1,1,col1> ]
        [0.01 rgbt <1,1,1,col1> ]
        [0.02 rgbt <1,1,1,1.0> ]
        [0.98 rgbt <1,1,1,1.0> ]
        [0.99 rgbt <1,1,1,col1> ]
        [1.00 rgbt <1,1,1,col1> ]
        }
      }
          finish {
      ambient 0.3
      diffuse 0.8
     
      }
    }
  texture { 
    pigment {
      function { x/size1 }
     color_map {
        [0.00 rgbt <1,1,1,col1> ]
        [0.01 rgbt <1,1,1,col1> ]
        [0.02 rgbt <1,1,1,1.0> ]
        [0.98 rgbt <1,1,1,1.0> ]
        [0.99 rgbt <1,1,1,col1> ]
        [1.00 rgbt <1,1,1,col1> ]
        }
      }
          finish {
      ambient 0.3
      diffuse 0.8
    
      }      
    }
  texture {
    pigment {
      function { z/size2 }
      color_map {
        [0.00 rgbt <1,1,1,col2> ]
        [0.01 rgbt <1,1,1,col2> ]
        [0.02 rgbt <1,1,1,1.0> ]
        [0.98 rgbt <1,1,1,1.0> ]
        [0.99 rgbt <1,1,1,col2> ]
        [1.00 rgbt <1,1,1,col2> ]
        }
      }
    finish {
      ambient 0.3
      diffuse 0.8
     
      }
    }
  texture {          
  
    pigment {
      function { x/size2 }
      color_map {
        [0.00 rgbt <1,1,1,col2> ]
        [0.01 rgbt <1,1,1,col2> ]
        [0.02 rgbt <1,1,1,1.0> ]
        [0.98 rgbt <1,1,1,1.0> ]
        [0.99 rgbt <1,1,1,col2> ]
        [1.00 rgbt <1,1,1,col2> ]
        }
      }          
    finish {
      ambient 0.3
      diffuse 0.8

      }
    }
     
#end

  