Struct Cell
GPU-optimized cell data structure for the text mode grid.
Each cell represents a single character position with glyph, colors, and attributes.
The struct is 32 bytes (GPU cache-line friendly) and maps directly to a
StructuredBuffer<Cell> in the TextModeCell shader.
Inherited Members
Namespace: Scylla.TextMode
Assembly: ScyllaTextMode.dll
Syntax
public struct Cell
Fields
AtlasRectPacked
Packed atlas glyph rect dimensions as two uint16 texel values. Lower 16 bits: glyphRect.width, Upper 16 bits: glyphRect.height. Stored as integer texels for exact precision. The shader adds 2*padding to get the full SDF-padded rect dimensions. Pre-stamped by GlyphAtlasCache when the codepoint changes.
Declaration
public uint AtlasRectPacked
Field Value
| Type | Description |
|---|---|
| uint |
AtlasUVPacked
Packed atlas glyph rect origin as two uint16 texel coordinates. Lower 16 bits: glyphRect.x, Upper 16 bits: glyphRect.y. Stored as integer texels for exact precision (eliminates half-float ±0.5 texel error). The shader subtracts SDF padding to get the atlas UV origin. Pre-stamped by GlyphAtlasCache when the codepoint changes.
Declaration
public uint AtlasUVPacked
Field Value
| Type | Description |
|---|---|
| uint |
Attributes
Cell attributes bitfield. See CellAttributes for flag definitions. Bits 0-15: style flags, bits 24-31: atlas texture index.
Declaration
public uint Attributes
Field Value
| Type | Description |
|---|---|
| uint |
BGColor
Background color packed as RGBA8 (R in lowest byte, A in highest).
Declaration
public uint BGColor
Field Value
| Type | Description |
|---|---|
| uint |
Codepoint
Unicode codepoint of the character displayed in this cell. A value of 0 represents an empty/space cell.
Declaration
public uint Codepoint
Field Value
| Type | Description |
|---|---|
| uint |
FGColor
Foreground color packed as RGBA8 (R in lowest byte, A in highest).
Declaration
public uint FGColor
Field Value
| Type | Description |
|---|---|
| uint |
MetricsPacked
Packed glyph bearings as two half-precision floats for shader-side positioning. Lower 16 bits: horizontal bearing X (half16, font metric units). Upper 16 bits: horizontal bearing Y (half16, font metric units). Pre-stamped by GlyphAtlasCache when the codepoint changes.
Declaration
public uint MetricsPacked
Field Value
| Type | Description |
|---|---|
| uint |
MetricsWHPacked
Packed glyph metrics width and height as two half-precision floats. Lower 16 bits: metrics.width (half16, font metric units). Upper 16 bits: metrics.height (half16, font metric units). These are the logical glyph dimensions from the font's metrics table, used for correct glyph sizing in the shader (matching TMP's approach). Pre-stamped by GlyphAtlasCache when the codepoint changes.
Declaration
public uint MetricsWHPacked
Field Value
| Type | Description |
|---|---|
| uint |
SIZE_IN_BYTES
Size of the Cell struct in bytes. Used for GraphicsBuffer stride.
Declaration
public const int SIZE_IN_BYTES = 32
Field Value
| Type | Description |
|---|---|
| int |
Methods
CreateDefault(Color32, Color32)
Creates a default empty cell with the specified colors.
Declaration
public static Cell CreateDefault(Color32 fg, Color32 bg)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | fg | Foreground color. |
| Color32 | bg | Background color. |
Returns
| Type | Description |
|---|---|
| Cell | A new cell with space character and specified colors. |
PackColor(Color32)
Packs a UnityEngine.Color32 into a uint as RGBA8.
Declaration
public static uint PackColor(Color32 color)
Parameters
| Type | Name | Description |
|---|---|---|
| Color32 | color | The color to pack. |
Returns
| Type | Description |
|---|---|
| uint | The packed RGBA8 value. |
PackHalf2(float, float)
Packs two float values into a uint as two half-precision floats.
Declaration
public static uint PackHalf2(float x, float y)
Parameters
| Type | Name | Description |
|---|---|---|
| float | x | First float value. |
| float | y | Second float value. |
Returns
| Type | Description |
|---|---|
| uint | The packed half-float pair. |
PackUint16Pair(int, int)
Packs two unsigned 16-bit integer values into a single uint. Used for atlas texel coordinates that require exact integer precision.
Declaration
public static uint PackUint16Pair(int x, int y)
Parameters
| Type | Name | Description |
|---|---|---|
| int | x | First value (stored in lower 16 bits, clamped to 0-65535). |
| int | y | Second value (stored in upper 16 bits, clamped to 0-65535). |
Returns
| Type | Description |
|---|---|
| uint | The packed uint16 pair. |
UnpackColor(uint)
Unpacks a uint RGBA8 value into a UnityEngine.Color32.
Declaration
public static Color32 UnpackColor(uint packed)
Parameters
| Type | Name | Description |
|---|---|---|
| uint | packed | The packed RGBA8 value. |
Returns
| Type | Description |
|---|---|
| Color32 | The unpacked color. |