Class TextModeGridCapture
Renders a TextMode grid into a render texture where every cell is an exact whole number of pixels, for effects that process the grid as an image, such as the CRT.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public static class TextModeGridCapture
Remarks
The capture records into a command buffer the caller owns, so it works in every render
pipeline: execute the buffer with Graphics.ExecuteCommandBuffer, typically from
LateUpdate after the view has uploaded its cells. It reads the view's own GPU cell
buffer through ITextModeRenderSource and shades cells with the same shader
code as the on-screen views.
The target is cleared first and the cells are blended over the clear color, because cell
backgrounds may be transparent (the terminal leaves them so on purpose). In a Linear
color space project, give the target an sRGB format such as
GraphicsFormat.R8G8B8A8_SRGB so that sampling it returns linear light. Row 0 of the
grid lands at the top of the texture (v = 1) on every graphics API.
Methods
ComputeTargetSize(int, int, Vector2Int)
Computes the size in pixels of a capture target for a grid.
Declaration
public static Vector2Int ComputeTargetSize(int columns, int rows, Vector2Int cellPixels)
Parameters
| Type | Name | Description |
|---|---|---|
| int | columns | Number of grid columns. |
| int | rows | Number of grid rows. |
| Vector2Int | cellPixels | Size of one cell in target pixels. |
Returns
| Type | Description |
|---|---|
| Vector2Int | The target size, |
Record(CommandBuffer, ITextModeRenderSource, RenderTexture, Color)
Records the commands that render a view's grid into a target texture.
Declaration
public static bool Record(CommandBuffer cmd, ITextModeRenderSource source, RenderTexture target, Color clearColor)
Parameters
| Type | Name | Description |
|---|---|---|
| CommandBuffer | cmd | The command buffer to record into. The render target it leaves set is the capture target. |
| ITextModeRenderSource | source | The view whose grid is rendered. |
| RenderTexture | target | The texture to render into. The full grid fills it exactly, so each cell is
|
| Color | clearColor | Color the target is cleared to before the cells are drawn, given as a regular (sRGB) color like any Inspector color. It shows through transparent cell backgrounds. |
Returns
| Type | Description |
|---|---|
| bool | True if commands were recorded; false if the view or the shader is not ready. |
ReleaseResources()
Releases the shared capture material. It is recreated on the next capture.
Declaration
public static void ReleaseResources()