Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improved 3D clouds shape some more + a few other things
- Loading branch information
Showing
8 changed files
with
74 additions
and
48 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import math | ||
import numpy as np | ||
import png | ||
|
||
resolution = 256 | ||
shift = 97 | ||
|
||
# generate values then shuffle them, instead of just generating random values | ||
# this ensures a flat histogram | ||
noise = np.zeros(resolution * resolution, 'uint8') | ||
for r in range(int(resolution * resolution / 256)): | ||
for v in range(256): | ||
noise[r * 256 + v] = v | ||
np.random.shuffle(noise) | ||
noise = np.reshape(noise, (resolution, resolution)) | ||
|
||
# TODO: turn into blue noise here? | ||
# possible algorithm idea for that: | ||
# a pixel exerts a "force" on similar nearby values to "push" them away | ||
# two nearby pixels are swapped if the net force put on them would decrease after the swap | ||
# idk how well this would work but i'm pretty sure it _should_ work, right? | ||
|
||
image = np.zeros((resolution, resolution, 3), 'uint8') | ||
for x in range(resolution): | ||
for y in range(resolution): | ||
image[x, y, 0] = noise[x, y] | ||
|
||
for x in range(resolution): | ||
for y in range(resolution): | ||
image[x, y, 1] = image[(x + shift) % resolution, (y + shift) % resolution, 0] | ||
|
||
image_reshaped = np.reshape(image, (resolution, resolution * 3)) | ||
|
||
writer = png.Writer(width=resolution, height=resolution) | ||
with open('./noise.png', 'wb') as file: | ||
writer.write(file, image_reshaped) |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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
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
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
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