Skip to content

Instantly share code, notes, and snippets.

@charles-l
Created August 24, 2020 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save charles-l/befc0b606efd9a135ffce1fbec6bbeb3 to your computer and use it in GitHub Desktop.
Save charles-l/befc0b606efd9a135ffce1fbec6bbeb3 to your computer and use it in GitHub Desktop.
Render a noise pattern onto an image in Blender
import bpy
import numpy as np
from mathutils import noise
img = bpy.data.images['some-img']
w, h = img.size
# 4 channel image (RGBA), f64
a = np.array(img.pixels).reshape((h, w, 4))
for j in range(h):
for i in range(w):
v = noise.fractal([float(i)/w, float(j)/h, 0.5], 1.0, 2.0, 8)
a[j, i, :3] = v
a[:,:,3] = 1 # alpha
img.pixels = a.reshape((-1,))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment