rafx

Adding Features

Features represent “things” that can be drawn. For example, the could be separate features for meshes, sprites, cloth, debug draw, imgui, etc.

Declare the Feature

You may either implement RenderFeature or use this macro

use rafx::render_feature_mod_prelude::*;
rafx::declare_render_feature!(Debug3DRenderFeature, DEBUG_3D_FEATURE_INDEX);

When using rafx-renderer, you should implement RenderFeaturePlugin.

Register the Feature

// Create the registry
let render_registry = rafx::nodes::RenderRegistryBuilder::default()
    .register_feature::<SpriteRenderFeature>()
    .register_feature::<MeshRenderFeature>();

Features that have been registered are assign a unique index. For example, to get the feature index of MeshRenderFeature call MeshRenderFeature::feature_index().

If using a RenderFeaturePlugin, the call to register_feature should go into configure_render_registry. This will be called after the RenderFeaturePlugin is registered with the Renderer. A RenderFeaturePlugin can be registered with the Renderer by calling add_render_feature on the RendererBuilder.

Define the Frame Packet and Submit Packet

Each RenderFeature defines two data structures of packed arrays – the RenderFeatureFramePacket and the RenderFeatureSubmitPacket.

See the demo for examples of features implementing the FramePacket and SubmitPacket.

Implement the RenderFeatureExtractJob, RenderFeaturePrepareJob, and RenderFeatureWriteJob

See the demo for examples of features implementing the RenderFeature jobs.