Class NoiseUtils
A utility class for rendering noise defined by NoiseSettings into various Texture types.
Inheritance
Namespace: UnityEditor.Experimental.TerrainAPI
Syntax
public static class NoiseUtils
Fields
kNumBlitPasses
Number of passes that the builtin noise blit shader contains. The passes include one for blitting 2D noise and one for blitting 3D noise.
Declaration
public static readonly int kNumBlitPasses
Field Value
Type | Description |
---|---|
System.Int32 |
Methods
BakeToTexture2D(NoiseSettings, Int32, Int32, GraphicsFormat, TextureCreationFlags)
Bakes 2D noise defined by the given NoiseSettings instance into a Texture2D instance and returns a reference to it.
Declaration
public static Texture2D BakeToTexture2D(NoiseSettings noise, int width, int height, GraphicsFormat format = null, TextureCreationFlags flags = null)
Parameters
Type | Name | Description |
---|---|---|
NoiseSettings | noise | An instance of NoiseSettings defining the type of noise to bake |
System.Int32 | width | The width of the baked Texture2D |
System.Int32 | height | The height of the baked Texture2D |
GraphicsFormat | format | The GraphicsFormat for the baked Texture2D. In most cases, you will want to use GraphicsFormat.R16_UNorm |
TextureCreationFlags | flags | TextureCreation flags for the baked Texture2D |
Returns
Type | Description |
---|---|
Texture2D | A reference to the baked Texture2D instance |
BakeToTexture3D(NoiseSettings, Int32, Int32, Int32, GraphicsFormat, TextureCreationFlags)
Bakes 3D noise defined by the given NoiseSettings instance into a Texture3D instance and returns a reference to it.
Declaration
public static Texture3D BakeToTexture3D(NoiseSettings noise, int width, int height, int depth, GraphicsFormat format = null, TextureCreationFlags flags = null)
Parameters
Type | Name | Description |
---|---|---|
NoiseSettings | noise | An instance of NoiseSettings defining the type of noise to bake |
System.Int32 | width | The width of the baked Texture3D |
System.Int32 | height | The height of the baked Texture3D |
System.Int32 | depth | The depth of the baked Texture3D |
GraphicsFormat | format | The GraphicsFormat for the baked Texture3D. In most cases, you will want to use GraphicsFormat.R16_UNorm |
TextureCreationFlags | flags | TextureCreation flags for the baked Texture3D. |
Returns
Type | Description |
---|---|
Texture3D | A reference to the baked Texture3D instance |
Remarks
Be careful when specifying TextureCreation flags. If you specify that mipmaps should be generated for a Texture3D, that will use a lot more memory than if you were generating mipmaps for a Texture2D.
Blit2D(NoiseSettings, RenderTexture)
Blits 2D noise defined by the given NoiseSettings instance into the destination RenderTexture.
Declaration
public static void Blit2D(NoiseSettings noise, RenderTexture dest)
Parameters
Type | Name | Description |
---|---|---|
NoiseSettings | noise | An instance of NoiseSettings defining the type of noise to render |
RenderTexture | dest | The destination RenderTexture that the noise will be rendered into. |
Blit2D(NoiseSettings, RenderTexture, Material)
Blits 2D noise defined by the given NoiseSettings instance into the destination RenderTexture using the provided Material.
Declaration
public static void Blit2D(NoiseSettings noise, RenderTexture dest, Material mat)
Parameters
Type | Name | Description |
---|---|---|
NoiseSettings | noise | An instance of NoiseSettings defining the type of noise to render |
RenderTexture | dest | The destination RenderTexture that the noise will be rendered into. |
Material | mat | The Material to be used for rendering the noise |
Blit3D(NoiseSettings, RenderTexture)
Blits 3D noise defined by the given NoiseSettings instance into the destination RenderTexture.
Declaration
public static void Blit3D(NoiseSettings noise, RenderTexture dest)
Parameters
Type | Name | Description |
---|---|---|
NoiseSettings | noise | An instance of NoiseSettings defining the type of noise to render |
RenderTexture | dest | The destination RenderTexture that the noise will be rendered into. |
BlitPreview2D(RenderTexture, RenderTexture)
Blits the source RenderTexture into the destination RenderTexture using the default Preview Blit Material. This is the blit Material that is used when rendering the NoiseSettings Preview.
Declaration
public static void BlitPreview2D(RenderTexture source, RenderTexture destination)
Parameters
Type | Name | Description |
---|---|---|
RenderTexture | source | The source RenderTexture used in the Blit operation |
RenderTexture | destination | The destination RenderTexture in the Blit operation This will have the noise preview shader logic applied to it. |
BlitPreview2D(RenderTexture, RenderTexture, Material)
Blits the source RenderTexture into the destination RenderTexture using the specified Material.
Declaration
public static void BlitPreview2D(RenderTexture src, RenderTexture dest, Material mat)
Parameters
Type | Name | Description |
---|---|---|
RenderTexture | src | |
RenderTexture | dest | |
Material | mat | The material to be used in the blit operation |
GetDefaultBlitMaterial(Type)
Declaration
public static Material GetDefaultBlitMaterial(Type fractalType)
Parameters
Type | Name | Description |
---|---|---|
System.Type | fractalType |
Returns
Type | Description |
---|---|
Material |
GetDefaultBlitMaterial(NoiseSettings)
Returns a Material reference to the default blit material for the given NoiseSettings object.
Declaration
public static Material GetDefaultBlitMaterial(NoiseSettings noise)
Parameters
Type | Name | Description |
---|---|---|
NoiseSettings | noise |
Returns
Type | Description |
---|---|
Material | A reference to the default blit Material for the specified NoiseSettings instance |
Remarks
Internally, this uses noise.domainSettings.fractalTypeName to get it's FractalType