Large-scale Aerosols Visualization Based on the Accelerated Ray Casting Algorithm

: The ray casting algorithm is a widely used basic volume rendering algorithm, but traditional ray casting algorithms have some disadvantages such as low efficiency, slow speed and large resource consumption when rendering aerosol data such as smoke, fog and dust in 3D scenes. In this regard, this paper proposes a large-scale aerosol visualization method based on a ray-casting acceleration algorithm. A large part of the computational work in a traditional ray casting algorithm is to compute a large volume of data from the underlying scalar field. Therefore, the accelerated design of the ray casting algorithm should first consider avoiding sampling of empty spaces and invalid voxels, and culling areas in the volume data that do not contribute to volume rendering. The method in this paper firstly optimizes and accelerates the traditional ray casting algorithm through the hierarchical bounding box tree, and combines the illumination model to enhance the color rendering of each voxel. Unnecessary space debris reduces hardware load, improves rendering speed, and meets the real-time rendering requirements of large-scale aerosols.


Introduction
The Volume rendering [1] technology is a technology that displays all volume details on a two-dimensional image at the same time based on three-dimensional volume data. Using volume rendering technology, the comprehensive distribution of various substances can be displayed in one image, and the condition of the isosurface can be reflected by controlling the opacity. Volume rendering is widely used in medical CT imaging, real-time meteorological observation, geological survey, molecular biology scanning imaging, aerospace and other fields. Today's volume rendering research field mainly focuses on how to improve the quality of the rendered image and how to reduce the rendering time of the algorithm. Usually, the rendering quality is positively correlated with the rendering time. How to reduce the algorithm rendering time as much as possible on the basis of ensuring the image quality is one of the hotspots in the current volume rendering technology research. Among many volume rendering algorithms, the ray casting algorithm calculates the highest image quality, but its algorithm complexity is higher than other volume rendering algorithms, and the rendering time is longer.
In order to improve the rendering speed of visualization, many volume rendering acceleration algorithms have been proposed. There are two commonly used methods based on software acceleration: acceleration through function optimization, such as multi-resolution based on wavelet transform [2], based on early opacity cutoff [3], based on parallel and distributed volume rendering [4], Interactive classification based on density-distance map [5], combined with graphics hardware acceleration and other algorithms, but these methods do not filter the data, and the acceleration is not complete; by processing the data to improve the drawing speed, such as based on the adjacent layers Similarity [6], based on bounding box space [7], based on octree [8], k-d tree [9] and other data structure methods, but these methods do not accelerate the algorithm process, and there is still a lot of acceleration time. room for improvement.
On the basis of related research, this paper optimizes function changes and data processing at the same time. By researching the use of algorithms to eliminate invalid data and empty voxel jumps when performing volume rendering, the rendering time is accelerated, and the image quality is guaranteed, while significantly improving Algorithm acceleration effect.

Ray Casting Algorithm
Ray Casting [10] is a direct volume rendering technique based on image sequences. The calculation of the ray casting algorithm does not stop at the surface of the object, but samples the interior of the object along the ray, and does not generate secondary rays. It draws volume data in a 3D scalar data field into a 2D image through scientific computing by tracing rays from the viewpoint to the object. The basic steps are to start from each pixel on the screen and emit a ray along the line of sight. When the ray passes through the volume data, it is sampled equidistantly along the ray direction, and the optical properties of the sampling point are calculated by interpolation (Such as color value and opacity); then according to the order from front to back (Front-to-back) or from back to front (Back-to-front), the sampling points on the ray are synthesized, and the corresponding value of this ray is calculated. The color value of the pixel on the screen.
The traditional ray casting algorithm does not filter the initial data, but draws the sampling points one by one layer by layer, which makes the process of calculating the ratio of each voxel to the screen pixel and so on consumes computing resources and time. In this regard, the acceleration design of ray casting algorithm is discussed from three aspects: sampling point optimization, empty voxel jumping method and the combination of the two improved methods.

Empty Voxel Skipping
The purpose of empty voxel skipping is to exclude from volume data sampling the regions in which it does not contribute to the output image. A state-of-the-art imagesequential volume rendering method, GPU-based octreeaccelerated ray casting [11], traces each ray from one tree node to another. Nodes marked as empty can simply be skipped, and each ray is computed independently, without exploiting consistency between rays or between successive rendered frames. More importantly, for sparsely structured volume data, the octree subdivides the space very finely, and many spatially adjacent nodes will have the same type (empty or not). Advanced tree refinement forces ray traversal to occur in unnecessarily small spatial increments. This huge overhead makes empty voxel skipping inefficient and significantly reduces the potential performance improvement. Spatial segmentation based on K-D tree [12] can better adapt to the spatial subdivision of sparse structure, but the subdivision based on K-D tree is very dependent on the spatial position of non-empty voxels. If the dataset of segmented objects changes frequently, the K-D tree cannot change in real time according to new spatial features. Hierarchical bounding box tree (BVH) [13] can perform efficient space segmentation, fully consider the area and shape of the volume data itself, filter out a large amount of unnecessary blank space, and can be dynamically updated.

Early termination of light
Use an early termination condition to speed up the algorithm, i.e. stop the compositing operation when the cumulative opacity exceeds 1. In the process of pixel mixing iterative solution, the value of opacity a is gradually increased. When the value of a is close to 1, it means that the calculation result of the pixel value by the light tends to be saturated, even if the sampling continues, the final pixel value almost unaffected. Therefore, the method of terminating the ray calculation early can be used, which can improve the overall drawing time. A threshold can be set. As long as the value of a exceeds this threshold, the ray will be terminated. At the same time, combined with the adaptive accelerated sampling method, that is, when the ray traverses the volume data, if it encounters an invalid sampling point, the sampling interval is appropriately increased. Reduce the resampling frequency, and restore the resampling frequency if a valid sampling point is encountered. The overall rendering time can be further improved by combining early ray termination with adaptive sampling acceleration.

OC tree
In the case of a large amount of data, it is more difficult to use the determination of the minimum granularity (leaf node). When the granularity is large, the data volume of some nodes may still be relatively large, and the subsequent query efficiency is still relatively low. On the contrary, the granularity is small. The depth of the fork tree increases, the required memory space is relatively large (each non-leaf node requires eight pointers), and the efficiency is also reduced. The division basis of equal division makes the efficiency not too high due to the limitation of division depth when the data center of gravity is skewed.
The empty voxel jumping method based on the octree structure, that is, recursively divides each block of volume data into eight parts, and records the in and out points of each block of non-empty data that the light passes through to sample. However, the octree-based method will additionally record many empty nodes, which increases the computational complexity of sampling.

AABB bounding box tree
The hierarchical bounding box is referred to as BVH; and the hierarchical bounding box tree is a binary tree used to store the shape of the bounding box. Its root node represents the largest bounding box, and the next 2 child nodes represent 2 sub-bounding boxes.
The AABB bounding box is an axisymmetric bounding box, that is, the six faces of the box are parallel to the xy, xz, yz planes

Figure 1. Bounding Volume Hierarchy
Subdivide the body data with an improved bounding box structure, with each leaf node corresponding to a subblock of data. In the sub-division process, each sub-data block needs to be expanded by a voxel to avoid errors during boundary interpolation (the value obtained by interpolation may be greater than the maximum value of the original sub-data block or smaller than the minimum value of the original sub-data block. ), and then count the minimum and maximum values of each sub-data block, and store them in the original bounding box structure for generating 3-dimensional textures.

Improvement to empty voxel skipping
Recursively divide each block of data into eight parts to form an octree. For the volume data block of each leaf node, the marked attribute is one of empty, non-empty, and unknown; for each non-leaf node, the attribute proportion of its child nodes is counted, and its attribute is assigned as proportion highest attribute.
Perform a breadth-first search on the octree of the volume data, and construct a bounding box for the volume data blocks whose attributes are different from their parent nodes.
For each ray, when it passes through the bounding box, it is merged and deleted according to the rules to determine the sampling range. Volume rendering of ray casting algorithm using lazy loading method

Grouped linear interpolation
The traditional linear interpolation calculation process is quite complicated and consumes a lot of computing resources, which is the main reason why the traditional ray casting algorithm cannot draw in real time In the interpolation calculation stage, all resampling points on a ray are divided into 3 levels according to the distance from the viewpoint, and different linear interpolation is used for each level.
Compared with the traditional algorithm, the hierarchical grouping linear interpolation method does not reduce the number of resampling points and does not reduce the authenticity of the image. According to the different positions of the resampling points on the light, it gradually decreases from the first level to the third level. The amount of interpolation calculation of each level of resampling point greatly shortens the total interpolation calculation time and achieves the purpose of improving the rendering efficiency of the algorithm.

Experiment Analysis
In this experiment, the computer configuration is AMD Ryzen 5 5600H with Radeon Graphics 3.30 GHz, Windows 10 64-bit, 16GB memory. The programming environment is Visual Studio 2019 and Unity3D, using C# programming and HLSL shading language.  Aerosol particles have the characteristics of uneven distribution, small variation scale and complexity. In this paper, the cloud is used as a representative to conduct experiments. Comparing the algorithm in this paper with the traditional ray casting algorithm, it can be seen that under the same cloud data. Compared with the traditional ray casting algorithm, the acceleration algorithm in this paper is better in rendering results, with more details, more obvious diffuse effect, and more obvious distinction between light and dark. At the same time, the acceleration algorithm in this paper has better performance in terms of accuracy and realism.

Conclusion
In order to solve the shortcomings of traditional ray-casting algorithm when drawing aerosol data such as smoke, fog and dust in 3D scenes, it has some disadvantages such as low efficiency, slow speed and large resource consumption. This paper proposes a large-scale aerosol visualization method based on ray casting acceleration algorithm, optimizes resampling, performs hierarchical grouping operations on the sampled resampling points, and uses the hierarchical bounding box algorithm to segment the space, and then uses empty voxels to jump. The method culls empty space and invalid voxels, avoids unnecessary space fragmentation, reduces hardware load, and improves rendering speed. Comparing the algorithm in this paper with the traditional algorithm, in terms of rendering speed, with the increase of the amount of data, the advantage of the algorithm in this paper is also increasing. At the same time, the algorithm in this paper has better performance in terms of authenticity and accuracy. The experimental results show that the algorithm in this paper is feasible, effective and stable.