## 2 Materials and Methods
### GPU-Based Lateral \(Z\) Direction Filtering of Surface Atoms  
We developed an efficient method to filter the surface atoms in the lateral \(Z\) direction (i.e., in the vertical scanning direction of a biomolecular structure) based on graphics processing unit (GPU) computations. The underlying idea is that for any arbitrary 3D molecular orientation of a biomolecular structure, the set of atoms which are directly exposed to the scanning tip and can potentially come into contact with it, contains exactly those which are displayed by rendering the corresponding graphical 2D view. To visualize objects on the computer screen, graphic cards work with vertices and primitives. A primitive is the smallest unit used to build geometrical forms. Four main primitives are generally used: points, lines, triangles, and quads. To visualize atoms of a biomolecular structure as spheres (with corresponding Van der Waals radii) we use triangles as primitives. Spheres are therefore represented by a set of triangles, each of them having three vertices with attributes such as spatial position (x, y, z), orientation normal vector, color, etc. In the first step, the GPU processes all vertices with their attributes via the vertex shader [23; 24] (Figure 2A). The vertex shader places the vertices relative to each other in the clip space, a GPU internal 3D coordinate system with coordinates ranging from \(-1\) to \(1\) that can be viewed as a 3D version of what will become the visible screen. Vertices having clip coordinates beyond this range will be later clipped out of the scene. The vertex shader is programmable, and the programmer has full control of it. After processing all vertices, the GPU groups them to form the corresponding triangles in the clip space, and then proceeds with rasterization. Rasterization is the process by which the GPU transforms the 3D clip space into what will become the visible screen space, i.e., a 2D canvas of pixels (Figure 2A). Rasterization consists of determining which pixels are covered by a particular triangle and generates so called fragments accordingly. A fragment is characterized by the 2D position of the pixel it belongs to, plus the attributes inherited from the vertices of the triangle including the interpolated clip space z-coordinate interpreted as the depth value of the fragment by the GPU. During the processing of all triangles, many fragments will obviously share the same pixel position. However, an early depth test allows us to compare the depth of a newly generated fragment with that of the current fragment for a given pixel position, keeping only the least deep fragment. In such a situation, the result of the rasterization process is a pixel grid which consists of filtered fragments, each fragment representing the least deep position for a given pixel. Finally, all remaining fragments from the previous rasterization process undergo fragment shading to determine a color for the processed fragment (Figure 2A). The normal and color attributes are usually used to compute light effects, and the 4D output vector from the fragment shader (RGB values plus opacity) will be interpreted by the GPU as a color for a particular pixel. In the context of visualizing a biomolecular structure, completed fragment shading would result in rendering the Van der Waals representation on the computer screen (render to screen pathway). That is, for a given molecular orientation, only the visible atoms are displayed and separated from the hidden non-visible atoms. Obviously, this separation would exactly correspond to filtering the subset of atoms that would be accessible to the scanning tip in that particular 3D orientation. Since, similar to the vertex shader, the fragment shader is programmable, we are able to implement the desired atom filter algorithm for S-AFM. This is possible by bypassing the rendering process and directing the fragment shader output to a texture (render to texture pathway), which can be viewed as an off-screen grid of pixels that can be read on the central processing unit (CPU).