Texture
public class Texture : Resource A texture is an image used in rendering. Can be a static texture loaded from disk, or a dynamic texture rendered to by code. Can also be 2D, 3D (multiple slices), or a cube texture (6 slices).
Properties
| Name | Type | Description |
|---|---|---|
IsError | Boolean | Whether this texture is an error or invalid or not. |
IsValid virtual | Boolean | |
Flags | TextureFlags | Flags providing hints about this texture |
Index | Int32 | Texture index. Bit raw dog and needs a higher level abstraction. |
Width | Int32 | Width of the texture in pixels. |
Height | Int32 | Height of the texture in pixels. |
Depth | Int32 | Depth of a 3D texture in pixels, or slice count for 2D texture arrays, or 6 for slices of cubemap. |
Mips | Int32 | Number of mip maps this texture has. |
Size | Vector2 | Returns a Vector2 representing the size of the texture (width, height) |
IsLoaded | Boolean | Whether this texture has finished loading or not. |
ImageFormat | ImageFormat | Image format of this texture. |
LastUsed | Int32 | Returns how many frames ago this texture was last used by the renderer |
UAVAccess | Boolean | Gets if the texture has UAV access |
SequenceData | Vector4 | If this texture is a sprite sheet, will return information about the sheet, which is generally used in the shader. You don't really need to think about the contents. |
SequenceCount | Int32 | The count of sequences in this texture, if any. The rest of the sequence data is encoded into the texture itself. |
HasAnimatedSequences | Boolean | |
Invalid static | Texture | 1x1 solid magenta colored texture. |
White static | Texture | 1x1 solid white opaque texture. |
Black static | Texture | 1x1 solid black opaque texture. |
Transparent static | Texture | 1x1 fully transparent texture. |
Methods
static TextureBuilder CreateCustom() Begins creation of a custom texture. Finish by calling Int32).
static Texture2DBuilder Create(Int32 width, Int32 height, ImageFormat format = 0) Begins creation of a custom texture. Finish by calling Finish.
static Texture3DBuilder CreateVolume(Int32 width, Int32 height, Int32 depth, ImageFormat format = 0) Begins creation of a custom 3D texture. Finish by calling Finish.
static TextureCubeBuilder CreateCube(Int32 width = 1, Int32 height = 1, ImageFormat format = 0) Begins creation of a custom cube texture. (A texture with 6 sides) Finish by calling Finish.
static TextureArrayBuilder CreateArray(Int32 width = 1, Int32 height = 1, Int32 count = 1, ImageFormat format = 0) Begins creation of a custom texture array. Finish by calling Finish.
static TextureBuilder CreateRenderTarget() Begins creation of a render target. Finish by calling Int32).
static Texture CreateRenderTarget(String name, ImageFormat format, Vector2 size) A convenience function to quickly create a render target.
name — A meaningless debug name for your texture. format — The image format. size — The size of the texture. static Texture CreateRenderTarget(String name, ImageFormat format, Vector2 size, Texture oldTexture = null) This will create a render target texture if is null or doesn't match what you've passed in. This is designed to be called regularly to resize your texture in response to other things changing (like the screen size, panel size etc).
name — A meaningless debug name for your texture. format — The image format. size — The size of the texture. oldTexture — A previously created texture. static Texture CreateFromSvgSource(String svgContents, Int32? width, Int32? height, Color? color) virtual Void Dispose() Will release the handle for this texture. If the texture isn't referenced by anything else it'll be released properly. This will happen anyway because it's called in the destructor. By calling it manually you're just telling the engine you're done with this texture right now instead of waiting for the garbage collector.
Int32 GetSequenceFrameCount(Int32 sequenceId) Get the frame count for this sequence
Void MarkUsed(Int32 requiredMipSize = 0) Tells texture streaming this texture is being used. This is usually automatic, but useful for bindless pipelines.
static Texture Load(BaseFileSystem filesystem, String filepath, Boolean warnOnMissing = True) Try to load a texture from given filesystem, by filename.
static Texture LoadFromFileSystem(String filepath, BaseFileSystem filesystem, Boolean warnOnMissing = True) Try to load a texture from given filesystem, by filename.
static Texture Load(String path_or_url, Boolean warnOnMissing = True) Try to load a texture.
static Texture LoadAvatar(Int64 steamid, Int32 size = 64) Load avatar image of a Steam user (with a certain size if supplied).
steamid — The SteamID of the user to load the avatar of. size — The size of the avatar (Can be 32, 64, or 128. Defaults to 64 and rounds input to nearest of the three). static Texture LoadAvatar(String steamid, Int32 size) static Task<Texture> LoadAsync(BaseFileSystem filesystem, String filepath, Boolean warnOnMissing = True) Load a texture asynchronously. Will return when the texture is loaded and valid. This is useful when loading textures from the web.
static Task<Texture> LoadAsync(String filepath, Boolean warnOnMissing = True) Load a texture asynchronously. Will return when the texture is loaded and valid. This is useful when loading textures from the web, or without any big loading hitches.
static Task<Texture> LoadFromFileSystemAsync(String filepath, BaseFileSystem filesystem, Boolean warnOnMissing = True) Load a texture asynchronously. Will return when the texture is loaded and valid. This is useful when loading textures from the web, or without any big loading hitches.
static Texture Find(String filepath) Try to get an already loaded texture.
filepath — The filename of the texture. Color32[] GetPixels(Int32 mip = 0) Reads pixel colors from the texture at the specified mip level
Bitmap GetBitmap(Int32 mip) Void GetPixels(ValueTuple<Int32, Int32, Int32, Int32> srcRect, Int32 slice, Int32 mip, Span<T> dstData, ImageFormat dstFormat, ValueTuple<Int32, Int32> dstSize = null) Void GetPixels(ValueTuple<Int32, Int32, Int32, Int32> srcRect, Int32 slice, Int32 mip, Span<T> dstData, ImageFormat dstFormat, ValueTuple<Int32, Int32, Int32, Int32> dstRect, Int32 dstStride) Void GetPixels3D(ValueTuple<Int32, Int32, Int32, Int32, Int32, Int32> srcBox, Int32 mip, Span<T> dstData, ImageFormat dstFormat, ValueTuple<Int32, Int32, Int32> dstSize = null) Color32 GetPixel(Single x, Single y, Int32 mip = 0) Reads a single pixel color.
Color32 GetPixel3D(Single x, Single y, Single z, Int32 mip = 0) Reads a single pixel color from a volume or array texture.
Void GetPixelsAsync(ReadOnlySpan<Color32>> callback, Int32 mip = 0) Void GetPixelsAsync(ReadOnlySpan<T>> callback, ImageFormat dstFormat = -2, ValueTuple<Int32, Int32, Int32, Int32> srcRect = null, Int32 slice = 0, Int32 mip = 0) Void GetPixelsAsync3D(ReadOnlySpan<T>> callback, ImageFormat dstFormat = -2, ValueTuple<Int32, Int32, Int32, Int32, Int32, Int32> srcBox = null, Int32 mip = 0) Void GetBitmapAsync(Action<Bitmap> callback, Int32 mip = 0) Byte[] SaveToVtex(ImageFormat? formatOverride = null) Task<Byte[]> SaveToVtexAsync(ImageFormat? format = null) Void Clear(Color color) Clear this texture with a solid color
Void Update(ReadOnlySpan<Byte> data, Int32 x = 0, Int32 y = 0, Int32 width = 0, Int32 height = 0) Void Update(ReadOnlySpan<T> data, Int32 x = 0, Int32 y = 0, Int32 width = 0, Int32 height = 0) Void Update(ReadOnlySpan<Color32> data, Int32 x = 0, Int32 y = 0, Int32 width = 0, Int32 height = 0) Void Update(Bitmap source) Update this texture from the bitmap
Void Update3D(ReadOnlySpan<Byte> data, Int32 x = 0, Int32 y = 0, Int32 z = 0, Int32 width = 0, Int32 height = 0, Int32 depth = 0) Void Update(Color32 color, Single x, Single y) Write a coloured pixel to the texture