Render module

To use the entire render module, add the following line to your project file:

``require engine.render_core`` or ``require engine.core``

The render engine used in EdenSpark features an advanced multidraw indirect rendering pipeline with GPU culling for all geometry rendering. The render system gathers all nodes with Mesh ( LODSelector ) and sorts them by their material and mesh. After that, only the modified data is submitted to the GPU, which then performs GPU culling and gathers draw calls.

You should have at least one active Camera in your scene to render it.

Note

If you have more than one active camera in your scene, the scene will be rendered for all of them. Be careful and turn off the cameras you don’t need.

We provide a set of components to help you set up rendering in your scene:

  • ShadowSettings: Shadows are based on the cascaded shadow maps technique.

  • AmbientSettings: Ambient lights can be set either with a constant color or with a sky color.

  • Tonemap: Global color grading.

  • Sky: Allows you to set a material for the sky (e.g., a skybox, a panorama image, or a procedural shader).

  • AntiAliasing: Anti-aliasing settings (FXAA, MSAA).

To use it:

let renderSettings = create_render_settings("RenderSettings")
// AntiAliasing and Tonemap are disabled by default

get_component(renderSettings) $(var settings : ShadowSettings?) {
    // set up the shadows
}

get_component(renderSettings) $(var settings : AmbientSettings?) {
    // set up the ambient color
}

get_component(renderSettings) $(var settings : Tonemap?) {
    // set up the tonemap
}

get_component(renderSettings) $(var settings : AntiAliasing?) {
    // set up anti-aliasing
}

get_component(renderSettings) $(var settings : Sky?) {
    // set up the sky
}

To add lighting to your scenes, you can use the following light sources:

  • DirectionLight: Represents a directional light, or sunlight; it emits light in a single direction.

  • SpotLight: Represents a spotlight source; it emits light in a cone shape.

  • PointLight: Represents a point source of light; it emits light in all directions within a certain radius.

Functions

create_base_render_settings(name: string = "render_settings"): NodeId

Creates base render settings, without any components attached (e.g. shadows, ambient light, skybox, anti-aliasing, tonemap etc.) It is useful for creating custom render settings

Arguments:
  • name : string

create_render_settings(name: string = "render_settings"): NodeId

Creates render settings. Render settings allow you to modify the render pipeline (e.g. shadows, ambient light, skybox, anti-aliasing, tonemap etc.)

Arguments:
  • name : string - the name of the render settings

set_panorama(node: NodeId; texture: TextureId)

Set a panorama texture as the skybox

Arguments:
  • node : NodeId - the render settings node of the scene, the result of the create_render_settings() call

  • texture : TextureId - the panorama texture, it should be 2D texture with width to height ratio equal to 2

set_skybox(node: NodeId; cubemap: TextureId)

Set a skybox texture as the skybox. See CubeMap (SkyBox).

Arguments:
  • node : NodeId - the render settings node of the scene, the result of the create_render_settings() call

  • cubemap : TextureId - the skybox texture, it should be cubemap texture.