"""Add non-repeating mineral/weathering patches to the authored granite atlas.""" import bpy,numpy as np im=bpy.data.images['Summit unique weathered granite'];w,h=im.size p=np.asarray(im.pixels[:],dtype=np.float32).reshape(h,w,4) rng=np.random.default_rng(141) def cloud(n): grid=rng.uniform(-1,1,(n,n));xs=np.linspace(0,n-1,w);ys=np.linspace(0,n-1,h) rows=np.array([np.interp(xs,np.arange(n),row) for row in grid]) return np.array([np.interp(ys,np.arange(n),rows[:,i]) for i in range(w)]).T patch=cloud(12)*.065+cloud(48)*.045+cloud(170)*.025 p[:,:,:3]=np.clip(p[:,:,:3]+patch[:,:,None],0,1) im.pixels.foreach_set(p.ravel());im.update();im.save() bpy.ops.wm.save_as_mainfile(filepath=bpy.data.filepath) print('Saved non-repeating mineral patches and weathering atlas',w,h)