s&box docs

public class Sandbox.Texture : Sandbox.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).

Broader workflow and conceptual references connected to this API.

Methods

Showing 43 methods

public void Clear(Color color)

Clear this texture with a solid color

public static Sandbox.Texture2DBuilder Create(int width, int height, Sandbox.ImageFormat format = 0)

Begins creation of a custom texture. Finish by calling `Sandbox.Texture2DBuilder.Finish`.

Parameters

  • format: Default: 0

public static Sandbox.TextureArrayBuilder CreateArray(int width = 1, int height = 1, int count = 1, Sandbox.ImageFormat format = 0)

Begins creation of a custom texture array. Finish by calling `Sandbox.TextureArrayBuilder.Finish`.

Parameters

  • width: Default: 1
  • height: Default: 1
  • count: Default: 1
  • format: Default: 0

public static Sandbox.TextureCubeBuilder CreateCube(int width = 1, int height = 1, Sandbox.ImageFormat format = 0)

Begins creation of a custom cube texture. (A texture with 6 sides) Finish by calling `Sandbox.TextureCubeBuilder.Finish`.

Parameters

  • width: Default: 1
  • height: Default: 1
  • format: Default: 0

public static Sandbox.TextureBuilder CreateCustom()

Begins creation of a custom texture. Finish by calling `Sandbox.TextureBuilder.Create(System.String,System.Boolean,System.ReadOnlySpan,System.Int32)`.

public static Sandbox.Texture CreateFromSvgSource(string svgContents, System.Nullable`1<int> width, System.Nullable`1<int> height, System.Nullable`1<Color> color)

public static Sandbox.Texture3DBuilder CreateVolume(int width, int height, int depth, Sandbox.ImageFormat format = 0)

Begins creation of a custom 3D texture. Finish by calling `Sandbox.Texture3DBuilder.Finish`.

Parameters

  • format: Default: 0

public virtual sealed 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.

protected virtual override void Finalize()

public static Sandbox.Texture Find(string filepath)

Try to get an already loaded texture.

Parameters

  • filepath: The filename of the texture.

Returns

The already loaded texture, or null if it was not yet loaded.

public Sandbox.Bitmap GetBitmap(int mip)

public void GetBitmapAsync(System.Action`1<Sandbox.Bitmap> callback, int mip = 0)

Parameters

  • mip: Default: 0

public Color32 GetPixel(float x, float y, int mip = 0)

Reads a single pixel color.

Parameters

  • mip: Default: 0

public Color32 GetPixel3D(float x, float y, float z, int mip = 0)

Reads a single pixel color from a volume or array texture.

Parameters

  • mip: Default: 0

public void GetPixels3D(System.ValueTuple`6<int,int,int,int,int,int> srcBox, int mip, System.Span`1<T> dstData, Sandbox.ImageFormat dstFormat, System.ValueTuple`3<int,int,int> dstSize = null)

Parameters

  • dstSize: Default: null

public void GetPixelsAsync3D(System.Action`1<System.ReadOnlySpan`1<T>> callback, Sandbox.ImageFormat dstFormat = -2, System.ValueTuple`6<int,int,int,int,int,int> srcBox = null, int mip = 0)

Parameters

  • dstFormat: Default: -2
  • srcBox: Default: null
  • mip: Default: 0

public int GetSequenceFrameCount(int sequenceId)

Get the frame count for this sequence

public static Sandbox.Texture LoadFromFileSystem(string filepath, Sandbox.BaseFileSystem filesystem, bool warnOnMissing = True)

Try to load a texture from given filesystem, by filename.

Parameters

  • warnOnMissing: Default: True

public static System.Threading.Tasks.Task`1<Sandbox.Texture> LoadFromFileSystemAsync(string filepath, Sandbox.BaseFileSystem filesystem, bool 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.

Parameters

  • warnOnMissing: Default: True

public void MarkUsed(int requiredMipSize = 0)

Tells texture streaming this texture is being used. This is usually automatic, but useful for bindless pipelines.

Parameters

  • requiredMipSize: Default: 0

public byte[] SaveToVtex(System.Nullable`1<Sandbox.ImageFormat> formatOverride = null)

Parameters

  • formatOverride: Default: null

public System.Threading.Tasks.Task`1<byte[]> SaveToVtexAsync(System.Nullable`1<Sandbox.ImageFormat> format = null)

Parameters

  • format: Default: null

public void Update3D(System.ReadOnlySpan`1<byte> data, int x = 0, int y = 0, int z = 0, int width = 0, int height = 0, int depth = 0)

Parameters

  • x: Default: 0
  • y: Default: 0
  • z: Default: 0
  • width: Default: 0
  • height: Default: 0
  • depth: Default: 0

Properties

Showing 20 properties

public static Sandbox.Texture Sandbox.Texture.Black { get; set; }

1x1 solid black opaque texture.

public int Sandbox.Texture.Depth { get; set; }

Depth of a 3D texture in pixels, or slice count for 2D texture arrays, or 6 for slices of cubemap.

public Sandbox.TextureFlags Sandbox.Texture.Flags { get; set; }

Flags providing hints about this texture

public bool Sandbox.Texture.HasAnimatedSequences { get; set; }

public int Sandbox.Texture.Height { get; set; }

Height of the texture in pixels.

public int Sandbox.Texture.Index { get; set; }

Texture index. Bit raw dog and needs a higher level abstraction.

public static Sandbox.Texture Sandbox.Texture.Invalid { get; set; }

1x1 solid magenta colored texture.

public bool Sandbox.Texture.IsError { get; set; }

Whether this texture is an error or invalid or not.

public bool Sandbox.Texture.IsLoaded { get; set; }

Whether this texture has finished loading or not.

public virtual bool Sandbox.Texture.IsValid { get; set; }

public int Sandbox.Texture.LastUsed { get; set; }

Returns how many frames ago this texture was last used by the renderer

public int Sandbox.Texture.Mips { get; set; }

Number of mip maps this texture has.

public int Sandbox.Texture.SequenceCount { get; set; }

The count of sequences in this texture, if any. The rest of the sequence data is encoded into the texture itself.

public Vector4 Sandbox.Texture.SequenceData { get; set; }

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.

public Vector2 Sandbox.Texture.Size { get; set; }

Returns a Vector2 representing the size of the texture (width, height)

public static Sandbox.Texture Sandbox.Texture.Transparent { get; set; }

1x1 fully transparent texture.

public bool Sandbox.Texture.UAVAccess { get; set; }

Gets if the texture has UAV access

public static Sandbox.Texture Sandbox.Texture.White { get; set; }

1x1 solid white opaque texture.

public int Sandbox.Texture.Width { get; set; }

Width of the texture in pixels.

Metadata

FieldValue
NamespaceSandbox
Typeclass
AssemblySandbox.Engine
Doc IDT:Sandbox.Texture

On this page

Methodspublic System.Void Clear(Color color)public static Sandbox.Texture2DBuilder Create(System.Int32 width, System.Int32 height, Sandbox.ImageFormat format = 0)public static Sandbox.TextureArrayBuilder CreateArray(System.Int32 width = 1, System.Int32 height = 1, System.Int32 count = 1, Sandbox.ImageFormat format = 0)public static Sandbox.TextureCubeBuilder CreateCube(System.Int32 width = 1, System.Int32 height = 1, Sandbox.ImageFormat format = 0)public static Sandbox.TextureBuilder CreateCustom()public static Sandbox.Texture CreateFromSvgSource(System.String svgContents, System.Nullable`1<System.Int32> width, System.Nullable`1<System.Int32> height, System.Nullable`1<Color> color)public static Sandbox.TextureBuilder CreateRenderTarget()public static Sandbox.Texture CreateRenderTarget(System.String name, Sandbox.ImageFormat format, Vector2 size, Sandbox.Texture oldTexture = null)public static Sandbox.Texture CreateRenderTarget(System.String name, Sandbox.ImageFormat format, Vector2 size)public static Sandbox.Texture3DBuilder CreateVolume(System.Int32 width, System.Int32 height, System.Int32 depth, Sandbox.ImageFormat format = 0)public virtual sealed System.Void Dispose()protected virtual override System.Void Finalize()public static Sandbox.Texture Find(System.String filepath)public Sandbox.Bitmap GetBitmap(System.Int32 mip)public System.Void GetBitmapAsync(System.Action`1<Sandbox.Bitmap> callback, System.Int32 mip = 0)public Color32 GetPixel(System.Single x, System.Single y, System.Int32 mip = 0)public Color32 GetPixel3D(System.Single x, System.Single y, System.Single z, System.Int32 mip = 0)public Color32[] GetPixels(System.Int32 mip = 0)public System.Void GetPixels(System.ValueTuple`4<System.Int32,System.Int32,System.Int32,System.Int32> srcRect, System.Int32 slice, System.Int32 mip, System.Span`1<T> dstData, Sandbox.ImageFormat dstFormat, System.ValueTuple`2<System.Int32,System.Int32> dstSize = null)public System.Void GetPixels(System.ValueTuple`4<System.Int32,System.Int32,System.Int32,System.Int32> srcRect, System.Int32 slice, System.Int32 mip, System.Span`1<T> dstData, Sandbox.ImageFormat dstFormat, System.ValueTuple`4<System.Int32,System.Int32,System.Int32,System.Int32> dstRect, System.Int32 dstStride)public System.Void GetPixels3D(System.ValueTuple`6<System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32> srcBox, System.Int32 mip, System.Span`1<T> dstData, Sandbox.ImageFormat dstFormat, System.ValueTuple`3<System.Int32,System.Int32,System.Int32> dstSize = null)public System.Void GetPixelsAsync(System.Action`1<System.ReadOnlySpan`1<Color32>> callback, System.Int32 mip = 0)public System.Void GetPixelsAsync(System.Action`1<System.ReadOnlySpan`1<T>> callback, Sandbox.ImageFormat dstFormat = -2, System.ValueTuple`4<System.Int32,System.Int32,System.Int32,System.Int32> srcRect = null, System.Int32 slice = 0, System.Int32 mip = 0)public System.Void GetPixelsAsync3D(System.Action`1<System.ReadOnlySpan`1<T>> callback, Sandbox.ImageFormat dstFormat = -2, System.ValueTuple`6<System.Int32,System.Int32,System.Int32,System.Int32,System.Int32,System.Int32> srcBox = null, System.Int32 mip = 0)public System.Int32 GetSequenceFrameCount(System.Int32 sequenceId)public static Sandbox.Texture Load(Sandbox.BaseFileSystem filesystem, System.String filepath, System.Boolean warnOnMissing = True)public static Sandbox.Texture Load(System.String path_or_url, System.Boolean warnOnMissing = True)public static System.Threading.Tasks.Task`1<Sandbox.Texture> LoadAsync(Sandbox.BaseFileSystem filesystem, System.String filepath, System.Boolean warnOnMissing = True)public static System.Threading.Tasks.Task`1<Sandbox.Texture> LoadAsync(System.String filepath, System.Boolean warnOnMissing = True)public static Sandbox.Texture LoadAvatar(System.Int64 steamid, System.Int32 size = 64)public static Sandbox.Texture LoadAvatar(System.String steamid, System.Int32 size)public static Sandbox.Texture LoadFromFileSystem(System.String filepath, Sandbox.BaseFileSystem filesystem, System.Boolean warnOnMissing = True)public static System.Threading.Tasks.Task`1<Sandbox.Texture> LoadFromFileSystemAsync(System.String filepath, Sandbox.BaseFileSystem filesystem, System.Boolean warnOnMissing = True)public System.Void MarkUsed(System.Int32 requiredMipSize = 0)public System.Byte[] SaveToVtex(System.Nullable`1<Sandbox.ImageFormat> formatOverride = null)public System.Threading.Tasks.Task`1<System.Byte[]> SaveToVtexAsync(System.Nullable`1<Sandbox.ImageFormat> format = null)public System.Void Update(Color32 color, Sandbox.Rect rect)public System.Void Update(Color32 color, System.Single x, System.Single y)public System.Void Update(Sandbox.Bitmap source)public System.Void Update(System.ReadOnlySpan`1<Color32> data, System.Int32 x = 0, System.Int32 y = 0, System.Int32 width = 0, System.Int32 height = 0)public System.Void Update(System.ReadOnlySpan`1<System.Byte> data, System.Int32 x = 0, System.Int32 y = 0, System.Int32 width = 0, System.Int32 height = 0)public System.Void Update(System.ReadOnlySpan`1<T> data, System.Int32 x = 0, System.Int32 y = 0, System.Int32 width = 0, System.Int32 height = 0)public System.Void Update3D(System.ReadOnlySpan`1<System.Byte> data, System.Int32 x = 0, System.Int32 y = 0, System.Int32 z = 0, System.Int32 width = 0, System.Int32 height = 0, System.Int32 depth = 0)Propertiespublic static Sandbox.Texture Sandbox.Texture.Black { get; set; }public System.Int32 Sandbox.Texture.Depth { get; set; }public Sandbox.TextureFlags Sandbox.Texture.Flags { get; set; }public System.Boolean Sandbox.Texture.HasAnimatedSequences { get; set; }public System.Int32 Sandbox.Texture.Height { get; set; }public Sandbox.ImageFormat Sandbox.Texture.ImageFormat { get; set; }public System.Int32 Sandbox.Texture.Index { get; set; }public static Sandbox.Texture Sandbox.Texture.Invalid { get; set; }public System.Boolean Sandbox.Texture.IsError { get; set; }public System.Boolean Sandbox.Texture.IsLoaded { get; set; }public virtual System.Boolean Sandbox.Texture.IsValid { get; set; }public System.Int32 Sandbox.Texture.LastUsed { get; set; }public System.Int32 Sandbox.Texture.Mips { get; set; }public System.Int32 Sandbox.Texture.SequenceCount { get; set; }public Vector4 Sandbox.Texture.SequenceData { get; set; }public Vector2 Sandbox.Texture.Size { get; set; }public static Sandbox.Texture Sandbox.Texture.Transparent { get; set; }public System.Boolean Sandbox.Texture.UAVAccess { get; set; }public static Sandbox.Texture Sandbox.Texture.White { get; set; }public System.Int32 Sandbox.Texture.Width { get; set; }Metadata