## 2 Materials and Methods
### GPU-Based Computation of Simulated AFM Images  
Finally, we developed a method which takes into account the filtered set of atoms to efficiently compute the simulated AFM image employing an adaptation of the GPU workflow described above. We refer to this method as the XYZ-F2 method. The lateral \(Z\) direction filtering uses the normal rendering process of the graphic card to output the indices of visible atoms. The simulated AFM calculation method we developed manipulates the workflow of the GPU from its original purpose to let the GPU parallelize the calculations with a minimal coding effort and without having to handle problems related to parallel computations. That is, there is no need to code a complicated program for parallelization and to take care of all related problems (such as concurrency access). Figure 2: **GPU workflow for the lateral \(Z\) direction filtering of surface atoms. ** (**A**) For demonstration purposes, an example system of just five atoms is considered. Left, vertex processing: every vertex is placed in the clip space coordinate system by the vertex shader. Its attributes are transferred to the next step. The attributes used in classical rendering are written in blue. The attribute used in our filtering method, an index for tracking the atom, is written in red. Middle, rasterization: for each triplet of vertices, a triangle is formed, and fragments are generated based on the pixels covered by the triangle. The attributes of newly generated fragments result from the interpolation (or not) of the attributes of the three vertices. The depth test is applied to distinguish fragments in the front from others behind. Right, fragment processing: all fragments, which can now be viewed as pixels, enter the fragment shader. In classic rendering, the color is computed and rendered to the screen. In our filtering method, the index attribute of the fragment, inherited from the vertex of the atom covering this fragment, is written in a grid texture which can further be read on the CPU. The final grid texture contains, for each pixel, the tracking index of the atom closest to the viewer within this pixel position. (**B**) Left: molecular structure of the Cas9 endonuclease protein (from PDB 40C08) in the scanning view perspective showing the atoms that are probed by the AFM scanning tip. Right: molecular structure in the front view perspective. The AFM substrate surface is indicated by the thick gray line. The surface atoms remaining after filtering (\(\sim\)24% of total atoms) are shown in red color. (**C**) Simulated AFM image for the scanning view in (**B**), computed from the set of filtered atoms. For this method, each atom is represented by a point primitive with the 3D position and corresponding Van der Waals radius as attributes. The rendering texture corresponds to the scanning grid (Figure 1A, red grid) in which each cell represents one pixel. The vertex shader operates in the same way as during filtering, i.e., vertices (in this case points) are mapped onto the clip space. Before the rasterization, vertices are intercepted by the geometry shader. The geometry shader is an optional programmable shader which takes a primitive as an input and outputs one or more primitives (which can be of a different type from the input primitive). For our purpose, we employ the geometry shader to generate for each filtered atom the corresponding tip contact sub-grid (Figure 1A, blue grid). That is, for each point primitive used as the input, the shader generates as an output a quad primitive with the size and position of the tip contact sub-grid for the corresponding atom. During the rasterization process, the obtained quads are mapped onto the pixel screen space and fragments are generated. Each fragment encodes the (X, Y) pixel position and the attributes of the point primitive it originated from, i.e., the corresponding atom position (x, y, z) and Van der Waals radius.