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.
Related Guides
Broader workflow and conceptual references connected to this API.
GPU instancing is an optimization where multiple instances of the same model with the same material can be drawn in a single draw call. This is a big optimization when rendering things that appear many times in a scene such as foliage.
S&box uses a scene system to create games. We feel this is the easiest system for people to pick up, while still being powerful.
You can create different types of shaders in s&box through code or the ShaderGraph.
Errors will happen. Here's how to make a useful error report.
Sampler states control how textures are sampled in shaders, how they're filtered and addressed.
| | Minimum | Recommended | |:--|:--|:--| | OS | Windows 10 (64-bit) | Windows 11 (64-bit) | | Processor | Core i5-7500 / Ryzen 5 1600 | Core i7-9700K / Ryzen 7 3700 | | Memory | 8 GB RAM | 16 GB RAM | | Graphics | GTX 1050 / RX 570 - 4GB VRAM | RTX 2060 / RX 6600XT - 8GB VRAM | | Network | Broadband Internet connection | Broadband Internet connection | | Storage | 12 GB available space | 50 GB available space | | VR Support | OpenXR | OpenXR |
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: 20alignment: 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 drawtransform: Transform to draw the model atattributes: 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 drawbuffer: The GPU buffer containing the DrawIndirectArgumentsbufferOffset: Optional offset in the GPU buffer Default: 0attributes: 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: nullborderWidth: Default: nullborderColor: 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: 0initialMip: Default: 0numMips: 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: DepthTexturerenderAttributes: 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: nullcolor: Default: nullmaterial: 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
No results match this filter.
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.
No results match this filter.
Metadata
| Field | Value |
|---|---|
| Namespace | Sandbox |
| Type | class |
| Assembly | Sandbox.Engine |
| Doc ID | T:Sandbox.Graphics |