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¶
-
_pyinstance
= None¶
-
instance
= <raytraverse.renderer.renderer._VirtEngine object>¶
-
scene
= None¶
-
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
= <MagicMock id='140334625906512'>¶ raytraverse.crenderer.cRtrace
-
srcn
= 1¶
-
defaultargs
= ''¶
-
args
= ''¶
-
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 raytrraverse.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)
-
name
= 'rtrace'¶
-
engine
= <MagicMock id='140334625887760'>¶ raytraverse.crenderer.cRtrace
-
defaultargs
= '-av 0 0 0 -aa 0 -ab 7 -ad 128 -as 0 -c 10 -as 0 -lw 1e-5'¶
-
directargs
= '-av 0 0 0 -ab 0 -lr 0'¶
-
usedirect
= False¶
-
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
(srcname, freesrc=- 1)[source]¶ add a source description to the loaded scene
- Parameters
srcname (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
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
= <MagicMock id='140334625472208'>¶ 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
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