Overview

TracerManager is a self-contained MonoBehaviour that handles the spawning, pooling, updating, and GPU rendering of tracer and bolt visual effects. It operates independently from the reticle rendering pipeline, so tracers never interfere with reticle draw calls or category transitions.

Rendering is performed by the TracerSDF shader via a CommandBuffer submitted through RenderPipelineManager.endCameraRendering. This hook is part of the SRP core package and works identically in both URP and HDRP — no pipeline-specific assembly references or renderer features are required.

The system supports three visual types:

TypeEnumDescription
BoltTracerType.BoltSci-fi energy bolt. Consistent appearance per shot, configurable perspective taper, glow, and end roundness.
StreamTracerType.StreamContinuous beam effect. Persists while firing with animated sine-wave displacement, noise modulation, and optional dual-beam rendering.
BulletTracerType.BulletRealistic tracer ammunition. Per-shot randomization across three sub-types (Streak, Bolt, Dot) with wobble, phosphorus-burn flicker, and sputtering.

All tracers are pooled in a fixed-size NativeArray<TracerData> (default 32, configurable up to 128) and uploaded to the GPU as a single StructuredBuffer each frame. Like the reticle system, the entire tracer pool renders in one draw call.

Origin Modes

The origin point — where tracers appear to fly in from — is controlled by TracerOriginMode:

ModeBehavior
FixedAll shots originate from a user-defined angle.
ScatterEach shot comes from a completely random angle.
RandomStartA random angle is chosen on mouse-down; all shots in that burst use it.
AnimatedOrigin rotates at a slow-to-medium speed with randomized direction changes.
TempestAggressive arcade-style rotation with random pauses and sharp direction reversals.

Tracer Data

The tracer system uses three complementary data structures:

TracerData (GPU Struct)

TracerData is a 172-byte blittable struct that represents a single active tracer on the GPU. It contains origin/target positions, progress, color, glow, perspective parameters, wobble fields (Bullet type), and beam wave fields (Stream type). The struct is uploaded to the TracerSDF shader via a StructuredBuffer.

Key fields include:

TracerConfig (Runtime Configuration)

TracerConfig is the serializable configuration class that defines a tracer's appearance and behavior. It includes all visual parameters (color, width, length, glow, feather, taper, perspective) along with type-specific settings for beam waves, dual-beam rendering, and randomization profiles. TracerManager holds a reference to the active TracerConfig and uses it to spawn new tracer instances.

The class also provides static factory presets: DefaultLaserBolt, PlasmaBolt, ExtremeBeam, DefaultBeam, ArcBeam, DualArc, LightningBeam, and PlasmaBeam.

TracerPresetData (Saveable Preset)

TracerPresetData wraps a TracerConfig with metadata for persistence: a GUID identifier, display name, author, description, timestamps, fire rate, and a flag indicating whether the preset is a read-only default. Presets are serialized to JSON and stored as .adstracer files.


Tracer Presets

Tracer presets provide a save/load system for tracer configurations. The preset pipeline has two layers:

Both synchronous and async I/O methods are available (Save/SaveAsync, Load/LoadAsync). The last-used preset is persisted via PlayerPrefs and restored automatically when TracerManager initializes.

Preset Sharing

Because presets are plain JSON files with a .adstracer extension, they can be shared between users or distributed with your game. Default presets are immutable — users must duplicate a default before editing it.


Tracer Editor

The tracer system includes a full visual editor for designing and previewing tracer effects in real time. It consists of two panels: the Tracer Editor for property editing and the Tracer Browser for preset management.

Tracer Editor Panel

The editor panel is a draggable floating modal (position persists in PlayerPrefs) that exposes all TracerConfig properties organized into collapsible sections. Changes are reflected immediately in the viewport — fire tracers while editing to see results in real time.

Appearance Controls

ControlDescription
Tracer TypeDropdown: Bolt, Stream, or Bullet. Changes which parameter sections are visible.
Bolt ColorPrimary fill color (opens the color picker).
Glow ColorOuter glow color (opens the color picker).
WidthThickness of the tracer body.
LengthHow long the tracer extends along its path.
Min WidthMinimum width when perspective taper is active. Prevents tracers from disappearing at distance.
Glow IntensityBrightness of the outer glow halo.
Glow SizeRadius of the glow falloff.
FeatherEdge softness of the tracer body.
TaperHow much the tracer narrows along its length (tail to head).
End RoundnessRounds the cap at each end of the tracer. 0 = flat, 1 = hemispherical.

Motion & Origin Controls

ControlDescription
Origin ModeDropdown: Fixed, Scatter, RandomStart, Animated, Tempest. Controls where tracers appear to originate from.
Fixed RotationAngle in degrees (visible only when Origin Mode = Fixed).
SpeedTravel speed of the tracer from origin to target.
Fire RateShots per second when auto-firing.
Perspective DepthHow much the tracer scales based on simulated depth.
Length PerspectiveHow much the tracer length compresses at perspective depth.

Beam Controls (Stream type only)

These controls appear in a collapsible Beam foldout when the tracer type is set to Stream:

ControlDescription
AmplitudeMagnitude of the sine-wave displacement perpendicular to the beam axis.
FrequencyNumber of wave cycles along the beam length.
SpeedHow fast the wave pattern scrolls along the beam.
Noise AmountPerlin noise displacement for organic, lightning-like variation.
Noise ScaleScale of the noise pattern. Smaller = finer detail.
ConvergeHow much the beam converges toward the target point.
Dual BeamToggle: renders a second beam with offset phase for a twin-beam look.
Phase OffsetWave phase offset between dual beams (visible when Dual Beam is on).

Bullet Randomization (Bullet type only)

These controls appear in a collapsible Sub-Type Mix foldout when the tracer type is set to Bullet:

ControlDescription
Sub-Type MixToggle to enable randomized bullet sub-types.
Streak / Bolt / Dot WeightsRelative probability of each sub-type per shot. Higher weight = more frequent.
Additional VarianceExtra randomization applied to width, length, and speed.
Wobble AmountLateral oscillation as the bullet travels.
Wobble FrequencySpeed of the wobble oscillation.
Sputter ChanceProbability (0–1) that a bullet "sputters" — flickering intermittently like a real phosphorus tracer burning out.
Flicker AmountIntensity variation of the brightness flicker effect.

Four randomization presets are available as starting points: Realistic, Streak Heavy, Dot Heavy, and No Mix.

Impact Burn

ControlDescription
Impact BurnToggle to enable a glowing impact point where the tracer hits.
Burn SizeRadius of the impact glow.
Burn IntensityBrightness of the impact glow.

Tracer Browser

The tracer browser is a separate floating panel that manages the preset library:

Double-clicking a preset in the list immediately loads and applies it. The browser is draggable with position persisted in PlayerPrefs.

Built-in Presets

RCE ships with 8 default tracer presets: Default Laser, Plasma Bolt, Extreme Beam, Beam, Arc Beam, Dual Arc, Lightning, and Plasma Stream. These are read-only — duplicate one to use it as a starting point for customization.


Pipeline Integration

The tracer renderer hooks into Unity's Scriptable Render Pipeline via RenderPipelineManager.endCameraRendering, a callback from the UnityEngine.Rendering namespace (SRP core). This approach has several advantages:

The TracerSDF shader evaluates each active tracer's SDF in the fragment shader, applying perspective taper, glow, beam-wave displacement, and impact burn effects. Inactive tracers (pooled slots with isActive = 0) are skipped via early-out.

Low Quality Mode

TracerManager.LowQualityMode disables glow calculations in the shader for better performance on lower-end hardware. The tracer shapes remain crisp; only the soft glow falloff is removed.

Master Toggle

TracerManager.TracersEnabled is a master on/off switch for the entire tracer system. When set to false, all active tracers are cleared, firing stops, and the Update/Render loops early-out. The setting persists in PlayerPrefs (ADS_TracersEnabled). In the editor, the toggle appears in the tracer toolbar; disabling it dims the toolbar controls to 35% opacity as a visual indicator.


Key Files

ComponentPath
TracerManagerAssets/RCE/Runtime/Tracers/TracerManager.cs
TracerDataAssets/RCE/Runtime/Tracers/TracerData.cs
TracerConfigAssets/RCE/Runtime/Tracers/TracerConfig.cs
TracerPresetDataAssets/RCE/Runtime/Tracers/TracerPresetData.cs
TracerSerializerAssets/RCE/Runtime/Tracers/TracerSerializer.cs
ITracerStorageAssets/RCE/Runtime/Tracers/ITracerStorage.cs (interface)
TracerStorageAssets/RCE/Runtime/Tracers/TracerStorage.cs
TracerSDF ShaderAssets/RCE/Runtime/Shaders/TracerSDF.shader
TracerTypeAssets/RCE/Runtime/Tracers/TracerType.cs
TracerOriginModeAssets/RCE/Runtime/Tracers/TracerOriginMode.cs
TracerRandomizationAssets/RCE/Runtime/Tracers/TracerRandomization.cs
TracerEditorControllerAssets/RCE/Runtime/UI/TracerEditorController.cs
TracerBrowserControllerAssets/RCE/Runtime/UI/TracerBrowserController.cs

What's Next