Run-time API
Texture Adjustments run-time API can be brought into scope with this using directive:
using AmazingAssets.TextureAdjustments;
Now Texture Adjustments classes and their Render methods become available.
//Example of rendering Hue, saturateion & Lightness adjustment
using UnityEngine;
using AmazingAssets.TextureAdjustments;
public class ExampleScript : MonoBehaviour
{
public TextureAdjustments_HueSaturationLightness hsl = new TextureAdjustments_HueSaturationLightness();
Texture2D RenderAdjustments(Texture2D sourceTexture)
{
//Texture Adjustments renders into RenderTexture
RenderTexture renderTexture = null;
//Render HSL
hsl.Render(sourceTexture, ref renderTexture, false, false);
//Convert RenderTexture to Texture2D
Texture2D final2D = renderTexture.ToTexture2D();
//Release RenderTexture
renderTexture.Release();
//Release resources used by adjustment
hsl.ReleaseResources();
return final2D;
}
}
//Example of rendering multiple adjustments
using UnityEngine;
using AmazingAssets.TextureAdjustments;
public class ExampleScript : MonoBehaviour
{
public TextureAdjustments_HueSaturationLightness hsl = new TextureAdjustments_HueSaturationLightness();
public TextureAdjustments_Gradient gradient = new TextureAdjustments_Gradient();
public TextureAdjustments_TextureBombing textureBombing = new TextureAdjustments_TextureBombing();
public TextureAdjustments_LUT lut = new TextureAdjustments_LUT();
Texture2D RenderAdjustments(Texture2D sourceTexture)
{
//Texture Adjustments renders into RenderTexture
RenderTexture renderTexture = null;
//Render adjustments
TextureAdjustments.Render(sourceTexture, ref renderTexture, false, false, hsl, gradient, textureBombing, lut);
//Convert RenderTexture to Texture2D
Texture2D final2D = renderTexture.ToTexture2D();
//Release RenderTexture
renderTexture.Release();
//Release resources used by adjustments
TextureAdjustments.ReleaseResources(hsl, gradient, textureBombing, lut);
return final2D;
}
}
Adjustment classes
Color Correction
TextureAdjustments_ColorSpace
TextureAdjustments_Levels
TextureAdjustments_HueSaturationLightness
TextureAdjustments_BrightnessAndContrast
TextureAdjustments_Grayscale
TextureAdjustments_Sharpen
TextureAdjustments_Threshold
TextureAdjustments_ColorOverlay
TextureAdjustments_ColorReplace
TextureAdjustments_GradientRamp
TextureAdjustments_LUT
Channel
TextureAdjustments_ChannelInvert
TextureAdjustments_ChannelSwap
TextureAdjustments_ChannelImport
TextureAdjustments_ChannelMixer
TextureAdjustments_ChannelClamp
Blur
TextureAdjustments_BlurGaussian
TextureAdjustments_BlurDithering
TextureAdjustments_BlurDirectional
TextureAdjustments_BlurRadial
TextureAdjustments_BlurGrainy
Generate
TextureAdjustments_Gradient
TextureAdjustments_Checkerboard
TextureAdjustments_Grid
TextureAdjustments_Shapes
TextureAdjustments_Whirl
Noise
TextureAdjustments_NoiseGradient
TextureAdjustments_NoisePixelated
TextureAdjustments_NoiseGrainy
TextureAdjustments_NoiseVoronoi
UV
TextureAdjustments_Flip
TextureAdjustments_Skew
TextureAdjustments_TilingAndOffset
TextureAdjustments_Rotator
TextureAdjustments_Twirl
Transform
TextureAdjustments_Resize
TextureAdjustments_Rotate
TextureAdjustments_CanvasSize
TextureAdjustments_Crop
Other
TextureAdjustments_Pixelate
TextureAdjustments_OilPainting
TextureAdjustments_Mipmap
TextureAdjustments_Average
TextureAdjustments_EdgePadding
TextureAdjustments_TextureBombing
TextureAdjustments_GlowingEdges
TextureAdjustments_Stroke
Runtime adjustment classes use the same property drawers as they have in the TA editor window and all class property names are the same as in their property drawers:

Adjustment Class Methods
bool Render(Texture srcTexture,
ref RenderTexture dstTexture,
bool dstTextureIsTemporary,
bool renderMipmaps
Applies current adjustment to the srcTexture and saves the result into the dstTexture. Returns true if adjustment has been successfully rendered. srcTexture is not modified.
srcTexture
Texture that adjustment is applied to.
dstTexture
Holds adjustment’s rendering result. It is always the same size as the srcTexture.
If this property is null, Render method initializes it manually.
dstTextureIsTemporary
Needs to be set to true, if dstTexture is created using RenderTexture.GetTemporary method, otherwise it is false.
renderMipmaps
Set this property to true, for calculating rendered texture's mipmaps too.
void ReleaseResources()
Releases resources used by current adjustment. Those are materials used in the blit methods, temporary calculation textures, etc.
void Reset()
Resets adjustment’s settings to their default values.
void UsesChannels()
Returns true if adjustment can be rendered per-RGBA channels
void UsesBlend()
Returns true if adjustment has blend option
void UsesMask()
Returns true if adjustment has mask option:

Global Static Methods
void TextureAdjustments.Render(Texture srcTexture,
ref RenderTexture dstTexture,
bool dstTextureIsTemporary,
bool renderMipmaps,
params TextureAdjustments_Base[] adjustments);
Applies multiple adjustments to the srcTexture and saves results into the dstTexture. Adjustments are calculated in the same order as they are provided in the list. srcTexture is not modified.
void TextureAdjustments.ReleaseResources(params TextureAdjustments_Base[] adjustments
Releases resources used by adjustments. Those are materials used in the blit methods, temporary calculation textures, etc.
Extensions
using AmazingAssets.TextureAdjustments; in the script, enables several extension methods:
public static Texture2D ToTexture2D(bool hasMipMap = false)
Adds ToTexture2D method to the RenderTexture class, converting it to the Texture2D object.
public static Texture2D ToTexture2D(int textureWidth, bool hasMipMap = false)
Adds ToTexture2D method to the Gradient class, converting it to the Texture2D object.
public static Texture2D[] Split(int rows, int columns, bool hasMipMap = false)
Adds the Split method to the Texture2D class, splitting it by rows and columns and returning the result as the Texture2D array.
public static Color GetAverageColor()
Adds GetAverageColor method to the Texture2D class, calculating its pixels average color value.
Always Included Shaders
Each Texture Adjustments filter is calculated and rendered using its own .shader and if a project uses any of the adjustments run-time API, then .shader used by that adjustment must be included in the Always Included Shaders array inside Graphics settings:

Shader used by adjustment can be easily obtained from the TA editor window or from adjustment property drawer:

Last updated