AR rendering¶
Rendering system¶
The rendering system renders the main AR view and multiple sub-viewports during different phases. The system consists of the following key components:
Renderer.h
: Defines the core logic of the rendering pipeline and manages essential attributes.Viewport.h
: Handles the sub-frame buffer. The renderer callsActivate()
to switch the buffer for rendering.GLObject.h
: Helps GO manage OpenGL resources, allocating memory and buffering data for rendering. Each GO may contain one or multiple GLObjects stored in a list. By invoking Draw(), the content will be rendered to the currently active frame buffer.
Tip
GOText
does not contains any GLObject
, and its Draw()
function does nothing. Instead, the rendering of GOText
is handled separately through TextRenderer.h
. Since we want to make the text always facing the screen instead of floating in the 3D space, a special projection method and shader program is required. As a result, the rendering of text is performed separately after all the other GO
s are rendered.
Rendering pipeline¶
The Renderer::OnRender()
function is executed after all layers are processed. It is the entry point of the rendering pipeline, which calls the corresponding functions to render different views depend on the current status.
Sub-view Rendering¶
While in the mapping phase or performing camera calibration, the main view is blocked, so it will not be rendered. Instead, the corresponding sub-view will be rendered through RenderMappingView()
or RenderCamCalibView()
.
Main-view Rendering¶
During the fabrication phase, there're two viewports that needed to be rendered: The AR view and the global 3D view. The AR view combines captured images with virtual objects, such as CAD models and feedback graphics, to provide clear and intuitive instructions. The global 3D view serves as an interface for navigating through the entire scene, enabling users to easily inspect different components. The rendering of the two viewports are handled by two separate functions:
RenderMainView()
renders the main AR view by calculating the projection matrix using the estimated position fromLayerSLAM
and overlays all geometry from theGORegistry
onto the captured image.RenderGlobalView()
switches the frame buffer to the 3D viewport and renders the geometry with a projection based on the user's navigation.