Module RayTracing

Meshes

# VPL.RayTracing.TriangleMethod.

Triangle(p1, p2, p3)

Create a ray tracing Triangle object given the three vertices p1, p2 and p3.

source

# VPL.RayTracing.TriangleMethod.

Triangle(mesh)

Create a vector of ray tracing Triangle objects from a Mesh object.

source

# VPL.RayTracing.TriangleMethod.

Triangle(mesh)

Create a vector of ray tracing Triangle objects from a Scene object.

source

RayTracer

# VPL.RayTracing.get_nwFunction.

get_nw(s::Source)

Retrieve the number of wavelengths that rays from a source will contain.

source

get_nw(rt::RayTracer)

Retrieve the number of wavelengths being simulated by the ray tracer. See VPL documentation for more details on the ray tracer.

source

# VPL.RayTracing.RTSettingsType.

RTSettings(;parallel = false, pkill = 0.2, maxiter = 2, sampler = Random.Xoshiro(123456789),
            nx = 3, ny = 3, nz = 0, dx = 0.0, dy = 0.0, dz = 0.0)

Settings for the ray tracer: parallel indicates if the raytracer will run on a single core or make use of multiple cores in the machine based on Julia’s multithreading support. pkill is the probably that a ray is terminated by the Russian roulette after it has been scattered a maxiter number of times. sampler is the pseudo-random number generator to be used by the ray tracer. nx and ny are the number of times the scene will be clone by the grid cloner in each direction along the x and y axis (e.g., setting nx = 1 and ny = 1 will generate a grid of 3 x 3 clones of the original scene), whereas dx and dy will be distance at which each new clone will be generated (along the axis). nz is the number of times the scene will be cloned in the vertical direction. Unlike horizontal cloning, the vertical cloning is always done in the positive direction of z axis and the number of clones will be exactly nz. See VPL documentation for more details on the ray tracer.

source

# VPL.RayTracing.accelerateFunction.

accelerate(scene::Scene; settings = RTSettings(), acceleration = Naive, rule = nothing)

Create an AccScene object from a scene, settings and acceleration function (choose from Naive or BVH). The argument rule is only required for the accelerator BVH and it must be an object of type SAH or AvgSplit (it is ignored for the Naive accelerator). The AccScene object contains the acceleration structure and the grid cloner structure built on top of the original 3D meshes in scene. See VPL documentation for details.

source

# VPL.RayTracing.RayTracerType.

RayTracer(scene, materials, sources, settings)

Create a ray tracer object from an acceleration structure built around a 3D mesh, a grid cloner structure around the acceleration structure (scene), a vector of materials associated to the mesh (materials), a vector of sources of irradiance (sources) and settings. (as generated by RTSettings()). See VPL documentation for more details on the ray tracer.

source

# VPL.RayTracing.trace!Function.

trace!(rt)

Run the ray tracing simulations. This function will overwrite the power component of any material object that is included in the scene. It returns the total number of rays being traced (primary and secondary). See VPL documentation for more details on the ray tracer.

source

Acceleration structures

# VPL.RayTracing.NaiveType.

Naive

Allow to run the ray tracer without an acceleration structure. This should be assigned to the argument acceleration in the RayTracer function.

source

# VPL.RayTracing.BVHType.

BVH

Construct a Bounding Volume Hierarchy around the triangular meshes to accelerate the ray tracer. This should be assigned to the argument acceleration in the RayTracer function, in combination with a corresponding rule.

source

# VPL.RayTracing.SAHType.

SAH{K}(minN, maxL)

Rule to be used in RayTracer when acceleration = BVH. It will divide each node at the axis and location using the Surface Area Heuristics. To speed up the construction, only K cuts will be tested per axis. These cuts will correspond to the quantiles along each axis. The rule is parameterized by the minimum number of triangles in a leaf node (minN) and the maximum depth of the tree (maxL).

source

# VPL.RayTracing.AvgSplitType.

AvgSplit(minN, maxL)

Rule to be used in RayTracer when acceleration = BVH. It will divide each node along the longest axis through the mean coordinate value. The rule is parameterized by the minimum number of triangles in a leaf node (minN) and the maximum depth of the tree (maxL).

source

Sources

# VPL.RayTracing.SourceType.

Source(geom, angle, power::Number, nrays)
Source(geom, angle, power::Tuple, nrays)

Createn irradiance source given a source geometry, a source angle, the power per ray and the total number of rays to be generated from this source. When simulating more than one wavelength simultaneously, a tuple of power values should be given, of the same length as in the materials used in the scene. See VPL documentation for details on source geometries and source angles.

source

# VPL.RayTracing.DirectionalSourceFunction.

DirectionalSource(box::AABB, θ, Φ, radiosity, nrays)
DirectionalSource(scene::Scene, θ, Φ, radiosity, nrays)

Create a Directional source (including geometry and angle components) by providing an axis-aligned bounding box (box) or an Scene object (scene) as well as the zenith (θ) and azimuth (Φ) angles, the radiosity of the source and the number of rays to be generated. Directional sources may generate incorrect results in the absence of a grid cloner that extendes the scenes. This is because the rays are generated from the upper face of the scene’s bounding box. See VPL documentation for details on light sources.

source

# VPL.RayTracing.PointSourceType.

PointSource(vec)

Create a point irradiance source geometry at given 3D location vec, defined as vector of Cartesian coordinates (Vec(x, y, z)).

source

# VPL.RayTracing.LineSourceType.

LineSource(p, line)

Create a line irradiance source geometry given an origin (p) and a segment (line) both specified as vector of Cartesian coordinates (Vec(x, y, z)). This will create a line source between the points p and p .+ line.

source

# VPL.RayTracing.AreaSourceType.

AreaSource(mesh)

Create an area irradiance source geometry given a triangular mesh.

source

# VPL.RayTracing.LambertianSourceType.

LambertianSource(x, y, z)
LambertianSource(axes)

Create a Lambertian irradiance source angle by given a local coordinate system as three separate Vec objects representing the axes (x, y, z) or as tuple containing the three axes. Rays will be generated towards the hemisphere defined by the z direction. See VPL documentation for details on irradiance sources.

source

# VPL.RayTracing.FixedSourceType.

FixedSource(dir)
FixedSource(θ, Φ)

Create a fixed irradiance source by given a vector with the direction of the rays (dir) or zenith (θ) and azimuth (Φ) angles.

source

Materials

# VPL.RayTracing.SensorType.

Sensor(nw::Int)

Create a sensor material object to store power for nw wavelengths. A sensor material will let rays pass through without altering the direction or irradiance. They will also not count for the total number of ray iterations.

source

# VPL.RayTracing.BlackType.

Black(nw::Int)

Create a black material object to store power for nw wavelengths. See VPL documentation for details.

source

# VPL.RayTracing.LambertianType.

Lambertian(;τ = 0.0, ρ = 0.0)

Create a Lambertian material object from the values of transmittance (τ) and reflectance (ρ). When more than one wavelength is being simulated, a tuple of values should be passed for each optical property (as in τ = (0.1,0.2)).

source

# VPL.RayTracing.PhongType.

Phong(;τ = 0.0, ρd = 0.0, ρsmax = 0.0, n = 2)

Create a Phong material object from the values of transmittance (τ) diffuse reflectance (ρd), maximum Phong specular reflectance (ρsmax) and n is the specular exponent that controls the “Phong reflectance lobe”. When more than one wavelength is being simulated, a tuple of values should be passed for each optical property (as in τ = (0.1, 0.3)).

source

# VPL.RayTracing.powerFunction.

power(material::Material)

Extract the power stored inside a material.

source

# VPL.RayTracing.reset!Method.

reset!(material::Material)

Reset the power stored inside a material back to zero

source

# VPL.RayTracing.tauFunction.

tau(vals...)

Generate values of transmisivity to be used in material object. vals... is a list of one or more comma separted values, corresponding to the different wavelengths/wavebands to be simulated in a ray tracer.

source

# VPL.RayTracing.rhoFunction.

rho(vals...)

Generate values of reflectivity to be used in material object. vals... is a list of one or more comma separted values, corresponding to the different wavelengths/wavebands to be simulated in a ray tracer.

source