Atrc Renderer Documentation

pic

Atrc Renderer DocumentationBuildingDependenciesCMake OptionsExampleUsageComponentsCLI UsageConfigurationRendering SettingsSceneEntityAggregateCameraEntityFilmFilterGeometryMaterialMediumEnvirLightPost ProcessorRendererProgressReporterTexture2DTexture3DTransformTransform2Shared Scene Description

Building

Dependencies

Prerequests

Dependencies Contained in Project Source

Dependencies Need to Be Prepared

CMake Options

NameDefault ValueExplanation
USE_EMBREEOFFuse Embree library to tracing rays
USE_OIDNOFFuse OIDN denoising library
BUILD_GUIOFFbuild rendering launcher with GUI
BUILD_EDITOROFFbuild scene editor

Note. OIDN is 64-bit only.

Example

Full-featured Building on Windows

Run following command in PowerShell

Full-featured Building on *nix

Usage

Components

  1. CLI, command-line interface of the off-line renderer
  2. GUI, renderer launcher with graphics user interface
  3. Editor, scene editor
  4. Tracer, off-line rendering library based on ray tracing
  5. Factory, JSON config -> Tracer object

CLI Usage

Use following command to print help information:

Typical usage looks like:

in which scene_config.json is a configuration file describing scene information and rendering settings.

Configuration

Atrc uses JSON to describe scene and rendering settings. The input JSON file must contains two parts:

where scene is a scene object with type Scene (explained later). rendering specifies rendering settings like camera, global illumination algorithm, progress reporter, and post processors.

metal_sphere

Here is a simple example, which results in the above image (a bit rough metal sphere):

Atrc's configuration file consists of a series of nested JSON objects, and each field has its type and value. The syntaxes of some commonly used types are listed below:

field typeexamplesemantics
int-1integer 1
real1.2floating number 1.2
booltrueboolean value true
boolfalseboolean value false
string"minecraft"string minecraft
Spectrum[ 0.5 ]RGB value (0.5, 0.5, 0.5)
Spectrum[ 0.1, 0.2, 0.3 ]RGB value (0.1, 0.2, 0.3)
Vec2[ 2 ]2D vector (2, 2)
Vec2[ 1.2, 2 ]2D vector (1.2, 2)
Vec3[ 9.9 ]3D vector (9.9, 9.9, 9.9)
Vec3[ 1, 2.2, 3 ]3D vector (1, 2.2, 3)
Vec2i[ 1 ]2D integer vector (1, 1)
Vec2i[ 1, 2 ]2D integer vector (1, 2)
Vec3i[ 2 ]3D integer vector (2, 2, 2)
Vec3i[ 3, 4, -6 ]3D integer vector (3, 4, -6)
[Type][Instance0, Instance1, ...]JSON array of objects with given Type

When a string represents a path or file name, ${scene-directory} means the absolute path of the directory where the configuration file is located, and ${working-directory} means the absolute path of working directory. Take ${scene-directory}/output.png as an example, it means output.png file in the directory where the configuration file is.

Except for fields with above types, other fields appear in the syntax of JSON object. Each object contains a field type, representing its type in Atrc renderer.

In the following description, I will use a simplified tabular form to indicate which fields an object should contain and the meaning of these fields. Taking the last post-processor save_to_img in the above configuration file as an example, its JSON representation is:

The corresponding tabular form is:

Field NameTypeDefault ValueExplanation
............

In the form, the "default value" column is blank to indicate that this is a required field, and not blank to indicate that it is an optional field.

Rendering Settings

This section describes fields included in the rendering item.

Field NameTypeDefault ValueExplanation
cameraCamera camera for viewing the scene
rendererRenderer rendering algorithm
reporterProgressReporter how to output rendering progress
post_processors[PostProcessor][]image post processors
widthint image width
heightint image height
film_filterFilmFilterbox with radius = 0.5film filter function
epsreal3e-4scene epsilon

Scene

This section describes the possible type values for fields of type Scene.

default

Field NameTypeDefault ValueExplanation
entities[Entity][]entities in scene
aggregateEntityAggregatenative aggregatedata structure for accelerating ray queries between entities (default is a brute-force one)
envEnvirLightnullenvironment light

EntityAggregate

For the intersection test between rays and the entities, Atrc uses a two-level data structure (refer to the design of RTX), where the inside of the entity is one level and the one between entities is another level. EntityAggregate is the field type corresponding to the data structure between entities.

native

native doesn't contain any fields, meaning to traversing all entities.

bvh

Organize entities with a BVH tree.

Field NameTypeDefault ValueExplanation
max_leaf_sizeint5How many entities a leaf node can contain

Camera

This section describes the possible type values for fields of type Camera.

thin_lens

Field NameTypeDefault ValueExplanation
posVec3 eye position
dstVec3 position looked by the camera
upVec3 see 'lookat' matrix in 3D computer graphics
fovreal field of view (in degree)
lens_radiusreal0lens radius (for DoF effect)
focal_distancereal1distance between focal plane and lens

Entity

geometric

geometric

Ordinary entity with geometry shape, material and mediums.

Field NameTypeDefault ValueExplanation
geometryGeometry geometric shape
materialMaterial surface material
med_inMediumvoidouter medium
med_outMediumvoidinner medium
emit_radianceSpectrum[ 0, 0, 0 ]emitted radiance
no_denoiseboolfalsedisable denoiser on this entity
powerreal-1sampling weight of this light source; specify -1 to compute it automatically

FilmFilter

The process of rendering the image is also a process of sampling-reconstructing the image plane. FilmFilter is the filter function used for reconstruction. For details, please refer to this article. If you don't know much about this part, it is recommended to use the simplest (but not the best) reconstruction filter function:

box

The simplest box filter function, coincides with a single pixel with a radius of 0.5.

Field NameTypeDefault ValueExplanation
radiusreal filter radius in pixels

gaussian

Gaussian filter function

Field NameTypeDefault ValueExplanation
radiusreal filter radius in pixels
alphareal  in gaussian function

Geometry

Used to describe the geometry of an object.

Most geometric shapes contain a transform field of type [Transform], which is a sequence of Transform. It is worth noting that the Transform in the back of the sequence acts on the object first, and the Transform in front of the sequence acts on the object later.

disk

pic

Field NameTypeDefault ValueExplanation
transform[Transform] transform from local space to world space
radiusreal disk radius

double_sided

Double-sided adapter, which converts a single-sided geometry to double-sided, and is mainly suitable for geometric shape in the form of disc, quad or triangle.

Field NameTypeDefault ValueExplanation
internalGeometry geometry turned from single-sided to double-sided

quad

pic

Quad , constructed by two triangles and

Field NameTypeDefault ValueExplanation
transform[Transform] transform from local space to world space
AVec3 position of vertex
BVec3 position of vertex
CVec3 position of vertex
DVec3 position of vertex
tAVec2(0, 0)texture coordinate of vertex
tBVec2(0, 0)texture coordinate of vertex
tCVec2(0, 0)texture coordinate of vertex
tDVec2(0, 0)texture coordinate of vertex

sphere

pic

Single-sided sphere

Field NameTypeDefault ValueExplanation
transform[Transform] transform from local space to world space
radiusreal sphere radius

triangle

pic

Single-sided triangle

Field NameTypeDefault ValueExplanation
transform[Transform] transform from local space to world space
AVec3 position of vertex
BVec3 position of vertex
CVec3 position of vertex
tAVec2(0, 0)texture coordinate of vertex
tBVec2(0, 0)texture coordinate of vertex
tCVec2(0, 0)texture coordinate of vertex

triangle_bvh

pic

Triangle mesh

Embree is used when enabled, otherwise a simple BVH tree is used.

Field NameTypeDefault ValueExplanation
transform[Transform] transform from local space to world space
filenamestring model file path, supports OBJ/STL file

triangle_bvh_embree

Triangle mesh implemented using Embree. It has the same parameters as triangle_bvh.

Available only when cmake option USE_EMBREE is ON.

triangle_bvh_noembree

Triangle mesh implemented using simple BVH tree. It has the same parameters as triangle_bvh.

Material

Normal Mapping

pic

Some materials support normal mapping. The field list of these materials will include a normal_map.

BSSRDF

pic

Some materials support Normalized Diffusion BSSRDF, which contains following three fields:

  1. bssrdf_dmfp. diffuse mean free path length.
  2. bssrdf_A. diffuse surface reflectance.
  3. bssrdf_eta. ior.

BSSRDF is enabled only when bssrdf_dmfp is specified. According to material type, bssrdf_A and bssrdf_eta may have default value. These fields and their default values are listed in fields of those materials.

disney

pic

see Disney Principled BSDF

Field NameTypeDefault ValueExplanation
base_colorTexture2D see original article; range:
metallicTexture2D see original article; range:
roughnessTexture2D see original article; range:
specular_scaleTexture2Dall_onescale factor of non-metallic specular lobe; range:
specular_tintTexture2Dall_zerosee original article; range:
anisotropicTexture2Dall_zerosee original article; range:
sheenTexture2Dall_zerosee original article; range:
sheen_tintTexture2Dall_zerosee original article; range:
clearcoatTexture2Dall_zerosee original article; range:
clearcoat_glossTexture2Dall_onesee original article; range:
transmissionTexture2Dall_zerosee original article; range:
transmission_roughnessTexture2Droughnessroughness of transmitted specular lobe; range:
iorTexture2Dall_{1.5}see original article; range:
normal_mapTexture2Dall_{ 0, 0, 1 }normal map
bssrdf_dmfpTexture2Dnullspecify this to enable BSSRDF
bssrdf_ATexture2Dbase_colordiffuse surface reflectance for BSSRDF
bssrdf_etaTexture2Diorior for BSSRDF

glass

pic

Smooth glass

Field NameTypeDefault ValueExplanation
color_mapTexture2D surface color
color_reflection_mapTexture2D reflection color
color_refraction_mapTexture2D refraction color
iorTexture2D index of refraction
bssrdf_dmfpTexture2Dnullspecify this to enable BSSRDF
bssrdf_ATexture2Dnulldiffuse surface reflectance for BSSRDF
bssrdf_etaTexture2Diorior for BSSRDF

Two color assignment methods are provided:

  1. Only provide color_map. Colors of reflection and refraction are given automatically filled with color_map.
  2. Provide color_reflection_map and color_refraction_map, which give reflection and refraction colors respectively.

ideal_black

A mass of black

ideal_diffuse

pic

Ideal diffuse reflection, reflects the same radiance in all directions.

Field NameTypeDefault ValueExplanation
albedoTexture2D surface color times
normal_mapTexture2Dall_{ 0, 0, 1 }normal map

mirror

pic

Ideal mirror reflection

Field NameTypeDefault ValueExplanation
color_mapTexture2D surface color
etaTexture2D index of refraction
kTexture2D index of absorbtion

phong

NOTE. Atrc will automatically scale and to keep energy conservation.

Field NameTypeDefault ValueExplanation
dTexture2D diffuse color
sTexture2D specular color
nsTexture2D specular glossness
normal_mapTexture2Dall_{ 0, 0, 1 }normal map

invisible_surface

Surface material which is totally invisible

Medium

void

Vacuum, which means nothing.

heterogeneous

pic

Heterogeneous media defined based on 3D textures

Field NameTypeDefault ValueExplanation
transform[Transform] from texture space () to world space
densityTexture3D medium density, i.e.
albedoTexture3D albedo, i.e.
gTexture3D asymmetry of scattering
max_scattering_countintINT_MAXmax continous scattering count

homogeneous

pic

Field NameTypeDefault ValueExplanation
sigma_aSpectrum absorption rate
sigma_sSpectrum scattering rate
greal asymmetry of scattering
max_scattering_countintINT_MAXmax continous scattering count

EnvirLight

ibl

pic

Image based lighting

Field NameTypeDefault ValueExplanation
texTexture2D texture object describing radiance
no_importance_samplingboolfalsedisable importance sampling
powerreal-1sampling weight of this light source; specify -1 to compute it automatically

native_sky

pic

Environment light that represents a sky with a gradient of color from top to bottom.

Field NameTypeDefault ValueExplanation
topSpectrum top radiance
bottomSpectrum bottom radiance
powerreal-1sampling weight of this light source; specify -1 to compute it automatically

Post Processor

gamma

Perform gamma correction on the image

Field NameTypeDefault ValueExplanation
gammareal 
inv_gammareal 

Only one of gamma and inv_gamma need to be given.

oidn_denoiser

Use OIDN to denoise the image

Field NameTypeDefault ValueExplanation
clampboolfalsewhether to clamp the image color to before denoising

save_gbuffer_to_png

pic

Save the G-Buffer to png files

Field NameTypeDefault ValueExplanation
albedostring""where to save material colors
normalstring""where to save normal image

save_to_img

Save the rendered image to a file

Field NameTypeDefault ValueExplanation
filenamestring where to save the output image
openboolfalsewhether to open it with the default image browser
inv_gammareal1 for gamma correction (typical value is 2.2)
gammareal1 for gamma correction (typical value is 1 / 2.2)
extstringfrom filenamesaved file type ("jpg", "png" or "hdr")

Only one of gamma/inv_gamma need to be specified for gamma correction.

resize

Resize the image and G-Buffer to the specified resolution

Field NameTypeDefault ValueExplanation
size[int, int] target resolution

Renderer

pt

Traditional path tracing. You can specify the tracing strategy by integrator.

Field NameTypeDefault ValueExplanation
task_grid_sizeint32rendering task pixel size
worker_countint0rendering thread count
sppint samples per pixel
min_depthint5minimum path depth before using RR policy
max_depthint10maximum depth of the path
cont_probreal0.9pass probability when using RR strategy
specular_depthint20extra path depth for specular scattering

The entire image is divided into multiple square pixel blocks (rendering tasks), and each pixel block is assigned to a worker thread for execution as a subtask.

When the number of worker threads is less or equal to 0 and the number of hardware threads is , then worker threads will be used. For example, you can set worker_count to -2, which means that you leave two hardware threads and use all other hardware threads.

ao

pic

Ambient occlusion renderer

Field NameTypeDefault ValueExplanation
worker_countint0rendering thread count
task_grid_sizeint32rendering task pixel size
ao_sample_countint5samples per camera ray
low_colorSpectrum[ 0 ]occluded color
high_colorSpectrum[ 1 ]unoccluded color
max_occlusion_distancereal1max occlusion distance
background_colorSpectrum[ 0 ]background color
sppint samples per pixel

bdpt

Bidirectional path tracer

Field NameTypeDefault ValueExplanation
worker_countint0rendering thread count
task_grid_sizeint32rendering task pixel size
camera_max_depthint10max depth of camera subpath
light_max_depthint10max depth of light subpath
use_misbooltrueuse multiple importance sampling
sppint samples per pixel

particle

Adjoint particle tracer. particle builds path from light source to camera, making the convergence very slow.

Field NameTypeDefault ValueExplanation
worker_countint0rendering thread count
particle_task_countint particle tracing task count
particles_per_taskint particles per task in backward pass
min_depthint5min path depth before using RR policy
max_depthint10max depth of the path
cont_probreal0.9continuing probability when using RR strategy
forward_task_grid_sizeint32rendering task pixel size in forward pass
forward_sppint samples per pixel in forward pass

particle uses the strategy of starting from a light source to construct a light path, called backward pass; for paths of length 1 (that is, the light source is directly seen from the camera), however, particle builds them from the camera to light sources, called forward pass. The two passes are independent executed and are combined to render the final image.

Backward pass consists of particle_task_count particle tracing tasks. Each task contains particles_per_task particles, so a total number of particle_task_count * particles_per_task paths are traced in backward pass.

pssmlt_pt

Primary sample space metropolis light transport on path tracing

Field NameTypeDefault ValueExplanation
worker_countint0rendering thread count
min_depthint5min path depth before using RR policy
max_depthint10max depth of the path
cont_probreal0.9continuing probability when using RR strategy
use_misbooltrueuse mis to compute direct illumination
startup_sample_countint100000number of startup samples in MLT
mut_per_pixelint100mutations per pixel
sigmareal0.01small mutation size
large_step_probreal0.35probability of large mutation in each iteration
chain_countint1000number of markov chains

sppm

Stochastic progressive photon mapping

Field NameTypeDefaultExplanation
worker_countint0rendering thread count
task_grid_sizeint128pixels per thread in finding visible points
forward_max_depthint8max tracing depth in finding visible points
init_radiusreal-1initial search radius. negative num means auto
iteration_countint number of iterations
photons_per_iterationint how many photons are traced per iteration
photon_min_depthint5min depth when tracing photon before apply RR
photon_max_depthint10max depth when tracing photon before apply RR
photon_cont_probreal0.9RR continuing probability
alphareal0.666667radius reduction factor
grid_resint64resolution of grids for range search acceleration

vol_bdpt

Volumetric bidirectional path tracing

Field NameTypeDefault ValueExplanation
worker_countint0rendering thread count
task_grid_sizeint32rendering task pixel size
camera_max_depthint10max depth of camera subpath
light_max_depthint10max depth of light subpath
sppint samples per pixel
use_misbooltrueuse multiple importance sampling

ProgressReporter

stdout

Print to standard output

noout

No progress output

Texture2D

All 2d textures contain the following fields (these fields are not listed in the subsequent textures):

Field NameTypeDefault ValueExplanation
inv_vboolfalseturn to (flip the texture vertically)
inv_uboolfalseturn to (flip the texture horizontally)
swap_uvboolfalseswap and
transform[Transform2][]transform sequence applied to the texture coordinate
wrap_ustring"clamp"ways to deal with that is out of ; range: clamp/mirror/repeat
wrap_vstring"clamp"ways to deal with that is out of ; range: clamp/mirror/repeat
inv_gammareal1used to perform inverse gamma correction to the texture; typical value is 2.2

Note that inv_v, inv_u, swap_uv and transform are all transformations to uv, where transform applies first, then swap_uv , and inv_u, inv_v applies last. In the transform sequence, the Transform2 in the back of the sequence applies first, and the Transform2 in the front of the sequence applies later.

checker_board

checker board texture

Field NameTypeDefault ValueExplanation
grid_countreal how many grids the texture contains
color1Spectrum[ 0 ]the first grid color
color2Spectrum[ 1 ]the second grid color

constant

Constant-valued texture, that is, sampling always results in the same value

Field NameTypeDefault ValueExplanation
texelSpectrum texel value

hdr

Texture loaded from .hdr file

Field NameTypeDefault ValueExplanation
filenamestring .hdr filename
samplestring"linear"sampling strategy; range: linear/nearest

image

Textures loaded from common image file formats (.bmp, .jpg, .png, .tga, etc)

Field NameTypeDefault ValueExplanation
filenamestring image filename
samplestring"linear"sampling strategy; range: linear/nearest

Texture3D

All 3d textures contain the following fields (these fields are not listed in the subsequent textures):

Field NameTypeDefault ValueExplanation
inv_vboolfalseturn to
inv_uboolfalseturn to
inv_wboolfalseturn to
uvw_permVec3i[ 0, 1, 2 ]permutation of uvw
transform[Transform3][]transform sequence applied to the texture coordinate
wrap_ustring"clamp"wrapping method to deal with that is out of ; range: clamp/mirror/repeat
wrap_vstring"clamp"wrapping method to deal with that is out of ; range: clamp/mirror/repeat
wrap_wstring"clamp"wrapping method to deal with that is out of ; range: clamp/mirror/repeat
inv_gammareal1used to perform inverse gamma correction to the texture; typical value is 2.2

Note that inv_v, inv_u, inv_w, uvw_perm and transform are all transformations to uv, where transform applies first, then uvw_perm , and inv_u, inv_v, inv_w applies last. In the transform sequence, the Transform3 in the back of the sequence applies first, and the Transform3 in the front of the sequence applies later.

constant

Constant-valued texture, that is, sampling always results in the same value

Field NameTypeDefault ValueExplanation
texelSpectrum texel value

image3d

3D grid.

Field NameTypeDefault ValueExplanation
formatstring one of { "real", "spec", "gray8", "rgb8" }
ascii_filenamestring filename of voxel data in text format
binary_filenamestring filename of voxel data in binary format
image_filenames[string] array of filenames for image slices
samplerstringlinearone of { "linear", "nearest" }

The format field determines how voxel data is stored in memory. real/spec store one/three float value for each voxel, and gray8/rgb8 use one/three bytes for each voxel. Note that real/gray8 format can only store gray value, and gray8/rgb8 can only store integer between [0, 255] (normalized to [0, 1] when sampled).

There are three ways to provide voxel data to spectrum_grid, one and only one of the three fields (ascii_filename/binary_filename/image_filenames) must be specified.

The format of text voxel data is:

The format of voxel_value is determined by format:

The data arrangement of binary voxel data is similar to the text format, except that all data is stored as binary data.

The filename array of image slices refers to the filenames of a series of two-dimensional images obtained by decomposing the voxels in the depth direction. These two-dimensional images must be the same size, and the number of images determines the depth value of the 3d texture.

Transform

Affine transformation on three-dimensional coordinates

translate

Field NameTypeDefault ValueExplanation
offsetVec3 transtion offset

rotate

Field NameTypeDefault ValueExplanation
axisVec3 rotation axis
radreal rotation radian
degreal rotation degree

Only one of rad and deg can be provided.

rotate_x

Rotate around the axis.

Field NameTypeDefault ValueExplanation
radreal rotation radian
degreal rotation degree

Only one of rad and deg can be provided.

rotate_y

Rotate around the axis.

Field NameTypeDefault ValueExplanation
radreal rotation radian
degreal rotation degree

Only one of rad and deg can be provided.

rotate_z

Rotate around the axis.

Field NameTypeDefault ValueExplanation
radreal rotation radian
degreal rotation degree

Only one of rad and deg can be provided.

scale

Isotropic scaling

Field NameTypeDefault ValueExplanation
ratioreal scaling ratio

Transform2

Affine transformation on two-dimensional coordinates

translate

Field NameTypeDefault ValueExplanation
offsetVec2 translation offset

rotate

Field NameTypeDefault ValueExplanation
radreal rotation radian
degreal rotation degree

Only one of rad and deg can be provided.

scale

Isotropic scaling

Field NameTypeDefault ValueExplanation
ratioreal scaling ratio

Shared Scene Description

Atrc supports rendering the same scene with different rendering parameters, such as rendering the same scene with multiple camera perspectives. Compared with using multiple configuration files, this solution avoids the overhead of repeatedly loading scene data and constructing data structures. Let the original content of rendering configuration is:

Now we need to use multiple different RenderDescription to render the same SceneDescription. We can write the configuration file as: