Class TextureUtils
Represents a series of Texture utility methods.
Inherited Members
Namespace: TriLibCore.Utils
Assembly: TriLibCore.dll
Syntax
public static class TextureUtils
Methods
ApplyTexture2D(TextureLoadingContext, bool)
Uploads the Unity Texture data to the GPU.
Declaration
public static void ApplyTexture2D(TextureLoadingContext textureLoadingContext, bool procedural)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | The Texture Context containing Data from the original and the Unity Texture. |
bool | procedural |
ApplyTransparency(TextureLoadingContext, Texture, Texture)
Applies Transparency to the Diffuse Texture data.
Declaration
public static void ApplyTransparency(TextureLoadingContext textureLoadingContext, Texture diffuseTexture, Texture transparencyTexture)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | |
Texture | diffuseTexture | |
Texture | transparencyTexture |
BuildMetallicTexture(TextureLoadingContext, Texture, Texture, Texture, Texture, Color, Color, float, float?, float?, bool, bool, int, int)
Builds a Metallic Texture using the given context data.
Declaration
public static void BuildMetallicTexture(TextureLoadingContext textureLoadingContext, Texture diffuseTexture, Texture metallicTexture, Texture specularTexture, Texture glossinessTexture, Color defaultDiffuse, Color defaultSpecular, float shininessExponent, float? defaultRoughness, float? defaultMetallic, bool usingRoughness = false, bool mixTextureChannelsWithColors = false, int metallicComponentIndex = 0, int glossinessComponentIndex = 0)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | |
Texture | diffuseTexture | |
Texture | metallicTexture | |
Texture | specularTexture | |
Texture | glossinessTexture | |
Color | defaultDiffuse | |
Color | defaultSpecular | |
float | shininessExponent | |
float? | defaultRoughness | |
float? | defaultMetallic | |
bool | usingRoughness | |
bool | mixTextureChannelsWithColors | |
int | metallicComponentIndex | |
int | glossinessComponentIndex |
CopyTextureCPU(RenderTexture, Texture2D, bool, bool)
Copies the content from a RenderTexture to a Texture2D updating the CPU Texture memory.
Declaration
public static void CopyTextureCPU(RenderTexture from, Texture2D to, bool updateMipMaps, bool makeNoLongerReadable)
Parameters
Type | Name | Description |
---|---|---|
RenderTexture | from | The source RenderTexture. |
Texture2D | to | The destination Texture2D. |
bool | updateMipMaps | if set to |
bool | makeNoLongerReadable | if set to |
CreateTexture2D(TextureLoadingContext)
Creates a Unity Texture from the given Context.
Declaration
public static void CreateTexture2D(TextureLoadingContext textureLoadingContext)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | The Texture Context containing Data from the original and the Unity Texture. |
ExtractChannelData(int, TextureLoadingContext, string)
Extracts a Unity Texture Channel Data.
Declaration
public static void ExtractChannelData(int channelIndex, TextureLoadingContext textureLoadingContext, string suffix = "")
Parameters
Type | Name | Description |
---|---|---|
int | channelIndex | The Channel (Color Component) index. |
TextureLoadingContext | textureLoadingContext | The Texture Context containing Data from the original and the Unity Texture. |
string | suffix | Suffix to add to Texture name. |
FixNPOTTexture(TextureLoadingContext)
Fixes a Texture that has non power-of-two resolution.
Declaration
public static void FixNPOTTexture(TextureLoadingContext textureLoadingContext)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | The Texture Context containing Data from the original and the Unity Texture. |
FixNormalMap(TextureLoadingContext)
Changes the Texture channel order from RGBA to AGGR.
Declaration
public static void FixNormalMap(TextureLoadingContext textureLoadingContext)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | The Texture Context containing Data from the original and the Unity Texture. |
GetNextPOT(int)
Declaration
public static int GetNextPOT(int value)
Parameters
Type | Name | Description |
---|---|---|
int | value |
Returns
Type | Description |
---|---|
int |
IsValidTextureFileType(string)
Returns whether the given filename has a valid texture file extension.
Declaration
public static bool IsValidTextureFileType(string filename)
Parameters
Type | Name | Description |
---|---|---|
string | filename | The filename to check. |
Returns
Type | Description |
---|---|
bool |
|
LoadTexture2D(TextureLoadingContext)
Loads a Texture using Unity internal image loader.
Declaration
public static void LoadTexture2D(TextureLoadingContext textureLoadingContext)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | The Texture Context containing Data from the original and the Unity Texture. |
LoadTexture2DNonAlloc(TextureLoadingContext)
Loads a Texture.
Declaration
public static void LoadTexture2DNonAlloc(TextureLoadingContext textureLoadingContext)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | The Texture Context containing Data from the original and the Unity Texture. |
SpecularDiffuseToAlbedo(TextureLoadingContext, Texture, Texture, Vector4, Vector4, float, bool, bool)
Converts a Specular Diffuse Texture into an Albedo Texture.
Declaration
public static void SpecularDiffuseToAlbedo(TextureLoadingContext textureLoadingContext, Texture diffuseTexture, Texture specularTexture, Vector4 diffuseColor, Vector4 specularColor, float glossiness, bool outputBaseColor, bool reassign = false)
Parameters
Type | Name | Description |
---|---|---|
TextureLoadingContext | textureLoadingContext | |
Texture | diffuseTexture | |
Texture | specularTexture | |
Vector4 | diffuseColor | |
Vector4 | specularColor | |
float | glossiness | |
bool | outputBaseColor | |
bool | reassign |