Skip to content

Built in Schedulers, Kernels and Render Targets

Stefan Zellmann edited this page Aug 4, 2017 · 3 revisions

Content of this page: Brief and detailed descriptions of how to configure and use built-in schedulers and kernels with the corresponding render targets.

Note that the current version of Visionaray is an early preview. At this stage, the framework, including the API, are likely to undergo frequent changes.

Visionaray can be used by developers in different ways:

  • Use built-in schedulers and kernels, and extend them with custom ray / object intersections or custom materials.
  • Write custom kernels to implement new ray tracing-based algorithms.
  • Write custom schedulers to target new architectures with existing kernels.

The following section gives an overview of Visionaray's built-in schedulers and kernels.

Schedulers Overview

Visionaray comes with a set of built-in schedulers to target a variety of modern hardware architectures:

  • simple_sched: a most simple, single-threaded scheduler that is compatible with single rays or ray packets.
  • tiled_sched: a multi-threaded scheduler targeting x86-compatible CPUs. Compatible with single rays or packets. Uses a task queue to assign work (display tiles) to threads for load balancing. Thread synchronization is implemented with atomic counters.
  • cuda_sched: a scheduler targeting CUDA compatible NVIDIA GPUs. Compatible with single rays.

Kernels Overview

Visionaray also implements some most basic algorithms via built-in kernels. Such a list can of course never be exhaustive. It is rather meant for developers to quickly generate an image without having to worry much about the rendering algorithm. Built-in kernels can provide a basis to implement more elaborate algorithms in custom kernels. For rudimentary purposes, they might however be sufficient.

  • simple::kernel: Implements primary ray casting with closest_hit ray traversal. Evaluates a local shading model that is encoded in the material that is assigned to the surface that was hit.
  • whitted::kernel: Implements recursive ray tracing with reflections as described in Whi80. At each point of intersection a local shading model is evaluated. A shadow ray is generated to evaluate occlusion, specular or mirror materials incur a reflective bounce.
  • pathtracing::kernel: Implements the path tracing algorithm that was first described in Kaj86. Global illumination is calculated by sampling "BRDFs", functions that are assigned to surfaces that determine the direction into which light is reflected.

Using Built-In Schedulers

Built-in schedulers provide a function frame() with the following interface:

void Scheduler::frame(Kernel k, Params p, unsigned frame_num = 0);

k is a C-style function, C++ functor, or C++ lambda function that is callable with a ray as first parameter. p is an instance of a parameter struct with data members as described below. frame_num is a counter that can be used for rendering with progressive refinement as described in the section on Pixel Samplers. If a pixel sampler that supports progressive refinement was chosen, the user is responsible of incrementing the frame_num counter each time a new refinement frame is rendered, and of resetting the counter to 0 when a viewing configuration was chosen.

INFO: A viewing configuration contains all information that is necessary to generate primary rays from. Most generally, a viewing configuration must contain enough information to deduce how many primary rays are generated, to determine the origin position and direction vector for each primary ray, and to deduce at which memory position in the render target the ray tracing result should be stored. The schedulers coming with Visionaray all imply a correspondence between image pixels and primary rays, which is however in general not necessary with custom schedulers. When it comes to the built-in schedulers, a viewing configuration update is typically initiated by moving the virtual camera, by resizing the rendering canvas, or by changing intrinsic camera parameters such as the focal length.

Setting up parameters for built-in schedulers

Schedulers are parameterized with data to obtain the viewing configuration from, and with a render_target that provides storage and custom functionality for the ray tracing result. The built-in schedulers can derive the viewing configuration from two types of input:

  • Camera matrices (projection and viewing transform).
  • A virtual camera set up using the built-in type visionaray::pinhole_camera.

In addition to that, a mutable reference to a render target must be provided as a scheduler parameter.

The utility function make_sched_params() can be used to generate a scheduler struct and provides the following basic interface.

//---------------------------------------------------------

// Get primary rays from camera matrices:

Params make_sched_params(
        visionaray::mat4   view_matrix,
        visionaray::mat4   proj_matrix,
        RenderTarget&      rendertarget
        );


//---------------------------------------------------------

// Get primary rays from visionaray::pinhole_camera:

Params make_sched_params(
        visionaray::pinhole_camera cam,
        RenderTarget&              rendertarget
        );

Params is a generic struct containing the parameters. Its type is not easily deducible by the developer.

NOTE: Deducing the viewing configuration from a visionaray::pinhole_camera, which implements a (perspective) pinhole camera model, can result in slightly better rendering performance because primary rays can be interpolated. Providing matrix transforms for perspective projection ("projection matrix") and for the viewing transform ("view matrix") incurs a slight overhead because two matrix multiplications must be performed for each primary ray. Being able to obtain the viewing configuration from two matrices is however more flexible because the projection type is not limited to the perspective model.

Optional scheduler parameters

We are still working on this, so please check back soon.

simple_sched

We are still working on this, so please check back soon.

tiled_sched

We are still working on this, so please check back soon.

cuda_sched

We are still working on this, so please check back soon.

Render targets for use with schedulers

We are still working on this, so please check back soon.

Using Built-In Kernels

We are still working on this, so please check back soon.

Setting up parameters for built-in kernels

We are still working on this, so please check back soon.

Clone this wiki locally