SpriteKit Procedurally Generated Noise

Jason Sturges
2 min readDec 26, 2020

Procedurally generated noise is built into SpriteKit using SKTexture initializer noise functions:

  • noiseWithSmoothnessCreates a new texture whose contents are procedurally generated colored noise data
  • vectorNoiseWithSmoothnessCreates a new texture whose contents are procedurally generated directional noise data

To see it in action, checkout SpriteKitNoise Xcode project from my Swift Prototypes repository at GitHub.

Noise With Smoothness

Noise with smoothness may be color or grayscale, taking three parameters:

  • smoothness — How similar neighboring texels will appear in the texture
  • size — Bounds of the texture in points
  • grayscale — If true, all components of the texel with be randomized equally

To apply the texture to the sprite, create a SKTexture instance and initialize a SKSpriteNode with the texture.

Lower smoothness values will result in a finer grain, with higher smoothness values approaching a solid smooth surface.

Above shows adjusting smoothness of procedurally generated color and grayscale noise.

Vector Noise With Smoothness

Vector noise with smoothness is similar, but does not provide a grayscale ability. It’s tileable with itself, and RGB values can be used as directional x, y, z data.

  • smoothness — How similar neighboring texels will appear in the texture
  • size — Bounds of the texture in points

Same as before, to apply the texture to the sprite, create a SKTexture instance and initialize a SKSpriteNode with the texture.

Above shows adjusting smoothness of procedurally generated vector noise.

--

--

Jason Sturges

Avant-garde experimental artist — creative professional leveraging technology for immersive experiences