Skip to content

Look ​

Rendered objects get a material per component class and visible cemented interfaces of doublet and triplet lenses. Two looks are available, which are selected via set_render_look:

BeamletOptics.set_render_look Method
julia
set_render_look(look::Symbol)

Sets the look of all subsequently rendered objects, :modern (default) or :cad. The :modern look renders clear glass with faint silhouettes, metallic mirrors and neutral mechanics without edge lines, the :cad look saturated materials with feature edge lines. Explicit kwargs of render!, e.g. color, material or edges, override the look.

If no suitable backend is loaded, a MissingBackendError will be thrown.

source

The looks in detail:

  • :modern (default): clear, slightly tinted glass with highlights, metallic mirrors and neutral mechanics; saturated coatings and polarizer films. Only the glass (:refractive, :coating and :interface) gets faint silhouettes, i.e. its feature edges at 50 % of the opacity of the :cad look

  • :cad: saturated materials with thin dark lines along the feature edges, like a CAD program

julia
set_render_look(:cad)
materialcomponents:modern:cad
:refractivelenses, prisms, plates, windowsclear glass, 0.3light blue, 0.5
:reflectivemirrors, retroreflectormetallic silversilver
:coatingbeamsplitter coatingsviolet, 0.9magenta, 0.9
:polarizerpolarization filtersgreen, 0.8green, 0.8
:detectordetectorsgraphitedark blue
:mechanicsmechanics, dummies and other objectsneutral greymid grey
:interfacecemented interfaces of doublets, tripletspale amber, 0.15amber, 0.25

The numbers are the opacity alpha of transparent materials.

Besides the color and the opacity, each material sets the transparency, diffuse, specular and shininess attributes of the mesh plot. The parts of composite objects are rendered with their own class, e.g. the prisms and the coating of a CubeBeamsplitter. The following keyword arguments of render! change the look of an object:

  • material = nothing: one of the materials above, overrides the component class for all parts of the object

  • color, alpha, transparency, ...: override the corresponding attribute of the material, for all parts of the object. The cemented interfaces keep their amber look.

  • edges: draws the feature edges, i.e. the edges where the faces of an object meet at an angle of more than 30°, and the boundary of open surfaces such as a Detector. By default, the :cad look draws them for all materials except :mechanics, whose detailed meshes, e.g. a housing from an STL file, would cover the optics, the :modern look for the glass only. The parts of composite objects contribute edges according to their own class. edges = true or false overrides the look, for all parts of the object. Shapes rendered via the marching cubes fallback have no edges. The opacity of the edges follows the opacity of the object, e.g. a nearly transparent housing (color = (:gray70, 0.05)) gets correspondingly faint edges, while the edges of glass stay visible.

julia
render!(ax, lens)                       # glass of the active look
render!(ax, mirror; edges = true)       # with feature edges in the :modern look
render!(ax, lens; color = :red)         # red glass, same transparency
render!(ax, mount; material = :mechanics, edges = false)

Lighting ​

The lighting of the scene is set via studio_lighting!:

BeamletOptics.studio_lighting! Method
julia
studio_lighting!(ax::Union{LScene, Axis3}; preset = :studio)

Sets up a CAD-like lighting rig in the 3D view ax, if a suitable backend is loaded: an ambient light, a key light from the upper right front, a fill light from the left and a rim light from behind, all relative to the camera. Backends with a single directional light (e.g. CairoMakie) get the ambient and the key light only. preset = :none leaves the lights unchanged. The GUI of the package BeamletOpticsGUI applies the rig by default, scenes created via render! call it explicitly.

If no suitable backend is loaded, a MissingBackendError will be thrown.

source
julia
fig = Figure()
ax = LScene(fig[1, 1])
studio_lighting!(ax)
render!(ax, system)

It works for an LScene and an Axis3.