Application of Automatic Analysis of Image Data Based on KD-Tree in Ray Tracing Technology

. In the field of computer graphics, ray tracing technology is widely used to generate high-quality "photo-level" images. The automatic analysis of KD-Tree image data is the data structure of dividing K-dimensional database space, and it has important application in the fast search of multi-dimensional space feature vector. Based on the automatic analysis of KD-Tree image data, the reasonable and effective application in ray tracing technology can make the verisimilitude of graphics reach the leap-type change, and realize the ideal application effect.

iterate over the two subsets until all the subsets can no longer be divided.When a subset can no longer be partitioned, the data in that subset is saved to the leaf node.
In general, KD-Tree creation algorithm is designed based on serial of CPU, and adopts data structure-preorder traversal method of stack.In single-core CPU, although the theoretical time complexity of KD-Tree serial creation algorithm is O (NLOG (N)) , the creation of KD-Tree still can not meet the requirements of many applications for complex set of elements.In this paper, the parallel performance of KD-Tree creation algorithm is optimized by fully improving the original algorithm and discovering the part of parallel computation.Compared with Quadtree/Octree, it is more suitable for models with different densities.Quadtree/OCTree uses fixed-size grids to split the space, which increases the depth of the tree.For some of the space without the model also occupied the node, resulting in waste.

THE DEVELOPMENT AND APPLICATION OF RAY TRACING TECHNOLOGY
In traditional graphics rendering (rasterization) , the lighting map and shadow map are pre-calculated and then applied to the scene to simulate the appearance of the scene.Ray tracing is a rendering technique that can accurately track the path of light in a scene, compared to rasterization, it can render reflections, Refractions, Shadows and lighting effects that are believable and have a higher degree of realism and fidelity.Ray-tracing simulates how light behaves in the real world, allowing for a leap in graphic realism to create 3-d scenes that are almost indistinguishable from real life.
On the mobile side, the cost of "spoofing" shadows and reflections in a smartphone game, such as a common game engine, has become prohibitive because of the traditional rasterization method, the reflection is generated using cascading shadow maps, which require rendering the geometry on the screen multiple times and writing the shadow map lookup table to memory, all of which consume cycles and bandwidth, and generate a lot of GPU and system power consumption.By bringing advanced 3D graphics processing capabilities to mobile devices, it creates a whole new capability for the mobile graphics processing industry to realize the vision of bringing lifelike graphics content to mobile devices, and drive a new revolution in smartphones.Ray Tracing Technology is a simulation of the human eye to receive light information, in the retina formation of the image process, according to statistics, the human eye received light information is limited, normally the human eye receives about 500 million pixels, meaning that the retina's image information can be broken down into 500 million very tiny lines of light and then traced back in the opposite direction, and detect the light corresponding to the information of the scene object.
Ray-tracing technology is based on this physical principle, in the process of generating computer images, the eye simulation abstract into the scene of the camera, the retina simulation abstract into the display screen or film, the 500 million rays are reduced to film pixels, and each pixel on the film is connected to a ray from the camera position to track the light at the point where the ray intersects the object in the scene.First of all, the camera film is subdivided into a grid, like the screen pixel point, the goal is to determine each pixel point lighting information.For each pixel, the light is emitted from the camera position and tracked to the pixel point.The beam of light is then tracked to see if it intersects with the object in the scene.If intersecting, the color value of the intersection point on the surface of the object is calculated.The color value of the point is recorded as the color value of the pixel.If not, the background color of the scene is simply filled into the current pixel, and then the next pixel is processed, looping until all the pixels have a value.
Compared with the traditional raster rendering technology, the ray tracing algorithm is more clear.Taking the viewpoint as the starting point, n rays are sent to the scene, then BXDF and BRDF are calculated according to the material of the collision point, and then diffuse reflection, specular reflection or refraction are carried out, this recursion cycle until the light escape or reach the maximum number of reflection, the final N light of the Monte Carlo integration can be obtained.The clitghtsource class has four member variables representing the position of the light source, the ambient light component of the light source, the diffuse component, and the specular component.Similarly, all set and get methods provide the same functionality for subclasses of the class.Finally, there are also three virtual member functions, EvalAmbient, diffuse, and evaluular, whose names indicate their function, and all return values of type GVector3 --color.Since the calculations may vary for different types of light sources, they are set up as virtual functions in preparation for future expansion.I put the lighting calculation in the light source type here, of course, you can also put it in the object class CGObject, or you can write a separate method that takes the light source and the object as parameters, the color is calculated and returned as the final return value.

THE APPLICATION OF AUTOMATIC ANALYSIS OF IMAGE DATA BASED ON KD-TREE IN RAY TRACING TECHNOLOGY
Compared with BSP, the difference is only in the way of segmentation and end conditions, the use after segmentation and BSP are exactly the same.Since the condition of the end of segmentation does not require the formation of convex polygons, the number of leaf polygons for rendering can be freely determined.To be able to generate a new generation of graphics hardware scene organization structure.In BSP, the non-foliated node preserves the segmentation surface, which is used for rendering.So you can't use BSP for dynamic scenes.The surface in the model is used as the segmentation surface, which will bring some uncertainty to the algorithm.

CPU and GPU
The computing power of heterogeneous parallel devices is mainly embodied in three aspects: thread concurrency, thread storage resources and thread computing resources.The on-site concurrency of CPU is very low, but each thread has a lot of storage resources and rich computing resources.This means that its algorithm is better suited to allocating data, and then each thread processes the data relatively independently, known as the MIMD algorithm pattern.So the CPU thread is usually said to be a relatively heavy field.But for GPU, because of its huge number of stream processors, it needs high thread burst to make full use of these stream processors.If the burst model can not reach the high burst, it is difficult to make full use of GPU's performance.But each thread has less storage resources and less computing resources.This means that the GPU thread is a relatively lightweight thread because it can not allocate data to threads and must be executed on a module by module basis, the SIMD algorithm pattern.

In multicore cpus --multithreading
Through the way of thread, can be in dual-core, four-core CPU for a certain degree of parallelism.However, due to the limitation of the number of CPU cores, if we parallelize the fourth layer of KD-Tree in the same way, we will not get the ideal optimization effect.Because there are eight nodes in the fourth-level KDTree and eight threads need to be created (including the main thread) , the number of threads is greater than the number of physical compute cores of the CPU.In each cycle, only half of the threads are actually working, and the CPU threads need to switch frequently.The constant switching between threads greatly reduces the creation speed of KD-Tree.

In CPU and GPU --multithreading and GPU features
The CPU is used to build the first few layers of KD-Tree.When the number of layers of KD-Tree can be parallel, the GPU is used to create the remaining layers of KD-Tree.Compared with the traditional algorithm, the parallelism of this algorithm is greatly improved, but its running speed is similar.There are two main reasons for this: in the process of switching from CPU to GPU creation, a large amount of memory data is transferred from main memory to video