Skip to content

Engine → Renderer

components.h

Component data for the ECS. Plain reflected structs; this module never includes ecs. The engine's renderer_subsystem registers the mesh renderer, sprite, camera, light, environment, render_settings and post_process components. Its extraction system maps the first five 1:1 onto the render_scene structs, resolving asset references through renderer::find_*, and resolves the two rendering-settings components through the pure functions below (choose_scene_settings, resolve_scene_settings, make_camera_view), which any other caller with ECS access can use; the editor and the bindings call make_camera_view.

Structs

File Description
camera_component
environment_component
light_component
mesh_renderer_component
post_process_component The camera layer of the rendering settings, for the entity of a camera_component (56 bytes): each override flag replaces that whole group for the camera's view (resolve_camera_settings, make_camera_view). Shadows are shared by every view and are not overridable here.
render_settings_component The scene layer of the rendering settings, for any entity (100 bytes). Each override flag makes this component a candidate for that whole group, all three anti-aliasing fields included under the one overrideAntiAliasing; per group, the highest priority among the candidates wins (choose_scene_settings). A component with no flag set takes part in no group. The anti-aliasing group's winner renders every view (render_scene::antiAliasing) unless renderer::set_anti_aliasing holds an override (render_settings.h).
resolved_render_settings Rendering settings with where each group came from, indexed by render_settings_group.
scene_settings_candidate One entity carrying a render_settings_component, as the caller gathered it. The caller leaves out disabled and inactive entities.
scene_settings_choice The winner of every group, indexed by render_settings_group.
sprite_component

Enumerations

render_settings_source

enum class render_settings_source : u8 {
    PROJECT = 0,
    SCENE = 1,
    CAMERA = 2
};

The layer a resolved group came from.

Constants

Name Type Value Description
CAMERA_COMPONENT_TYPE_NAME inline constexpr std::string_view "conjure.renderer.camera"
ENVIRONMENT_COMPONENT_TYPE_NAME inline constexpr std::string_view "conjure.renderer.environment"
LIGHT_COMPONENT_TYPE_NAME inline constexpr std::string_view "conjure.renderer.light"
MESH_RENDERER_COMPONENT_TYPE_NAME inline constexpr std::string_view "conjure.renderer.mesh_renderer"
NO_SETTINGS_CANDIDATE inline constexpr u32 0xFFFFFFFFu
POST_PROCESS_COMPONENT_TYPE_NAME inline constexpr std::string_view "conjure.renderer.post_process"
RENDER_SETTINGS_COMPONENT_TYPE_NAME inline constexpr std::string_view "conjure.renderer.render_settings"
SETTINGS_GROUP_COUNT inline constexpr usize static_cast<usize>(render_settings_group::COUNT)
SPRITE_COMPONENT_TYPE_NAME inline constexpr std::string_view "conjure.renderer.sprite"

Macros

CONJURE_REFLECT_ENUM

CONJURE_REFLECT_ENUM(conjure::renderer::projection_type, "conjure.renderer.projection_type", PERSPECTIVE, ORTHOGRAPHIC)

CONJURE_REFLECT_STRUCT

CONJURE_REFLECT_STRUCT(conjure::renderer::camera, "conjure.renderer.camera_data", CONJURE_FIELD(projection), CONJURE_FIELD(verticalFovRadians, .min = 0.01, .max = 3.1, .unit = conjure::core::reflect::field_unit::RADIANS), CONJURE_FIELD(orthographicHeight, .min = 0.001), CONJURE_FIELD(nearPlane, .min = 0.0001), CONJURE_FIELD(farPlane, .min = 0.001))

Functions

Public

choose_scene_settings

[[nodiscard]] CONJURE_API scene_settings_choice choose_scene_settings(
    std::span<const scene_settings_candidate> candidates) noexcept;

The scene winner rule, in one pass over the candidates for every group: per group only the candidates whose override flag for it is set compete, the highest priority wins, a tie goes to the lowest guid, with candidates without a guid after every candidate that has one, and then to the lowest entity index. A group is ambiguous when two or more of its candidates share its top priority. A group without candidates has no winner (NO_SETTINGS_CANDIDATE). Winners are indices into candidates.

make_camera_view

[[nodiscard]] CONJURE_API render_view make_camera_view(
    const camera_component &camera,
    const math::mat4 &worldFromCamera,
    render_target_id target = {},
    const post_process_component *overrides = nullptr) noexcept;

The view a camera component at a world matrix renders: the view matrix is the rigid inverse of the matrix (its scale is dropped, so a scaled parent does not warp the projection), with the camera's position, camera data and layer mask, NO_POST_PROCESS unless postProcess, into target (invalid = the swapchain). With overrides (the camera entity's post_process_component), each group whose override flag is set is copied into the view and named in settingsOverride; the other groups keep their defaults and are not named. The engine's extraction builds the scene cameras' views with it and the editor's screenshots through a scene camera do too.

register_components

[[nodiscard]] CONJURE_API core::result<void> register_components(
    core::reflect::type_registry &registry);

Registers the enums, the nested camera, light and settings structs (the four groups, and render_settings as conjure.renderer.render_settings_data) and the seven components with a reflection registry, nested types first. Registering twice is harmless (ALREADY_EXISTS is skipped); any other registry error is returned.

resolve_camera_settings

[[nodiscard]] CONJURE_API resolved_render_settings resolve_camera_settings(
    const resolved_render_settings &scene,
    const camera_component &camera,
    const post_process_component *overrides) noexcept;

The scene resolution with the camera's override groups applied (source CAMERA; overrides may be null) and postProcessDisabled set when the camera turns post-processing off. The settings stay the configured values in that case, so a script can edit the look it would get. The shadows and anti-aliasing groups have no camera layer and stay the scene's (a camera without post-processing still renders with MSAA, never with FXAA). sceneWinner and ambiguous stay the scene layer's.

resolve_scene_settings

[[nodiscard]] CONJURE_API resolved_render_settings resolve_scene_settings(
    const render_settings &projectDefaults,
    std::span<const scene_settings_candidate> candidates,
    const scene_settings_choice &choice) noexcept;

The project defaults with each group that has a winner replaced by the winner's group (source SCENE), with the winners and the ambiguity copied from choice. A winner that is not a candidate with a component asserts and the group keeps the project's values. The values are not sanitised.