Skip to content

FlexibleConfig #2668

Closed
Closed
@emanuele3d

Description

Introduction
The current rendering config is a relatively straightforward (if long) Java class with hardcoded video settings and their handling. This includes accessors (get*(), set*(), is*()), but also functionality to subscribe to the config to be notified of changes - to specific values or to the whole config.

This works, but is inflexible. Ideally engine and modules should be able to publish their configuration settings, as needed. Here is a couple of simple scenarios to ponder about.

Scenario 1 - ShadowMapNode
The ShadowMapNode is responsible for generating a ShadowMap used to cast shadows from the main light (sun/moon). This node wishes to publish two settings to the rendering config: a) a boolean defining its enabled/disabled state b) an integer defining the size of the (square) shadow map, in pixels.

Sceneario 2 - RealCameras module
The RealCameras module (so far a fictional one) introduces a number of realistic effects for the camera. Among them are lens flares. These are generated by a specialized node injected into the render graph on module startup. The node renders up to 20 lens flare elements, each having a set of parameters to play with, such as the texture asset used, the distance along the flare axis and the maximum opacity of the element. All these settings need to be published at runtime on the rendering config, for the user to play with.

FlexibleConfig and Setting classes
Enter the FlexibleConfig class, barely more than a <ResourceURN, Setting> map:

  • void add(Setting) - doesn't allow overwriting a stored setting object with a new one using the same ResourceUrn
  • boolean remove(ResourceUrn) - return true if the setting has been removed from the config. This happens only if the setting no longer has subscribers.
  • Setting get(ResourceUrn)
  • boolean has(ResourceUrn)

Individual Setting instances would contain:

  • an id - of type ResourceURN: the prefix is engine-set and is either "engine" or the fully qualified name of the module publishing the setting.
  • a stored value
  • a type - i.e. boolean, integer, float, double, one-selection/multiple-selection lists
  • a default value
  • a range - where applicable, i.e. integers, float, double
  • a list of choices - where applicable, i.e. list-type settings
  • a comma-separated list of ui-path
  • a human-readable name - translation friendly, to be displayed in the UI
  • a description - translation-friendly, potentially verbose, describing in plain language what a setting does.

Setting is largely immutable and contains the information from the FlexibleConfigs Features section. But it would have a setter methods for the stored value. It also provides subscribe()/unsubscribe() methods and a boolean hasSubscribers() method.

A few clarifications about the ui-path feature. A ui path would provide a hint to the ui on how to group settings together. I.e. all settings having a path /engine/shadows/shadowmap could be displayed together when the "shadows" list item is selected in the "engine" tab of the rendering config. It could be meaningful however for the same setting to be also be displayed in a separate tab/menu, hence the possibility for multiple ui paths. Ultimately however, it is up to the UI code to decide how to take advantage of them. I.e. a simpler UI might not provide "tabs" and might group settings between horizontal separators instead, potentially ignoring the deeper sections of a path.

How does this all sound? And notice that this issue specifically avoids dealing with the UI needed to display the content of a FlexibleConfig instance. That will be for a separate issue.

Metadata

Assignees

No one assigned

    Labels

    Topic: ArchitectureRequests, Issues and Changes related to software architecture, programming patterns, etc.Topic: RenderingRequests, Issues and Changes related to lighting, meshes, camera, etc.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions