s&box docs

public static abstract sealed class Sandbox.Graphics

Used to render to the screen using your Graphics Card, or whatever you kids are using in your crazy future computers. Whatever it is I'm sure it isn't fungible and everyone has free money and no-one has to ever work.

Broader workflow and conceptual references connected to this API.

Methods

Showing 38 methods

public static void Blit(Sandbox.Material material, Sandbox.RenderAttributes attributes = null)

Draw a screen space quad using the passed material. Your material should be using a screenspace shader so it will actually render to the screen and not in worldspace at 0,0,0

Parameters

  • attributes: Default: null

public static Sandbox.Rect DrawIcon(Sandbox.Rect rect, string iconName, Color color, float fontSize = 20, Sandbox.TextFlag alignment = 132)

Calls DrawText with "Material Icons" font. You can get a list of icons here https://fonts.google.com/icons?selected=Material+Icons

Parameters

  • fontSize: Default: 20
  • alignment: Default: 132

public static void DrawModel(Sandbox.Model model, Transform transform, Sandbox.RenderAttributes attributes = null)

Draws a single model at the given Transform immediately.

Parameters

  • model: The model to draw
  • transform: Transform to draw the model at
  • attributes: Optional attributes to apply only for this draw call Default: null

public static void DrawModelInstancedIndirect(Sandbox.Model model, Sandbox.GpuBuffer buffer, int bufferOffset = 0, Sandbox.RenderAttributes attributes = null)

Draws multiple instances of a model using GPU instancing with the number of instances being provided by indirect draw arguments. Use `SV_InstanceID` semantic in shaders to access the rendered instance.

Parameters

  • model: The model to draw
  • buffer: The GPU buffer containing the DrawIndirectArguments
  • bufferOffset: Optional offset in the GPU buffer Default: 0
  • attributes: Optional attributes to apply only for this draw call Default: null

public static void DrawQuad(Sandbox.Rect rect, Sandbox.Material material, Color color, Sandbox.RenderAttributes attributes = null)

Draw a quad in screenspace

Parameters

  • attributes: Default: null

public static void DrawRoundedRectangle(Sandbox.Rect rect, Color color, Vector4 cornerRadius = null, Vector4 borderWidth = null, Color borderColor = null)

Draw a rounded rectangle, with optional border, in Material.UI.Box

Parameters

  • cornerRadius: Default: null
  • borderWidth: Default: null
  • borderColor: Default: null

public static void FlushGPU()

Forces the GPU to flush all pending commands and wait for completion. Useful when you need to ensure GPU work is finished before proceeding. Can be called outside of a render block.

public static void GenerateMipMaps(Sandbox.Texture texture, Sandbox.Graphics.DownsampleMethod downsampleMethod = 0, int initialMip = 0, int numMips = -1)

Generate the mip maps for this texture. Obviously the texture needs to support mip maps.

Parameters

  • downsampleMethod: Default: 0
  • initialMip: Default: 0
  • numMips: Default: -1

public static Sandbox.RenderTarget GrabDepthTexture(string targetName = DepthTexture, Sandbox.RenderAttributes renderAttributes = null)

Grabs the current depth texture and stores it in targetName on renderAttributes.

Parameters

  • targetName: Default: DepthTexture
  • renderAttributes: Default: null

public static void Render(Sandbox.SceneObject obj, System.Nullable`1<Transform> transform = null, System.Nullable`1<Color> color = null, Sandbox.Material material = null)

Parameters

  • transform: Default: null
  • color: Default: null
  • material: Default: null

public static bool RenderToTexture(Sandbox.SceneCamera camera, Sandbox.Texture target)Obsolete

Render this camera to the specified texture target

Obsolete: Use CameraComponent.RenderToTexture

public static void SetupLighting(Sandbox.SceneObject obj, Sandbox.RenderAttributes targetAttributes = null)

Setup the lighting attributes for this current object. Place them in the targetAttributes

Parameters

  • targetAttributes: Default: null

Properties

Showing 10 properties

public static Sandbox.RenderAttributes Sandbox.Graphics.Attributes { get; set; }

Access to the current render context's attributes. These will be used to set attributes in materials/shaders. This is cleared at the end of the render block.

public static Vector3 Sandbox.Graphics.CameraPosition { get; set; }

The camera position of the currently rendering view

public static Rotation Sandbox.Graphics.CameraRotation { get; set; }

The camera rotation of the currently rendering view

public static Transform Sandbox.Graphics.CameraTransform { get; set; }

The camera transform of the currently rendering view

public static float Sandbox.Graphics.FieldOfView { get; set; }

The field of view of the currently rendering camera view, in degrees.

public static Sandbox.Frustum Sandbox.Graphics.Frustum { get; set; }

The frustum of the currently rendering camera view.

public static bool Sandbox.Graphics.IsActive { get; set; }

If true then we're currently rendering and you are safe to use the contents of this class

public static Sandbox.SceneLayerType Sandbox.Graphics.LayerType { get; set; }

The current layer type. This is useful to tell whether you're meant to be drawing opaque, transparent or shadow. You mainly don't need to think about this, but when you do, it's here.

public static Sandbox.RenderTarget Sandbox.Graphics.RenderTarget { get; set; }

Get or set the current render target. Setting this will bind the render target and change the viewport to match it.

public static Sandbox.Rect Sandbox.Graphics.Viewport { get; set; }

In pixel size, where are we rendering to?

Metadata

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

On this page

Methodspublic static System.Void Blit(Sandbox.Material material, Sandbox.RenderAttributes attributes = null)public static System.Void Clear(Color color, System.Boolean clearColor = True, System.Boolean clearDepth = True, System.Boolean clearStencil = True)public static System.Void Clear(System.Boolean clearColor = True, System.Boolean clearDepth = True)public static System.Void CopyTexture(Sandbox.Texture srcTexture, Sandbox.Texture dstTexture, System.Int32 srcMipSlice = 0, System.Int32 srcArraySlice = 0, System.Int32 srcMipLevels = 1, System.Int32 dstMipSlice = 0, System.Int32 dstArraySlice = 0, System.Int32 dstMipLevels = 1)public static System.Void CopyTexture(Sandbox.Texture srcTexture, Sandbox.Texture dstTexture, System.Int32 srcMipSlice = 0, System.Int32 srcArraySlice = 0, System.Int32 dstMipSlice = 0, System.Int32 dstArraySlice = 0)public static System.Void CopyTexture(Sandbox.Texture srcTexture, Sandbox.Texture dstTexture)public static System.Void Draw(System.Collections.Generic.List`1<Sandbox.Vertex> vertices, System.Int32 vertCount, Sandbox.Material material, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static System.Void Draw(System.Span`1<Sandbox.Vertex> vertices, System.Int32 vertCount, Sandbox.Material material, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static System.Void Draw(System.Span`1<Sandbox.Vertex> vertices, System.Int32 vertCount, System.Span`1<System.UInt16> indices, System.Int32 indexCount, Sandbox.Material material, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static System.Void Draw(Sandbox.GpuBuffer`1<T> vertexBuffer, Sandbox.GpuBuffer indexBuffer, Sandbox.Material material, System.Int32 startIndex = 0, System.Int32 indexCount = 0, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static System.Void Draw(Sandbox.GpuBuffer`1<T> vertexBuffer, Sandbox.Material material, System.Int32 startVertex = 0, System.Int32 vertexCount = 0, Sandbox.RenderAttributes attributes = null, Sandbox.Graphics.PrimitiveType primitiveType = 5)public static Sandbox.Rect DrawIcon(Sandbox.Rect rect, System.String iconName, Color color, System.Single fontSize = 20, Sandbox.TextFlag alignment = 132)public static System.Void DrawModel(Sandbox.Model model, Transform transform, Sandbox.RenderAttributes attributes = null)public static System.Void DrawModelInstanced(Sandbox.Model model, System.Int32 count, Sandbox.RenderAttributes attributes = null)public static System.Void DrawModelInstanced(Sandbox.Model model, System.Span`1<Transform> transforms, Sandbox.RenderAttributes attributes = null)public static System.Void DrawModelInstancedIndirect(Sandbox.Model model, Sandbox.GpuBuffer buffer, System.Int32 bufferOffset = 0, Sandbox.RenderAttributes attributes = null)public static System.Void DrawQuad(Sandbox.Rect rect, Sandbox.Material material, Color color, Sandbox.RenderAttributes attributes = null)public static System.Void DrawRoundedRectangle(Sandbox.Rect rect, Color color, Vector4 cornerRadius = null, Vector4 borderWidth = null, Color borderColor = null)public static Sandbox.Rect DrawText(Sandbox.Rect position, Sandbox.TextRendering.Scope scope, Sandbox.TextFlag flags = 132)public static Sandbox.Rect DrawText(Sandbox.Rect position, System.String text, Color color, System.String fontFamily = Roboto, System.Single fontSize = 20, System.Single fontWeight = 450, Sandbox.TextFlag flags = 132)public static Sandbox.Rect DrawText(Vector2 position, System.String text, Color color, System.String fontFamily = Roboto, System.Single fontSize = 20, System.Single fontWeight = 450)public static System.Void FlushGPU()public static System.Void GenerateMipMaps(Sandbox.Texture texture, Sandbox.Graphics.DownsampleMethod downsampleMethod = 0, System.Int32 initialMip = 0, System.Int32 numMips = -1)public static Sandbox.RenderTarget GrabDepthTexture(System.String targetName = DepthTexture, Sandbox.RenderAttributes renderAttributes = null)public static Sandbox.RenderTarget GrabFrameTexture(System.String targetName = FrameTexture, Sandbox.RenderAttributes renderAttributes = null, Sandbox.Graphics.DownsampleMethod downsampleMethod = -1, System.Int32 maxMips = 0)public static System.Void GrabFrameTexture(System.String targetName, Sandbox.RenderAttributes renderAttributes, System.Boolean withMips)public static Sandbox.Rect MeasureText(Sandbox.Rect position, Sandbox.TextRendering.Scope scope, Sandbox.TextFlag flags = 132)public static Sandbox.Rect MeasureText(Sandbox.Rect position, System.String text, System.String fontFamily = Roboto, System.Single fontSize = 20, System.Single fontWeight = 450, Sandbox.TextFlag flags = 132)public static System.Void Render(Sandbox.SceneObject obj, System.Nullable`1<Transform> transform = null, System.Nullable`1<Color> color = null, Sandbox.Material material = null)public static System.Boolean RenderToTexture(Sandbox.SceneCamera camera, Sandbox.Texture target)public static System.Void ResourceBarrierTransition(Sandbox.GpuBuffer buffer, Sandbox.Rendering.ResourceState before, Sandbox.Rendering.ResourceState after)public static System.Void ResourceBarrierTransition(Sandbox.GpuBuffer buffer, Sandbox.Rendering.ResourceState state)public static System.Void ResourceBarrierTransition(Sandbox.Texture texture, Sandbox.Rendering.ResourceState state, System.Int32 mip = -1)public static System.Void ResourceBarrierTransition(Sandbox.GpuBuffer`1<T> buffer, Sandbox.Rendering.ResourceState before, Sandbox.Rendering.ResourceState after)public static System.Void ResourceBarrierTransition(Sandbox.GpuBuffer`1<T> buffer, Sandbox.Rendering.ResourceState state)public static System.Void SetupLighting(Sandbox.SceneObject obj, Sandbox.RenderAttributes targetAttributes = null)public static System.Void UavBarrier(Sandbox.GpuBuffer buffer)public static System.Void UavBarrier(Sandbox.Texture texture)Propertiespublic static Sandbox.RenderAttributes Sandbox.Graphics.Attributes { get; set; }public static Vector3 Sandbox.Graphics.CameraPosition { get; set; }public static Rotation Sandbox.Graphics.CameraRotation { get; set; }public static Transform Sandbox.Graphics.CameraTransform { get; set; }public static System.Single Sandbox.Graphics.FieldOfView { get; set; }public static Sandbox.Frustum Sandbox.Graphics.Frustum { get; set; }public static System.Boolean Sandbox.Graphics.IsActive { get; set; }public static Sandbox.SceneLayerType Sandbox.Graphics.LayerType { get; set; }public static Sandbox.RenderTarget Sandbox.Graphics.RenderTarget { get; set; }public static Sandbox.Rect Sandbox.Graphics.Viewport { get; set; }Metadata