XML data source

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.

Sample XML scene file

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

 1<?xml version="1.0" encoding="utf-8"?>
 2
 3<scene version="0.2.0" >
 4
 5   <%set spe = 1024 %>
 6   <%set res = 1280 %>
 7   <%set wavelength = 1um %>
 8
 9   <integrator type="plt_path" >
10      <string name="direction" value="forward"/>
11   </integrator>
12
13   <sensor type="virtual_plane" id="coverage">
14      <transform name="to_world">
15         <lookat origin="0m, 0m, 0m" target="0m, 1m, 0m"/>
16      </transform>
17      <quantity name="extent" value="1000m, 750m" />
18
19      <integer name="samples" value="$spe" />
20      <film type="array" >
21         <integer name="width" value="$res" />
22         <integer name="height" value="($res*.75)" />
23
24         <response type="monochromatic">
25            <spectrum type="discrete" wavelength="$wavelength" />
26         </response>
27      </film>
28   </sensor>
29
30   <emitter type="point">
31      <point name="position" value="0m, 100m, 0m"/>
32      <spectrum name="radiant_intensity" type="discrete" wavelength="$wavelength" value="1" />
33   </emitter>
34
35   <bsdf type="surface_spm" id="mat-itu_marble">
36      <spectrum name="IOR" ITU="marble" />
37      <spectrum name="extIOR" constant="1" />
38   </bsdf>
39
40   <shape type="ply" id="object">
41      <path name="filename" value="...path..."/>
42      <quantity name="scale" value="1cm" />
43      <ref id="mat-itu_marble" name="bsdf"/>
44   </shape>
45
46</scene>

The scene file starts with setting default values for runtime-configurable variables. Tags of the form <% … %> are preprocessor directives. Preprocessor variables’ values are pasted using $variable, and their values can be overridden by the user, for example from the Command line interface.

Then, the scene file setups the used integrator, sensor, an emitter, as well as a single geometric object (a shape, with its triangular mesh 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.

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).

The XML parser includes a preprocessor: see XML preprocessor for more information.

wave_tracer expects physical units to be specified for all physical quantities that are read from a scene file, with a few exceptions: the spectra of emitters and sensors have implied units that depend on the sensor or emitter type. For example, in the example above the emission spectrum of the point emitter (line 32) quantifies spectral radiant intensity with units of Watts per solid angle per wavenumber.

Math expressions can be parsed, see Math expressions. Values that contain math expressions must appear within parentheses, for example see the “height” node of the film element (line 22) in the sample XML scene file above.


class xml_loader_t : public wt::scene::loader::loader_t

Scene loader from an XML data source.

Param name:

scene name

Param ctx:

context

Param xml:

XML data stream

Param user_defines:

user-defined variables (supplied externally from the scene file, e.g., via CLI arguments)

Param callbacks:

loading progress callbacks

Public Functions

xml_loader_t(std::string name, const wt_context_t &ctx, std::istream &xml, const user_defines_t &user_defines = {}, std::optional<progress_callback_t> callbacks = {})
virtual ~xml_loader_t()
inline virtual std::string node_description(const node_t &node) const noexcept override