Scene

Scene format takes a form similar to mitsuba. A scene file describes the scene geometry, materials, and media. It also specifies emitters and sensor configuration, as well as the integrator that should be used to compute the light transport in the scene.

XML scene data sources

Scene files that use the XML data source look as follows:

<?xml version="1.0" encoding="utf-8"?>

<scene version="0.1.0" >

   <default name="spe" value="1024"/>
   <default name="res" value="1280"/>
   <default name="wavelength" value="1um"/>

   <integrator type="plt_path" >
      <string name="direction" value="forward"/>
   </integrator>

   <sensor type="virtual_plane" id="coverage">
      <transform name="to_world">
         <lookat origin="0m, 0m, 0m" target="0m, 1m, 0m"/>
      </transform>
      <quantity name="extent" value="1000m, 750m" />

      <integer name="samples" value="$spe" />
      <film type="array" >
         <integer name="width" value="$res" />
         <integer name="height" value="($res*.75)" />

         <response type="monochromatic">
            <spectrum type="discrete" wavelength="$wavelength" />
         </response>
      </film>
   </sensor>

   <emitter type="point">
      <point name="position" value="0m, 100m, 0m"/>
      <spectrum name="radiant_intensity" type="discrete" wavelength="$wavelength" value="1" />
   </emitter>

   <bsdf type="surface_spm" id="mat-itu_marble">
      <spectrum name="IOR" ITU="marble" />
      <spectrum name="extIOR" constant="1" />
   </bsdf>

   <shape type="ply" id="object">
      <path name="filename" value="[path]"/>
      <quantity name="scale" value="1cm" />
      <ref id="mat-itu_marble" name="bsdf"/>
   </shape>

</scene>

The scene file starts with setting default values for runtime-configurable defines. Then, it setups the used integrator, sensor, an emitter, and a geometric object (a shape, with its geometrical data read from a PLY file).

The sensor is a virtual plane sensor that is used for signal coverage simulations, its extent and orientation is defined via the to_world transformation and extent quantity. The sensor’s film element defines its resolution (as an array of virtual pixels) and sensitivity function.

Note that wave_tracer uses physical units for all physical quantities, with one exception: scale values of spectrum elements are context-dependent; in the example above, the units of the radiant_intensity spectrum are implied to be spectral radiant intensity, i.e. Watts per steradians per millimetre.

The object’s material describes a smooth interface, with the exterior medium having an index-or-refraction (IOR) of 1, and internal medium with IOR spectrum defined by ITU “marble” material (defined by Recommendation ITU-R P.2040-2).

wave_tracer can parse math expressions. Values that contain math expressions must appear within parentheses, for example see the “height” node of the film element.

The XML schema documentation of scene elements is a work in progress. Sample scenes are available in the /scenes directory.



class scene_t

Holds all scene data, and provides emitter and spectral sampling facilities.

Public Functions

scene_t(std::string id, const wt_context_t &ctx, std::shared_ptr<integrator::integrator_t> integrator, std::vector<std::shared_ptr<sensor::sensor_t>> &&sensors, std::shared_ptr<sampler::sampler_t> sampler, std::vector<std::shared_ptr<emitter::emitter_t>> emitters, std::vector<std::shared_ptr<shape_t>> shapes)
inline const auto &get_id() const
inline const auto &integrator() const
inline const auto &sensors() const
inline auto &sampler() const noexcept
inline const auto &shapes() const
inline const auto &emitters() const
inline const auto &get_world_aabb() const
inline emitter_wavenumber_sample_t sample_emitter_and_spectrum(const sensor::sensor_t *sensor) const noexcept

Given a sensor, samples an emitter from all scene emitters, as well as a wavenumber from the sampled emitter’s spectrum (integrated over the sensor’s spectrum).

Parameters:

sensor – used sensor

inline emitter_beam_wavenumber_sample_t sample_emitter_and_spectrum_and_source_beam(const sensor::sensor_t *sensor) const noexcept

Given a sensor, samples an emitter from all scene emitters, as well as a wavenumber from the sampled emitter’s spectrum (integrated over the sensor’s spectrum), then sources a beam from the sampled emitter. Does NOT divide by the emitter or wavelength sampling density.

Parameters:

sensor – used sensor

inline emitter_direct_sample_t sample_emitter_direct(sampler::sampler_t &sampler, const sensor::sensor_t *sensor, const pqvec3_t &wp, const wavenumber_t k) const noexcept

Samples a direct connection from a world position to a scene emitter for a given sensor. Divides by the sampled emitter’s sampling probability mass. Does NOT divide by the wavelength sampling density.

Parameters:
  • sampler – sampler to use (overriding the scene’s sampler)

  • sensor – used sensor

  • wp – world position from which direct sampling is applied

  • k – wavenumber

inline emitter_direct_sample_t sample_emitter_direct(const sensor::sensor_t *sensor, const pqvec3_t &wp, const wavenumber_t k) const noexcept

Samples a direct connection from a world position to a scene emitter for a given sensor. Divides by the sampled emitter’s sampling probability mass. Does NOT divide by the wavelength sampling density.

Parameters:
  • sensor – used sensor

  • wp – world position from which direct sampling is applied

  • k – wavenumber

inline emitter_direct_sample_pdf_t pdf_emitter_direct(const sensor::sensor_t *sensor, const emitter::emitter_t *emitter, const pqvec3_t &wp, const ray_t &sample, const intersection_surface_t *sampled_surface = nullptr) const noexcept

Probability density of a sampled direct connection from an emitter to a world position.

Parameters:
  • sensor – used sensor

  • emitter – sampled emitter

  • wp – world position from which direct sampling was applied

  • sample – sampled emitter phase-space position (ray)

  • sampled_surface – sampled surface for emitter samples that seat on a surface (required for some emitters)

inline wavenumber_density_t sum_spectral_pdf_for_all_emitters(const sensor::sensor_t *sensor, const wavenumber_t k) const noexcept

Computes the spectral probability density for the given wavenumber k summed over all scene emitters: Useful for spectral MIS.

Parameters:
  • sensor – used sensor

  • k – sampled wavenumber

inline f_t pdf_emitter(const sensor::sensor_t *sensor, const emitter::emitter_t *emitter) const noexcept

Probability mass of sampling the emitter.

Parameters:
  • sensor – used sensor

  • emitter – sampled emitter

inline wavenumber_density_t pdf_spectral_sample(const sensor::sensor_t *sensor, const emitter::emitter_t *emitter, const wavenumber_t k) const noexcept

Probability density of a wavenumber sample, given an emitter and a sensor.

Parameters:
  • sensor – used sensor

  • emitter – used emitter

  • k – sampled wavenumber

inline wavenumber_density_t pdf_emitter_and_spectral_sample(const sensor::sensor_t *sensor, const emitter::emitter_t *emitter, const wavenumber_t k) const noexcept

Joint probability density of a wavenumber & emitter sample pair, given a sensor.

Parameters:
  • sensor – used sensor

  • emitter – sampled emitter

  • k – wavenumber

scene::element::info_t description() const

Public Static Attributes

static constexpr std::size_t max_supported_sensors = 1

This defines the max count of sensors that the scene is willing to handle. WIP: machinery for multi-sensor rendering is working on scene side. However, currently multi-sensor rendering does not always makes sense, and we might want dedicated integrator support.


class scene_renderer_t

Scene renderer, handles rendering loop.

Public Types

using interrupt_t = std::unique_ptr<scene::interrupts::interrupt_t>

Public Functions

scene_renderer_t(const scene_t &scene, const wt_context_t &ctx, const ads::ads_t &ads, std::launch launch_mode = std::launch::async, scene::render_opts_t render_opts = {})

Queues rendering. Rendering is launched based on the launch policy launch_policy: asynchronously or deferred. With deferred policy, rendering starts only when get() is called.

inline auto get()

Retrieves rendering results. This is a blocking operation.

inline void wait()

Waits for rendering to complete. This is a blocking operation.

template<typename Rep, typename Period>
inline auto wait_for(const std::chrono::duration<Rep, Period> &wait_duration)

Waits for rendering to complete. This is a blocking operation. When wait_duration is 0, no blocking occurs and rendering state is returned.

Parameters:

wait_duration – maximal time to wait.

Returns:

std::future_status

inline void interrupt(interrupt_t intr)

Queues an interrupt. See wt::scene::interrupts. (Thread safe).

scene::rendering_status_t rendering_status() const noexcept

Queries the rendering status. Thread safe, returned results might be stale.


class scene_element_t

Generic scene element.

Subclassed by wt::bsdf::bsdf_t, wt::emitter::emitter_t, wt::fraunhofer::fsd_sampler::fsd_sampler_t, wt::integrator::integrator_t, wt::sampler::sampler_t, wt::sensor::mask::mask_t, wt::sensor::response::response_t, wt::sensor::response::tonemap_t, wt::sensor::sensor_t, wt::shape_t, wt::spectrum::spectrum_t, wt::surface_profile::surface_profile_t, wt::texture::complex_t, wt::texture::quantity_t< Q >, wt::texture::texture_t

Public Functions

inline scene_element_t(std::string id) noexcept
scene_element_t(scene_element_t&&) noexcept = default
inline scene_element_t(const scene_element_t &o) noexcept
virtual ~scene_element_t() noexcept = default
inline const std::string &get_id() const noexcept
virtual element::info_t description() const = 0

Public Static Functions

static std::shared_ptr<scene_element_t> load(std::string id, scene::loader::loader_t *loader, const scene::loader::node_t &node, const wt::wt_context_t &context)

Friends

friend class wt::scene::loader::loader_t