raytraverse.renderer

Renderer

class raytraverse.renderer.Renderer[source]

Bases: object

virtual singleton renderer class. the Renderer is implemented as a singleton as specific subclasses (rtrace, rcontrib) have many global variables set at import time. This ensures the python object is connected to the current state of the engine c++-class.

All renderer classes are callable with with a numpy array of shape (N,6) representing the origin and direction of ray samples to calculate.

args = None
instance = <raytraverse.renderer.renderer._VirtEngine object>
scene = None
classmethod set_args(args, nproc=None)[source]
run(*args, **kwargs)[source]

alias for call, for consistency with SamplerPt classes for nested dimensions of evaluation

RadianceRenderer

class raytraverse.renderer.RadianceRenderer(rayargs=None, scene=None, nproc=None, default_args=True)[source]

Bases: raytraverse.renderer.renderer.Renderer

Virtual class for wrapping c++ Radiance renderer executable classes

Do not use directly, either subclass or use existing: Rtrace, Rcontrib

name = 'radiance_virtual'
engine = <cRtrace>

raytraverse.crenderer.cRtrace

srcn = 1
defaultargs = ''
args = None
nproc = None
classmethod get_default_args()[source]
classmethod reset()[source]

reset engine instance and unset associated attributees

classmethod set_args(args, nproc=None)[source]

prepare arguments to call engine instance initialization

Parameters
  • args (str) – rendering options

  • nproc (int, optional) – cpu limit

classmethod load_scene(scene)[source]

load octree file to engine instance

Parameters

scene (str) – path to octree file

Raises

ValueError: – can only be called after set_args, otherwise engine instance will abort.

Rtrace

class raytraverse.renderer.Rtrace(rayargs=None, scene=None, nproc=None, default_args=True, direct=False)[source]

Bases: raytraverse.renderer.radiancerenderer.RadianceRenderer

singleton wrapper for c++ raytrraverse.crenderer.cRtrace class

this class sets default arguments, helps with initialization and setting cpu limits of the cRtrace instance. see raytraverse.crenderer.cRtrace for more details.

Parameters
  • rayargs (str, optional) – argument string (options and flags only) raises ValueError if arguments are not recognized by cRtrace.

  • scene (str, optional) – path to octree

  • nproc (int, optional) – if None, sets nproc to cpu count, or the RAYTRAVERSE_PROC_CAP environment variable

  • default_args (bool, optional) – if True, prepend default args to rayargs parameter

  • direct (bool, optional) – if True use Rtrace.directargs in place of default (also if True, sets default_args to True.

Examples

Basic Initialization and call:

r = renderer.Rtrace(args, scene)
ans = r(vecs)
# ans.shape -> (vecs.shape[0], 1)

If rayargs include cache files (ambient cache or photon map) be careful with updating sources. If you are going to swap sources, update the arguments as well with the new paths:

r = renderer.Rtrace(args, scene)
r.set_args(args.replace("temp.amb", "temp2.amb"))
r.load_source(srcdef)

Note that if you are using ambient caching, you must give an ambient file, because without a file ambient values are not shared across processes or successive calls to the instance.

name = 'rtrace'
engine = <cRtrace>

raytraverse.crenderer.cRtrace

defaultargs = '-u+ -ab 16 -av 0 0 0 -aa 0 -as 0 -dc 1 -dt 0 -lr -14 -ad 1000 -lw 0.00004 -st 0 -ss 16'
directargs = '-av 0 0 0 -ab 0 -lr 0 -n 1'
usedirect = False
classmethod get_default_args()[source]

return default arguments of the class

classmethod set_args(args, nproc=None)[source]

prepare arguments to call engine instance initialization

Parameters
  • args (str) – rendering options

  • nproc (int, optional) – cpu limit

classmethod update_ospec(vs)[source]

set output of cRtrace instance

Parameters

vs (str) –

output specifiers for rtrace::

o origin (input) d direction (normalized) v value (radiance) V contribution (radiance) w weight W color coefficient l effective length of ray L first intersection distance c local (u,v) coordinates p point of intersection n normal at intersection (perturbed) N normal at intersection (unperturbed) r mirrored value contribution x unmirrored value contribution R mirrored ray length X unmirrored ray length

Returns

outcnt – the number of output columns to expect when calling rtrace instance

Return type

int

Raises

ValueError: – when an output specifier is not recognized

classmethod load_source(srcfile, freesrc=- 1, ambfile=None)[source]

add a source description to the loaded scene

Parameters
  • srcfile (str) – path to radiance scene file containing sources, these should not change the bounding box of the octree and has only been tested with the “source” type.

  • freesrc (int, optional) – the number of objects to unload from the end of the rtrace object list, if -1 unloads all objects loaded by previous calls to load_source

  • ambfile (str, optional) – path to ambient file. if given, and arguments

Rcontrib

class raytraverse.renderer.Rcontrib(rayargs=None, scene=None, nproc=None, skyres=10.0, modname='skyglow', ground=True, default_args=True)[source]

Bases: raytraverse.renderer.radiancerenderer.RadianceRenderer

singleton wrapper for c++ raytrraverse.crenderer.cRcontrib class

this class sets default arguments, helps with initialization and setting cpu limits of the cRcontrib instance. see raytrraverse.crenderer.cRcontrib for more details.

Parameters
  • rayargs (str, optional) – argument string (options and flags only) raises ValueError if arguments are not recognized by cRtrace.

  • scene (str, optional) – path to octree

  • nproc (int, optional) – if None, sets nproc to cpu count, or the RAYTRAVERSE_PROC_CAP environment variable

  • skyres (float, optional) – approximate resolution for skypatch subdivision (in degrees). Patches will have (rounded) size skyres x skyres. So if skyres=10, each patch will be 100 sq. degrees (0.03046174197 steradians) and there will be 18 * 18 = 324 sky patches.

  • modname (str, optional) – passed the -m option of cRcontrib initialization

  • ground (bool, optional) – if True include a ground source (included as a final bin)

  • default_args (bool, optional) – if True, prepend default args to rayargs parameter

Examples

Basic Initialization and call:

r = renderer.Rcontrib(args, scene)
ans = r(vecs)
# ans.shape -> (vecs.shape[0], 325)
name = 'rcontrib'
engine = <cRcontrib>

raytraverse.crenderer.cRcontrib

ground = True
side = 18
srcn = 325
modname = 'skyglow'
classmethod setup(scene=None, ground=True, modname='skyglow', skyres=10.0)[source]

set class attributes for proper argument initialization

Parameters
  • scene (str, optional) – path to octree

  • ground (bool, optional) – if True include a ground source (included as a final bin)

  • modname (str, optional) – passed the -m option of cRcontrib initialization

  • skyres (float, optional) – approximate resolution for skypatch subdivision (in degrees). Patches will have (rounded) size skyres x skyres. So if skyres=10, each patch will be 100 sq. degrees (0.03046174197 steradians) and there will be 18 * 18 = 324 sky patches.

Returns

scene – path to scene with added sky definition

Return type

str

classmethod get_default_args()[source]

construct default arguments

classmethod set_args(args, nproc=None)[source]

prepare arguments to call engine instance initialization

Parameters
  • args (str) – rendering options

  • nproc (int, optional) – cpu limit

ImageRenderer

class raytraverse.renderer.ImageRenderer(scene, viewmapper=None, method='linear')[source]

Bases: raytraverse.renderer.renderer.Renderer

interface to treat image data as the source for ray tracing results

not implemented as a singleton, so multiple instances can exist in parallel.

Parameters
  • scene (str) – path to hdr image file with projecting matching ViewMapper

  • viewmapper (raytraverse.mapper.ViewMapper, optional) – if None, assumes 180 degree angular fisheye (vta)

  • method (str, optional) – passed to scipy.interpolate.RegularGridInterpolator