Created
August 24, 2020 14:04
-
-
Save charles-l/befc0b606efd9a135ffce1fbec6bbeb3 to your computer and use it in GitHub Desktop.
Render a noise pattern onto an image in Blender
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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