Textureclass
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).
Methods43
Showing 43 methods
public void Clear(Color color)
Clear this texture with a solid color
| Parameter | Type | Description |
|---|---|---|
| color | Color | — |
void—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`.
| Parameter | Type | Description |
|---|---|---|
| width | int | — |
| height | int | — |
| format = 0 | ImageFormat | — |
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`.
| Parameter | Type | Description |
|---|---|---|
| width = 1 | int | — |
| height = 1 | int | — |
| count = 1 | int | — |
| format = 0 | ImageFormat | — |
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`.
| Parameter | Type | Description |
|---|---|---|
| width = 1 | int | — |
| height = 1 | int | — |
| format = 0 | ImageFormat | — |
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)
| Parameter | Type | Description |
|---|---|---|
| svgContents | string | — |
| width | Nullable<int> | — |
| height | Nullable<int> | — |
| color | Nullable<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`.
| Parameter | Type | Description |
|---|---|---|
| width | int | — |
| height | int | — |
| depth | int | — |
| format = 0 | ImageFormat | — |
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.
void—protected virtual override void Finalize()
void—public static Sandbox.Texture Find(string filepath)
Try to get an already loaded texture.
| Parameter | Type | Description |
|---|---|---|
| filepath | string | The filename of the texture. |
public void GetBitmapAsync(System.Action`1<Sandbox.Bitmap> callback, int mip = 0)
| Parameter | Type | Description |
|---|---|---|
| callback | Action<Bitmap> | — |
| mip = 0 | int | — |
void—public Color32 GetPixel(float x, float y, int mip = 0)
Reads a single pixel color.
| Parameter | Type | Description |
|---|---|---|
| x | float | — |
| y | float | — |
| mip = 0 | int | — |
public Color32 GetPixel3D(float x, float y, float z, int mip = 0)
Reads a single pixel color from a volume or array texture.
| Parameter | Type | Description |
|---|---|---|
| x | float | — |
| y | float | — |
| z | float | — |
| mip = 0 | int | — |
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)
| Parameter | Type | Description |
|---|---|---|
| srcBox | ValueTuple<int,int,int,int,int,int> | — |
| mip | int | — |
| dstData | Span<T> | — |
| dstFormat | ImageFormat | — |
| dstSize = null | ValueTuple<int,int,int> | — |
void—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)
| Parameter | Type | Description |
|---|---|---|
| callback | Action<ReadOnlySpan<T>> | — |
| dstFormat = -2 | ImageFormat | — |
| srcBox = null | ValueTuple<int,int,int,int,int,int> | — |
| mip = 0 | int | — |
void—public int GetSequenceFrameCount(int sequenceId)
Get the frame count for this sequence
| Parameter | Type | Description |
|---|---|---|
| sequenceId | int | — |
int—public static Sandbox.Texture LoadFromFileSystem(string filepath, Sandbox.BaseFileSystem filesystem, bool warnOnMissing = True)
Try to load a texture from given filesystem, by filename.
| Parameter | Type | Description |
|---|---|---|
| filepath | string | — |
| filesystem | BaseFileSystem | — |
| warnOnMissing = True | bool | — |
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.
| Parameter | Type | Description |
|---|---|---|
| filepath | string | — |
| filesystem | BaseFileSystem | — |
| warnOnMissing = True | bool | — |
public void MarkUsed(int requiredMipSize = 0)
Tells texture streaming this texture is being used. This is usually automatic, but useful for bindless pipelines.
| Parameter | Type | Description |
|---|---|---|
| requiredMipSize = 0 | int | — |
void—public byte[] SaveToVtex(System.Nullable`1<Sandbox.ImageFormat> formatOverride = null)
| Parameter | Type | Description |
|---|---|---|
| formatOverride = null | Nullable<ImageFormat> | — |
byte[]—public System.Threading.Tasks.Task`1<byte[]> SaveToVtexAsync(System.Nullable`1<Sandbox.ImageFormat> format = null)
| Parameter | Type | Description |
|---|---|---|
| format = null | Nullable<ImageFormat> | — |
Task<byte[]>—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)
| Parameter | Type | Description |
|---|---|---|
| data | ReadOnlySpan<byte> | — |
| x = 0 | int | — |
| y = 0 | int | — |
| z = 0 | int | — |
| width = 0 | int | — |
| height = 0 | int | — |
| depth = 0 | int | — |
void—No results match this filter.
Properties20
Showing 20 properties
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.
int—public Sandbox.TextureFlags Sandbox.Texture.Flags { get; set; }
Flags providing hints about this texture
public bool Sandbox.Texture.HasAnimatedSequences { get; set; }
bool—public int Sandbox.Texture.Height { get; set; }
Height of the texture in pixels.
int—public Sandbox.ImageFormat Sandbox.Texture.ImageFormat { get; set; }
Image format of this texture.
public int Sandbox.Texture.Index { get; set; }
Texture index. Bit raw dog and needs a higher level abstraction.
int—public static Sandbox.Texture Sandbox.Texture.Invalid { get; set; }
1x1 solid magenta colored texture.
public virtual bool Sandbox.Texture.IsError { get; set; }
Whether this texture is an error or invalid or not.
bool—public bool Sandbox.Texture.IsLoaded { get; set; }
Whether this texture has finished loading or not.
bool—public virtual bool Sandbox.Texture.IsValid { get; set; }
bool—public int Sandbox.Texture.LastUsed { get; set; }
Returns how many frames ago this texture was last used by the renderer
int—public int Sandbox.Texture.Mips { get; set; }
Number of mip maps this texture has.
int—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.
int—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
bool—public int Sandbox.Texture.Width { get; set; }
Width of the texture in pixels.
int—No results match this filter.