Graphics static class provides direct access to the GPU rendering pipeline. You use it inside component render callbacks (OnRenderObject, PostProcess, etc.) where a render context is active. For GPU compute work outside the render pipeline, use ComputeShader and GpuBuffer.
Graphics static class
State properties
true when a render scope is active and Graphics methods are safe to call.The current render viewport in pixel coordinates. Get or set to change the rendering region.
The current render context’s attribute set. Values set here are forwarded to the active material/shader for the duration of the current render scope.
The world-space transform of the camera rendering the current view.
World-space position of the rendering camera. Shorthand for
CameraTransform.Position.Horizontal field of view of the current camera, in degrees.
The current rendering layer (opaque, translucent, shadow, etc.). Use this to branch behaviour inside multi-pass shaders.
Get or set the active render target. Setting this binds the target and updates the viewport to match.
Drawing methods
Graphics.Draw
Draw a mesh from a vertex buffer with an optional index buffer.Vertex data to draw.
Number of vertices to use from the span.
The material (shader) to render with.
Attribute overrides for this draw. Defaults to
Graphics.Attributes.Primitive topology. Default is
Triangles.Graphics.DrawQuad
Draw a 2D screen-space quad.Screen rectangle in pixels.
Material to render.
Tint color applied to the quad.
Graphics.Blit
Draw a full-screen quad using a screen-space material. Useful for post-processing passes.A screen-space material. The shader receives the current frame color via
FrameTexture if you call GrabFrameTexture first.Graphics.Render
Render aSceneObject with an optional transform, color, or material override.
Graphics.Clear
Clear the current render target.Texture helpers
Graphics.GrabFrameTexture
Copies the current viewport’s color buffer into a render target and sets it as an attribute.Attribute name to bind the grabbed texture to. Default is
"FrameTexture".Target attribute set. Defaults to
Graphics.Attributes.Optional mip-chain generation for blur effects.
Graphics.GrabDepthTexture
Copies the current depth buffer into a render target.Graphics.CopyTexture
Copy pixel data between two GPU textures. Source and destination must have the same format and size.Primitive types
| Value | Description |
|---|---|
PrimitiveType.Triangles | Standard triangle list. Default. |
PrimitiveType.TriangleStrip | Triangle strip — efficient for quads. |
PrimitiveType.Lines | Line list — pairs of vertices form segments. |
PrimitiveType.LineStrip | Connected line strip. |
PrimitiveType.Points | Point sprites. |
RenderAttributes
RenderAttributes is a key-value store that passes data to shaders. Access the current scope’s attributes via Graphics.Attributes, or create a standalone instance for use with compute shaders.
In HLSL, bind an attribute by name:
Set methods
AllSet overloads accept a string or StringToken as the key.
Supported value types:
bool, int, float, double, Vector2, Vector3, Vector4, Angles, Matrix, string, Texture, GpuBuffer, SamplerState.SetData — constant buffer upload
Upload an unmanaged struct directly into a constant buffer slot.
T must be a blittable POD type.Upload an array of structs into a constant buffer.
Get methods
Retrieve a texture attribute by name.
Retrieve a float attribute.
Retrieve a
Vector3 attribute.Retrieve a bool attribute.
Retrieve an int attribute.
Combo values
Shader combos are compile-time switches that select between shader permutations.Clear
ComputeShader
ComputeShader wraps a compute material compiled from an HLSL shader file. Load it once, set attributes on Attributes, then dispatch.
Dispatch
Number of threads to dispatch in X. The engine divides this by the shader’s declared thread group size.
Number of threads to dispatch in Y.
Number of threads to dispatch in Z.
DispatchIndirect
Dispatch thread counts stored in a GPU buffer instead of supplying them from the CPU. Use this for GPU-driven rendering where particle counts are determined on the GPU.A buffer containing dispatch arguments. Must have
UsageFlags.IndirectDrawArguments and element size of 12 bytes (uint3).Index into the buffer of the argument entry to use. Default is
0.DispatchWithAttributes
Dispatch with a customRenderAttributes instance, bypassing ComputeShader.Attributes.
GpuBuffer
GpuBuffer<T> is a typed GPU-accessible buffer. Use it to upload data to compute shaders or read results back to the CPU.
Constructor
Number of elements the buffer holds.
Controls buffer semantics. Default is
Structured.Optional label visible in GPU debuggers.
UsageFlags
| Flag | HLSL type | Description |
|---|---|---|
Structured | StructuredBuffer<T> / RWStructuredBuffer<T> | General-purpose read/write structured buffer. Default. |
Append | AppendStructuredBuffer<T> | Append-consume buffer with hidden atomic counter. |
ByteAddress | ByteAddressBuffer | Raw 32-bit aligned byte access. |
Index | Index buffer | Vertex index buffer (element size must be 2 or 4 bytes). |
IndirectDrawArguments | — | Stores draw/dispatch arguments for indirect calls. |
Properties
Number of elements the buffer was created with.
Size in bytes of a single element.
The usage flags the buffer was created with.
SetData
Upload data from the CPU to the GPU. Synchronous.GetData
Download data from the GPU to the CPU. Synchronous — blocks until the GPU finishes.GetDataAsync
Download data asynchronously. The callback receives aReadOnlySpan<T> that is only valid during the callback.
Clear
Fill the entire buffer with a repeateduint32 value (default 0).
Dispose
GpuBuffer implements IDisposable. Always dispose when you are done to release GPU memory.