Draw 2D and 3D semiconductor devices and fabrication processes with CeTZ, including patterned geometry loaded from GDS.
#import "@preview/mesa:0.4.0" as semi
#set page(width: auto, height: auto, margin: 8mm)
#let sample = {
import semi: *
layer(
"substrate",
thickness: 30,
material: "substrate",
label: [Si],
)
layer(
"oxide",
thickness: 5,
material: "dielectric",
label: [SiO#sub[2]],
)
layer(
"gate",
thickness: 15,
material: "metal",
label: [Al],
)
}
#semi.layer-stack(
sample,
camera: (azimuth: 35deg, elevation: 35deg),
shading: "fancy",
)

GDS layouts can also be used to produce process-flow steps.

Usage
To use this package you can simply import in your typst document:
#import "@preview/mesa:0.4.0"
// Your drawing code here
It is recommended to start from the various example files. Also see the usage manual for the complete API reference.
DISCLAIMER: >80% of Typst code and 100% of Rust code was LLM-written, guided by me at a high level. I’m not fluent in Rust and I couldn’t have justified writing this package otherwise. Since this is only a visualization tool, I felt that vibe coding it could be justified. Nonetheless, I have been using it for my own projects and have been happy with the results.
In case of any bugs or missing features, please open an issue on GitHub.
Changelog
0.4.0
It is now possible to produce real sloped geometry and conformally deposit or isotropically etch around it. Etching can undercut or taper sidewalls. There have been minor changes to the mask, label, and material APIs.
New features
edge-profilechamfers or rounds the exposed upper edges of a deposition. Later layers and etches follow those slopes. A round profile approximates a quarter-circle withfacets(default6).removedeletes named layers completely, ignoring masks, blockers, and depth. You may use it to strip resist layers, for example.etchacceptsisotropicfor a circular or elliptical lateral etch, orsidewallfor a straight wall angle. Unselected layers stop the etch locally. An isotropic etch can wrap around a zero-rate layer without casting an anisotropic shadow beneath it.stroke,internal-stroke, andedge-accent-strokecan be set per material, on the stack, or in the palette.
API changes
- The former
beveloption is nowedge-accenton the material or stack. mask: nonenow covers the complete sample. The previous default,mask: auto, is no longer accepted.- Layer style and labels are set on the layer itself:
materialmay be a dictionary of family, variant, and overrides, andlabelmay be a dictionary ofdraw.contentoptions. debug: truereplaces the render with a topology view, or a pieces view of a cross-section.semi.debug.topologyandsemi.debug.sectionattach a legend.
Other changes
crease-anglenow defaults to15deg.
0.3.0
Mesa now supports conformal and planar depositions, arbitrary sidewall coverage, and selective etching of specified layers only. These operations can be combined to build more complex vertical devices, trenches, and overhangs.
conformal-layercoats every exposed surface with equal thickness, including sidewalls and downward-facing surfaces.layercan deposit a controlled fraction of its top-surface thickness on vertical sidewalls, useful for partially conformal processes.planar-layerfills topography to a height measured from the substrate, suitable for resist and planarization steps.etchcan target named layers. Unselected materials are ignored, allowing buried layers to be removed. Depth is now optional:depth: autoetches down to the substrate. Numeric depths can continue into it and form trenches.- Transparent materials now work as intended, with proper shadow interactions.
- Improvements to outline stroke and internal/external stroke disambiguation. Coplanar faces of the same material now render as continuous surfaces.
- More performance improvements, around 20× faster in the worst-performing example file.
0.2.0
Improved support for larger and more complex GDS layouts. Paths are now supported, lateral x and y layout dimensions can be rescaled on import to improve visual presentation clarity, and the renderer has been improved and optimized to render hundreds of faces within a second.
- GDS
PATHelements are imported with their widths and end styles. Dense paths may be simplified withpath-toleranceto optimize document compile times. - Imported layouts retain their declared physical unit and can be converted to
nanometres, micrometres, millimetres, or a custom unit. Independent
xandyscaling can make large devices legible without changing vertical process dimensions, while configurable padding provides room around the layout. - Fancy shading now projects the actual shape of cast shadows onto receiving surfaces. Narrow gates and patterned features can cast “proper” shadows. Flat shading does not project shadows, as before.
- Rectangular and patterned layers now share the same rendering path. Lighting, bevels, fades, cuts, outlines, and debug views therefore behave consistently when both kinds of geometry appear in one sample.
- Complex and finely segmented layouts render more efficiently.
crease-anglewas added to visually smooth curves, and rounded stroke caps prevent small gaps where outline segments meet. - A stack-level
strokesets a common exterior-outline style while preserving per-layer overrides. - GDS coordinates now use the file’s declared unit by default. A preferred unit can be specified and layout coordinates will be converted to it.
- Layouts can be padded to extend the substrate around the mask automatically.
0.1.0
Initial release