Astra Unity 2.6.6
Astra Unity Plugin
|
Utilities for working with Textures More...
Classes | |
class | TextureJob |
Public Types | |
enum | BlendType { Albedo = 0 , Normal = 1 , MetalGloss = 2 } |
Static Public Member Functions | |
static Texture2D | OverlayTextures (Texture2D aBaseTexture, Texture2D aToCopyTexture) |
Produces a Texture2D image composite of two images, where the base texture's R channel is only overwritten when the copy texture's R channel is less than the threshold of 0.48f for a given pixel. More... | |
static void | OverlayArrayOfTexturesGPU (ref Texture2D outputTexture, Texture2D[] textures, string shaderName="Unlit/AlphaCombiner", bool debug=false, Color? backgroundOverload=null, Material mat=null, RenderTextureReadWrite rwMode=RenderTextureReadWrite.Default) |
Merge multiple textures into one, this is done on the GPU and is currently specific to the alpha injection system This is MUCH faster then the original cpu only method (150ms to about 8.5ms) More... | |
static RenderTexture | OverlayArrayOfTexturesCompute (List< Texture > textures, List< float > strengths, BlendType blendType, RenderTextureFormat format=RenderTextureFormat.ARGB32, bool linear=false, bool debug=false) |
Merge multiple decal textures into one on the GPU via compute shader. More... | |
static RenderTexture | OverlayArrayOfTexturesGPU (Texture[] textures, string shaderName="Unlit/AlphaCombiner", bool debug=false, Color? backgroundOverload=null, RenderTextureFormat format=RenderTextureFormat.ARGB32, Material[] mats=null, int maxSize=-1, bool linear=false, int width=-1, int height=-1) |
Processes a stack of textures by rendering them out as quads textures at indexes higher will be closest to the camera with the texture at slot 0 the farthest away More... | |
static Texture2D | GetReadableTexture (Texture2D texture, TextureFormat format=TextureFormat.ARGB32, bool mipmap=true, bool linear=false, bool destroyOriginal=false, bool colorSpaceConvert=true) |
Converts any Texture2D into a readable Texture2D, this is useful for textures not marked Read/Write enabled More... | |
static TextureJob | GetReadableTextureAsync (Texture2D texture, TextureFormat format=TextureFormat.ARGB32, bool mipmap=true, bool linear=false, bool destroyOriginal=false, bool colorSpaceConvert=true) |
static Texture2D | QuickScale (Texture2D texture, int width, int height) |
Quick operation to scale a given texture to the specified size on the GPU More... | |
static Texture2D | QuickScale (Texture2D texture, int width, int height, TextureFormat format, bool linear=false) |
Quick operation to scale a given texture to the specified size on the GPU More... | |
static Texture2D | RenderMaterialToTexture2D (Material mat, bool debug=false, Color? backgroundOverload=null, bool linear=false, int width=2048, int height=2048) |
Renders a material to a texture, blocking. This is useful for baking complex materials into a single diffuse More... | |
static GameObject | DebugTexture (Texture tex) |
Creates a visible quad at 0,0,0 for display and debugging purposes More... | |
static GameObject | DebugMaterial (Material material) |
Creates a visible quad at 0,0,0 for display of the material More... | |
static Color[] | SampleTextureAtUVs (Texture2D texture, Vector2[] uvs) |
static Color32[] | Sample32TextureAtUVs (Texture2D texture, Vector2[] uvs) |
static int | GetPixelSlotFromUV (int x, int y, int width, int height=0) |
Retrieves the slot in a continuous array for colors More... | |
static int | GetPixelSlotFromUV (float x, float y, int width, int height) |
Retrieves the slot in a continuous array for colors More... | |
static int | GetPixelSlotFromUV (Vector2 uv, int width, int height) |
static TextureFormat | GetTextureFormatFromRenderTextureFormat (RenderTextureFormat srcFormat) |
Returns a suitable uncompressed textureformat from a render texture format, this is a "guess" More... | |
static RenderTextureFormat | GetRenderTextureFormatFromTextureFormat (TextureFormat srcFormat) |
static bool | IsTextureFormatCompressed (TextureFormat format) |
static bool | IsReadable (Texture2D texture) |
Tells us if a texture is readable or not, for legacy versions of unity (2018.2-) this is done by exception catching More... | |
static bool | IsPNG (byte[] bytes) |
Tells you if the bytes you loaded is a raw PNG file or not More... | |
Properties | |
static Light[] | scannedLights [getset] |
Utilities for working with Textures
|
inlinestatic |
Creates a visible quad at 0,0,0 for display of the material
material | The material you want to visualize |
|
inlinestatic |
Creates a visible quad at 0,0,0 for display and debugging purposes
tex | The texture you want to visualize |
|
inlinestatic |
Retrieves the slot in a continuous array for colors
x | A uv value such as 0.3 or 1.5 |
y | |
width | |
height |
|
inlinestatic |
Retrieves the slot in a continuous array for colors
x | The horizontal position stating left from 0->width eg: 500 |
y | The vertical position starting bottom from 0->height |
width | Pixels wide eg: 256 |
height | Pixels tall eg: 512 |
|
inlinestatic |
Converts any Texture2D into a readable Texture2D, this is useful for textures not marked Read/Write enabled
texture | source texture you want to make readable |
format | The color channel format defaults to ARGB32 not all formats are supported |
mipmap | If you want mipmaps generated |
linear | True if you want linear colorspace otherwise in gamma |
destroyOriginal | note this one SWAPS the default behaviour, as you usually want to keep the original around when calling this function! |
colorSpaceConvert | Controls if you want GL.sRGBWrite manipulated when you're in linear space, has no effect in gamma |
|
inlinestatic |
Returns a suitable uncompressed textureformat from a render texture format, this is a "guess"
srcFormat |
|
inlinestatic |
Tells you if the bytes you loaded is a raw PNG file or not
bytes | The byte array from |
|
inlinestatic |
Tells us if a texture is readable or not, for legacy versions of unity (2018.2-) this is done by exception catching
texture | The texture you want to test |
|
inlinestatic |
Merge multiple decal textures into one on the GPU via compute shader.
textures | List of textures to merge |
strengths | List of strengths for merging normals where 0.0 : 100% transparent and 1.0 : 100% opaque |
decalSlot | A string indicating what kind of blend operation e.g. albedo, normal, metallic |
format | Format for the RenderTexture used for this operation. Defaults to RenderTextureFormat.ARGB32 |
linear | Whether to use the RenderTextureReadWrite.Linear mode. Defaults to false |
debug | If true, keep the merge object afterwards to look at. Defaults false |
|
inlinestatic |
Merge multiple textures into one, this is done on the GPU and is currently specific to the alpha injection system This is MUCH faster then the original cpu only method (150ms to about 8.5ms)
outputTexture | The Texture to merge into |
textures | List of textures to merge |
shaderName | Shader to use, defaults to Unlit/AlphaCombiner |
debug | If true, keep the merge object afterwards to look at. Defaults false |
backgroundOverload | Background color to use. Defaults to white. |
mat | Material to use. If set, overrides the shader with the shader in this material. Defaults to null. |
rwMode | Color space conversion mode for the RenderTexture this operation uses. Defaults to RenderTextureReadWrite.Default. |
|
inlinestatic |
Processes a stack of textures by rendering them out as quads textures at indexes higher will be closest to the camera with the texture at slot 0 the farthest away
NOTE: this method is better to use then the version that returns a Texture2D as that one needs to trip a readpixels call This call is about 0.5ms, the read pixel call typically takes about 20 times as long (~8.5ms)
textures | The textures to render, highest index is closets, lowest index is farthest |
shaderName | Shader to use, defaults to Unlit/AlphaCombiner |
debug | If true, keep the merge object afterwards to look at. Defaults false |
backgroundOverload | Background color to use. Defaults to white. |
format | Format for the RenderTexture used for this operation. Defaults to RenderTextureFormat.ARGB32. |
mats | List of Materials to use, one for each texture passed in. If set, overrides the shader with the shader in this material for the associated texture. Defaults to null. |
maxSize | Maximum size for the resulting texture's width and height. Defaults to -1. |
linear | Whether to use the RenderTextureReadWrite.Linear mode. Defaults to false |
width | Width of the resulting texture, or -1 to be ignored. Defaults to -1 |
height | Height of the resulting texture, or -1 to be ignored. Defaults to -1 |
|
inlinestatic |
Produces a Texture2D image composite of two images, where the base texture's R channel is only overwritten when the copy texture's R channel is less than the threshold of 0.48f for a given pixel.
aBaseTexture | A base texture. |
aToCopyTexture | A to copy texture. |
|
inlinestatic |
Quick operation to scale a given texture to the specified size on the GPU
texture | Texture to scale |
width | Target width of result |
height | Target height of result |
|
inlinestatic |
Quick operation to scale a given texture to the specified size on the GPU
texture | Texture to scale |
width | Target width of result |
height | Target height of result |
format | TextureFormat to use for the resulting texture |
linear | Whether to use the RenderTextureReadWrite.Linear mode for rendering. Defaults to false. |
|
inlinestatic |
Renders a material to a texture, blocking. This is useful for baking complex materials into a single diffuse
mat | The material you want to bake |
debug | Set true to keep temporary textures in scene/memory for debugging |
backgroundOverload | Set to a color to replace the default color to use in the texture |
linear | If true, will render and set colors using linear, you typically do not want this as most colors should be in gamma/sRGB |
width | The width of the output texture |
height | The height of the output texture |