Class TextModeCRTMonitor
Shows a world-space TextMode view on a CRT monitor in a 3D scene: the tube simulation renders into a texture, and a screen mesh shows it as emitted light, with the phosphor mask laid out on the glass.
Inherited Members
Namespace: Scylla.TextMode.CRT
Assembly: ScyllaTextMode.CRT.dll
Syntax
[ExecuteAlways]
[DisallowMultipleComponent]
[DefaultExecutionOrder(1000)]
[AddComponentMenu("Scylla/TextMode/TextMode CRT Monitor")]
public sealed class TextModeCRTMonitor : MonoBehaviour
Remarks
Add it to the GameObject that holds a TextModeView and assign the renderer of the monitor's screen, for example a quad or a curved mesh in a monitor model. Without a screen renderer the monitor creates a quad as a child, sized and placed like the view's grid. The view keeps its grid and stops drawing itself.
A screen without a material gets the Scylla TextMode CRT Monitor material, which works in URP and the Built-in pipeline. It shows the picture unlit, lays the mask out in the picture's texels and fades it with distance, so it does not shimmer at a distance or an angle, and adds a little glass reflection. For HDRP, or to use the picture in a lit material of your own, give the screen that material and set TextureProperty to the texture it should receive, such as an emission map; OutputTexture holds the picture as well. Such a material shows no mask.
The settings work as on TextModeCRTDriver, and Tube switches the monitor on and off. Pointer input on the screen is not supported.
The monitor does its work in LateUpdate with a high execution order. Each frame it
captures the grid, records the raster, signal, afterglow, glow and burn-in passes into a
command buffer, writes the picture into OutputTexture, generates its mip
levels and hands the texture and the mask layout to the screen through a property block,
so the screen's material asset is never modified. The picture is rendered at the height
given by Resolution. A screen that no camera saw in the previous frame is
skipped and keeps its last picture; the afterglow starts fresh when it becomes visible
again. The beam simulator is not used on a monitor.
OnDisable gives drawing back to the view, hides the screen and releases the capture
and picture textures, the command buffer and the image renderer. OnDestroy also
destroys a quad the monitor created and the monitor material. All of this runs on the main
thread. The monitor needs a TextModeView on the same GameObject; without one
it logs a warning once and does nothing until a view is added.
The following example puts a view on a monitor model and switches the monitor off and on.
var monitor = view.gameObject.AddComponent<TextModeCRTMonitor>();
monitor.Screen = monitorModel.GetComponent<Renderer>();
monitor.Preset = myPreset;
monitor.Resolution = 768;
monitor.Tube.PowerOff();
monitor.Tube.PowerOn();
Properties
HDRHeadroom
Gets the display's headroom for the last frame, peak luminance over paper white, including a manual override. 1 on a standard display.
Declaration
public float HDRHeadroom { get; }
Property Value
| Type | Description |
|---|---|
| float |
HDRMaskActive
Gets whether HDR mask mode was active for the last frame: the settings ask for it and the display shows HDR with enough headroom. The screen is scene geometry, drawn before tonemapping, so light above paper white reaches the display.
Declaration
public bool HDRMaskActive { get; }
Property Value
| Type | Description |
|---|---|
| bool |
IsActive
Gets whether the monitor is currently showing the view.
Declaration
public bool IsActive { get; }
Property Value
| Type | Description |
|---|---|
| bool |
OutputTexture
Gets the picture the monitor renders, or null before the first frame. Use it in a material of your own, for example as the emission map of a lit screen.
Declaration
public RenderTexture OutputTexture { get; }
Property Value
| Type | Description |
|---|---|
| RenderTexture |
Preset
Gets or sets the preset. Assigning a preset copies its settings into Settings.
Declaration
public TextModeCRTPreset Preset { get; set; }
Property Value
| Type | Description |
|---|---|
| TextModeCRTPreset |
QualityTier
Gets or sets the quality tier. Setting it also stops following the project defaults.
Declaration
public CRTQualityTier QualityTier { get; set; }
Property Value
| Type | Description |
|---|---|
| CRTQualityTier |
Resolution
Gets or sets the height of the rendered picture in texels.
Declaration
public int Resolution { get; set; }
Property Value
| Type | Description |
|---|---|
| int |
Screen
Gets or sets the renderer of the monitor's screen. Null creates a quad on the next frame. The screen that is replaced stops showing the picture, and a quad the monitor created for itself is destroyed.
Declaration
public Renderer Screen { get; set; }
Property Value
| Type | Description |
|---|---|
| Renderer |
Settings
Gets the settings this monitor uses, before the readability clamp. Changes take effect on the next frame.
Declaration
public TextModeCRTSettings Settings { get; }
Property Value
| Type | Description |
|---|---|
| TextModeCRTSettings |
TextureProperty
Gets or sets the texture property of the screen's material that receives the picture.
Declaration
public string TextureProperty { get; set; }
Property Value
| Type | Description |
|---|---|
| string |
Tube
Gets or sets the tube: switch it on and off, degauss it, or clear its burn-in. Assign another to share one tube with a driver or a camera effect; null is ignored.
Declaration
public TextModeCRTTube Tube { get; set; }
Property Value
| Type | Description |
|---|---|
| TextModeCRTTube |
Methods
ApplyPreset(TextModeCRTPreset)
Assigns a preset and copies its settings into Settings, replacing any changes made since.
Declaration
public void ApplyPreset(TextModeCRTPreset preset)
Parameters
| Type | Name | Description |
|---|---|---|
| TextModeCRTPreset | preset | The preset to use. Null keeps the current settings and clears the preset. |
ResetToPreset()
Copies the preset's settings again, discarding changes made since it was applied.
Declaration
public void ResetToPreset()