Skip to content
A static utility class for Unity which handles generating and loading periodic, cloud-like (perlin-worley) 3D noise textures on the GPU.
C# HLSL ShaderLab
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Assets/CloudNoiseGen Updated source file headers with license information. Also removed th… Feb 17, 2019
.gitignore Initial commit Feb 12, 2019
LICENSE Initial commit Feb 12, 2019
README.md Update README.md Feb 13, 2019

README.md

CloudNoiseGen

Perlin-Worley noise

A static utility class for Unity which handles generating and loading periodic, cloud-like (perlin-worley) 3D noise textures for use with volumetric shaders. The noise is generated on the GPU, and so it is very fast.

Usage

Use the perlin and worley variables to set the amount of octaves, periods, brightness and contrast of the Perlin and Worley noise respectively.
Use the InitializeNoise function to load/generate noise.
The generated noise is stored in Assets/Resources/CloudNoiseGen/folderName as 2D textures (one for each z-slice).
If the folder already exists and contains noise with the same resolution, it will be loaded instead of generated (unless you set the mode parameter to ForceGenerate). If the folder already exists but the resolution does not match, it will be discarded and new noise will be generated.
When generating noise, the asset database is refreshed upon completion. This takes a few seconds. When generating noise for the first time, texture import settings need to be set. This takes a bit longer but only needs to be done once. The actual noise generation is near-instant depending on your GPU.

If you wish to display a preview of the noise before generating the textures, use the GetSlice function.
If you don't want to use the automatic handling of loading/generating the noise textures, you can use the LoadNoise and GenerateNoise functions instead of InitializeNoise.

Limitations

Generating new noise is limited to the editor.
Generated noise must be stored in the resources folder (so it can be loaded from script in built player).
If the folder containing the noise textures contains any other files, it will not be loaded (additionally, the generator will discard the entire folder and create a new one).
If you want to modify the way the perlin/worley noise is blended together, you need to modify the CloudNoiseGen shader.
Changing the texture import settings of the generated z slices is recommended against.

Credits

Perlin Noise
Noise Shader Library for Unity - https://github.com/keijiro/NoiseShader
Original work (webgl-noise) Copyright (C) 2011 Stefan Gustavson
Translation and modification was made by Keijiro Takahashi

Worley Noise
Worley noise implementation for WebGL shaders - https://github.com/Erkaman/glsl-worley
Original work (GLSL-cellular-noise) Copyright (C) 2011 Stefan Gustavson
Translation and modification was made by Eric Arnebäck
Periodic modification was made by Felix Westin

All source code is distributed under the MIT license (See CloudNoiseLib.cginc for full details).

You can’t perform that action at this time.