Noise Generators
A downloadable Package
Description
This package is a collection of classes that can be used to generate various types of noise textures. The generators are implemented in HLSL compute shaders allowing the textures to quickly be created (the speed varies based on the type of texture but is generally under 1ms). Full documentation of the included classes is available here and a more detailed description is included in the packages readme available on its GitHub page or in the root directory of the package. This package is free and open source however donations are greatly appreciated to support my continued development of both it and other open source tools for game development.
Features
This package currently supports the following types of noise textures
- Perlin Noise textures
- Worley Noise textures (aka Voroni or Cellular Noise)
- Value Noise texture
- Pure Random Noise textures
Furthermore the package also supports adding detail to any of the previous types of noise textures using fractal brownian motion, implemented as the Fractal Noise generator.
The package can also be extended to support custom types of noise generators given some familiarity with HLSL and compute shaders. The instructions for how to extend it are provided in the readme.
Using the Package
Using this package can be as simple as invoking a static method belonging to the generator class of the type of texture you would like to create. For example, if you wanted to create a pure random noise texture you would use the "RandomTextureGenerator.GenerateTexture(textureWidth,textureHeight,seed)" method, using your desired size and some number to seed the psuedo-random number generator as parameters (note that these are all unsigned integers). For other types of textures there may be more parameters to include, and some of them may be optional. For more details on what exactly each parameter does reference the full documentation for the type of texture you are generating. Note that there is some performance overhead with using the static method as it need to create a copy of the generated texture. Remember to release the resources of the noise texture when you are done using it though its "Release()" method.
Rather than use a static method, you can also instantiate an instance of a generator class yourself and modify its parameters directly (this is what the static method is doing behind the scenes). Once you have the parameters of the generator set, you can use the parameter-less GenerateTexture (of the object itself, not the static method of the class) to actually create the texture. Once you are done using the generator, remember to dispose of it. If you don't the garbage collector will have to dispose of it for you as part of its finalization. This can be an expensive process and you will be warned that it is occurring.
Lastly, you can also use a MonoBehaviour component to create noise textures if you would prefer to do so from the editor. The component will have editor fields you can modify to adjust the various parameters of the texture. The "Generate Texture" button on the editor will create the texture with the current settings for you to examine (you can view it by control clicking on the field for the noise texture in the inspector). You can also generate the texture from code using the "GenerateTexture()" method. When the component is disabled the inner generator object will be disposed along with its generated texture (you can also do this manually through the components "Dispose()" method, and it is recomended that you do so).
Installation Instructions
Through Itch.io
When installing this package through Itch.io you will need to update the package manually. There are two methods to download the package through Itch, you can either install it with the rest of your packages, leaving your asset folder less cluttered, but preventing modifications to the packages files; or you can install it as an asset, placing all of the scripts within your asset folder and allowing you to modify them. Modifications to this packages scripts are recommended only for user very confident in what they are doing.
Installing as a Package
Download this package's archive from this page. Once downloaded, extract the "NoiseGenerators" folder contained within to your desired installation location. Note that deleting this folder will break your package installation, even after adding the package to a Unity project.
After you have downloaded and unzipped the package, open the Unity project you wish to add this package too. Open the package manager window, and select the "+" icon in the upper left corner. Then, select the "Add package from disk" option. Navigate to your installation location and select the "package.json" file. Once you see this package show up in the Package Manager window, it has been successfully installed.
Installing as an Asset
Download the .unitypackage file from this page. Once downloaded, open the Unity project you wish to add this package to. Select "Assets" from the Unity Editor's toolbar, an from the "Import Package" menu select "Custom Package". In the window that pops up navigate to the .unitypackage file you downloaded and select it. The package will be added to your assets folder in the "/Packages/CommandPattern/" directory.
Updating the Package
If you installed the package through GitHub, you can automatically update it to its newest version by clicking the "update" button in the bottom right corner of its entry in the package manager window. If not, you will need to update it manually. In addition, there may be steps needed to migrate your code to the newer version of the package. If there are, these will be added to this section when the update has been released.
Manual Updating as a package
If you installed the package using the local package installation through the Unity package manager to update it you will need to download the archive for the updated version from the packages Itch.io page. Once you've done this, remove the old package in the package manager, delete the old installation and extract the inner folder from the new archive. If you plan to install the updated package with the same path, you may be able to skip removing the old package, but it is recommended you do so regardless. Once you have completed this, add the updated version of the package through the same installation progress you followed above.
Manual Updating as an Asset
If you installed the package as an asset using the .unitypackage file, simply download the updated .unitypackage file, delete you old installation in your assets folder, and follow the installation process above using the new .unitypackage file.
Installing the Package Demo
This package includes a demo showcasing the various types of noise textures that are implemented and allowing you to experiment with different parameters for those textures. Note that the texture display can sometime lag behind the generate texture. If you installed the package as an asset the demo will be included by default within the "Demos/NoiseDemo" directory. If installed as a package, this demo can be added by opening the "Samples" dropdown in its entry in the package manager and clicking the "import" button next to the "Noise Demo" entry. Once this demo has been imported, you can open it by navigating to the newly created "Samples/NoiseGenerators/[Current Version]/NoiseDemo" folder and opening the "NoiseDemoScene.Unity" scene.
Status | Released |
Category | Tool |
Author | sadsapphic |
Tags | Open Source, sourcecode, Unity |
Download
Click download now to get access to the following files:
Development log
- v1.0.2 updateDec 07, 2022
- v1.0.1 updateNov 05, 2022
Leave a comment
Log in with itch.io to leave a comment.