Skip to content

Game.PhotoModeRenderSystem

Assembly:
Namespace: Game.Rendering

Type: public class PhotoModeRenderSystem

Base: GameSystemBase

Summary:
PhotoModeRenderSystem manages the in-game photo mode rendering settings and UI bindings. It creates and controls a dedicated HD Volume used by the cinematic/photo camera, exposes numerous photo/lens/environment properties (via PhotoModeProperty and OverridableLensProperty wrappers), initializes presets (sensor/aperture presets), and synchronizes overridden lens values with camera controllers when a save is loaded or when photo mode is enabled. It also responds to camera blending to drive volume weight for smooth transitions between gameplay and cinematic view.


Fields

  • private static readonly string[] kApertureFormatNames
    Array of human-readable sensor/aperture format names used for sensor presets (e.g. "8mm", "35mm Full Aperture", "70mm IMAX").

  • private static readonly Vector2[] kApertureFormatValues
    Array of Vector2 values (width, height in mm) corresponding to kApertureFormatNames for preset sensor sizes.

  • private const string kSensorTypePreset
    String constant "SensorTypePreset" (used as preset id/name).

  • private const string kCameraApertureShape
    String constant "CameraApertureShape".

  • private const string kCameraBody
    String constant "CameraBody".

  • private const string kCameraLens
    String constant "CameraLens".

  • private const string kCamera
    String constant "Camera".

  • private const string kColorGrading
    String constant "Color".

  • private const string kLens
    String constant "Lens".

  • private const string kWeather
    String constant "Weather".

  • private const string kEnvironment
    String constant "Environment".

  • private Volume m_CameraControlVolume
    HD/Render Volume created to hold and control all camera/photo-mode related Volume components. Its weight is driven by camera blending and photo mode active state.

  • private ColorAdjustments m_ColorAdjustments
    Volume component for color adjustments (post exposure, contrast, saturation, etc.).

  • private WhiteBalance m_WhiteBalance
    Volume component for white balance settings.

  • private PaniniProjection m_PaniniProjection
    Volume component for Panini projection settings.

  • private Vignette m_Vignette
    Volume component controlling vignette effects.

  • private FilmGrain m_FilmGrain
    Volume component controlling film grain.

  • private ShadowsMidtonesHighlights m_ShadowsMidtonesHighlights
    Volume component for shadows/midtones/highlights adjustments.

  • private Bloom m_Bloom
    Volume component for bloom properties.

  • private MotionBlur m_MotionBlur
    Volume component for motion blur settings.

  • private DepthOfField m_DepthOfField
    Volume component for depth of field settings.

  • private CloudLayer m_DistanceClouds
    Volume/component for distant cloud layer properties.

  • private VolumetricClouds m_VolumetricClouds
    Volume component for volumetric clouds settings.

  • private Fog m_Fog
    Volume component for fog settings.

  • private PhysicallyBasedSky m_Sky
    Volume component for sky-related properties (air density, tint, etc.).

  • private CameraUpdateSystem m_CameraUpdateSystem
    Reference to the CameraUpdateSystem used to access and modify game camera controllers and to register OverridableLensProperty callbacks.

  • private PlanetarySystem m_PlanetarySystem
    Reference to the planetary/time system used for overriding time of day.

  • private ClimateSystem m_ClimateSystem
    Reference to climate/weather system (unused directly in the shown code, but initialized).

  • private SimulationSystem m_SimulationSystem
    Reference to the simulation system used here to control simulation speed override.

  • private OverridableLensProperty<float> focalLength
    Wrapper for a lens property controlling focal length (mapped to the camera controller FieldOfView via provided converters).

  • private OverridableLensProperty<Vector2> sensorSize
    Wrapper for sensor (film) size used to compute focal lengths and field of view.

  • private OverridableLensProperty<float> aperture
    Wrapper for physical aperture setting.

  • private OverridableLensProperty<int> iso
    Wrapper for ISO (sensitivity).

  • private OverridableLensProperty<float> shutterSpeed
    Wrapper for shutter speed.

  • private OverridableLensProperty<Camera.GateFitMode> gateFitMode
    Wrapper for the camera gate fit mode (how the sensor fits the frame).

  • private OverridableLensProperty<int> bladeCount
    Wrapper for number of aperture blades (affects bokeh).

  • private OverridableLensProperty<Vector2> curvature
    Wrapper for lens curvature parameter.

  • private OverridableLensProperty<float> barrelClipping
    Wrapper for barrel clipping/distortion.

  • private OverridableLensProperty<float> anamorphism
    Wrapper for anamorphic factor.

  • private OverridableLensProperty<float> focusDistance
    Wrapper controlling depth-of-field focus distance.

  • private OverridableLensProperty<Vector2> lensShift
    Wrapper for lens shift (image plane translation).

  • private bool m_Active
    Indicates whether photo mode is currently active (used to force volume weight = 1 when active).

  • private List<PhotoModeUIPreset> m_Presets
    List of UI presets available in photo mode (sensor presets and any added presets).

Properties

  • public OrderedDictionary<string, PhotoModeProperty> photoModeProperties { get; private set }
    Dictionary of all registered photo mode properties keyed by id. Properties are used to build UI groups and to drive in-game settings. The setter is private; use AddProperty to register properties.

  • public IReadOnlyCollection<PhotoModeUIPreset> presets => m_Presets
    Read-only view of the internal presets list; populated in InitializeProperties and via AddPreset.

Constructors

  • public PhotoModeRenderSystem()
    Default constructor (marked with [Preserve] attribute in source). Construction initializes the GameSystemBase; heavy initialization happens in OnCreate.

Methods

  • protected override void OnCreate()
    Sets up the PhotoModeRenderSystem. Key actions:
  • Disables the system initially (base.Enabled = false).
  • Retrieves CameraUpdateSystem, SimulationSystem, PlanetarySystem, and ClimateSystem from the world.
  • Creates a dedicated Volume ("CinematicControlVolume") and adds/gets many Volume components used by photo mode (ColorAdjustments, WhiteBalance, Vignette, Bloom, MotionBlur, DepthOfField, clouds, sky, fog, film grain, etc.).
  • Configures defaults (e.g. procedural vignette mode) and sets initial volume weight to 0.
  • Creates OverridableLensProperty instances that bind to the active camera controllers (for focal length, sensor size, aperture, ISO, shutter speed, gate fit, blade count, curvature, anamorphism, focus distance, lensShift, etc.). The wrappers allow the UI to override or revert lens values and to sync them on load.
  • Calls InitializeProperties to build the catalog of PhotoModeProperty entries and presets.

  • protected override void OnGameLoaded(Context serializationContext)
    Called after a save/load. Syncs OverridableLensProperty values so saved/overridden lens values are applied to the current camera controllers.

  • public void Enable(bool enabled)
    Enables or disables photo mode behavior. When enabled, sets m_Active and toggles base.Enabled. When disabled, the OnUpdate logic will allow the volume to be set to 0 and disable the system.

  • protected override void OnUpdate()
    Executed each frame while the system is enabled. It queries CameraUpdateSystem.GetBlendWeight to obtain camera blend direction/weight (CameraBlend and weight float) and adjusts the m_CameraControlVolume.weight accordingly:

  • When blending ToCinematicCamera, set weight = blend weight.
  • When blending FromCinematicCamera, set weight = 1 - blend weight.
  • When no blend (None), if m_Active then weight = 1 else weight = 0 and base.Enabled = false (system disables itself if not active).

  • protected override void OnDestroy()
    Destroys the cinematic control Volume and calls base.OnDestroy. Ensures cleanup of created resources.

  • public void AddProperty(PhotoModeProperty property)
    Registers a PhotoModeProperty into the photoModeProperties dictionary by its id. If null is passed it does nothing. If the id already exists, logs a warning and does not overwrite.

  • public void AddProperty(PhotoModeProperty[] property)
    Convenience overload to add an array of properties (iterates and calls single AddProperty).

  • private void InitializeProperties()
    Builds and registers the complete set of PhotoModeProperty entries used by the photo mode UI. Highlights:

  • Initializes photoModeProperties dictionary.
  • Adds grouped titles and binding-backed properties using PhotoModeUtils.BindProperty / BindPropertyW helpers for many Volume components and lens properties.
  • Adds custom property implementations (e.g. Camera collision toggles, Roll/dutch control, Time of Day override, Simulation Speed).
  • Creates sensor-type presets using PhotoModeUtils.CreatePreset with kApertureFormatNames/kApertureFormatValues and registers them.
  • Defines local helper functions to convert between FieldOfView and FocalLength respecting sensorSize so that UI can present focal length while underlying camera uses field of view.

  • private void AddPreset(PhotoModeUIPreset preset)
    Adds a PhotoModeUIPreset to the internal m_Presets list.

  • public void DisableAllCameraProperties()
    Iterates over all registered photoModeProperties and invokes each property's setEnabled(false) (if setEnabled is assigned). This disables all toggleable properties (e.g. time override) at once.

Usage Example

// Acquire the system from the world (example in a mod context):
var photoSystem = world.GetOrCreateSystemManaged<Game.Rendering.PhotoModeRenderSystem>();

// Enable photo mode functionality (this will allow the volume to be applied)
photoSystem.Enable(true);

// Access available presets
foreach (var preset in photoSystem.presets) {
    Debug.Log($"Preset: {preset.name}");
}

// Disable all camera-related toggles managed by the system
photoSystem.DisableAllCameraProperties();

Notes and tips for modders: - Use AddProperty to register custom PhotoModeProperty entries so they appear in the photo mode UI and get saved/loaded together with other properties. - Many of the volume components are HD/RenderPipeline-specific (Unity HDRP). The system relies on VolumeHelper utility methods to create/get components. When modifying or reading values, respect Volume component IsActive() checks where provided by the bindings. - OverridableLensProperty wraps camera controller lens values so that UI overrides can be synced and persisted. Call Sync() (as OnGameLoaded does) after load to apply saved overrides to active camera controllers.