-
Notifications
You must be signed in to change notification settings - Fork 87
RenderCores
The lowest layer in the Lighthouse 2 platform is the render core. A core (there are typically multiple available) is responsible for actual rendering, often via a low-level ray tracing library such as Optix, Optix Prime, Embree or Radeon-Rays. A render core implements the following API (only partially shown here, for clarity):
void SetTarget( GLTexture* target, const uint spp );
The core is expected to render directly to an OpenGL texture, which must be supplied before the first render call. The second parameter is for path tracers, which may want to size buffers based on the samples per pixel count.
void SetTextures( const CoreTexDesc* tex, const int textureCount );
void SetMaterials( CoreMaterial* mat, const CoreMaterialEx* matEx, const int materialCount );
void SetLights( ... );
void SetSkyData( const float3* pixels, const uint width, const uint height );
void SetGeometry( ... );
void SetInstance( const int instanceIdx, const int modelIdx, const mat4& transform );
\
The RenderSystem will use the above methods to update the core-side copy of the scene. The RenderSystem is responsible for doing this efficiently, i.e.: not every frame. The render core is expected to copy the data that is passed: host-side data may change at any time after the Set...
calls.
void UpdateToplevel();
Low-level ray tracing APIs such as Optix and Embree maintain an acceleration structure for rapid ray-scene intersection. The UpdateTopLevel
method updates this structure.
void Render( const ViewPyramid& view, ... );
The render function starts the actual rendering. During rendering the render target may not be in use elsewhere.
void Setting( const char* name, float value );
Custom settings are supplied to the core using a string identifier. This way cores can ignore unknown settings (e.g. settings intended for another core or set of cores).
It is important to note that none of the above methods will be called from the user application: only the RenderSystem will ever call render core methods. This ensures e.g. that UpdateTopLevel
is called at most once per frame (when the scene changed), as part of the SynchronizeSceneData
process. Knowing about a function like UpdateTopLevel
is thus only relevant for core developers.
Adding a core
There can be many reasons for adding a new core:
- it may be desirable to add a DirectX renderer for rapid scene previews;
- an existing path tracing core may be cloned and equipped with alternative materials;
- you want to do some experiments on a cloned core and keep the original.
Any core that implements the full render core dll is valid, even if it doesn't render anything, or perhaps just ASCII-art.
In many cases it will be useful to start with a cloned core. The repository contains a 'doc' folder, in which you can find a document that describes the steps to clone a core. This is an easy process: the document is a single page.