Search

CN-121564169-B - Synchronous updating and real-time rendering method based on tri-pixel model

CN121564169BCN 121564169 BCN121564169 BCN 121564169BCN-121564169-B

Abstract

The invention discloses a synchronous updating and real-time rendering method based on a tri-pixel model, which relates to the field of computer graphics and numerical control processing simulation, and comprises the steps of initializing a workpiece model, establishing the tri-pixel model, converting the tri-pixel model into voxel data and loading the voxel data into a GPU; the tri-pixel model is dynamically updated according to a cutter path in processing, voxel data are synchronously transmitted to the GPU, a visual line is projected from a camera to pixels in rendering, the GPU parallelly judges the intersecting condition, triangular patches are reconstructed and colored when intersecting, and the pixels are colorless when not intersecting.

Inventors

  • SHEN BIN
  • YUE TING
  • ZHANG HAOBO
  • Xu Lianyuan
  • CHEN SULIN
  • JIN SUN
  • LIU SHUN

Assignees

  • 上海交通大学

Dates

Publication Date
20260505
Application Date
20260121

Claims (6)

  1. 1. The synchronous updating and real-time rendering method based on the tri-model is characterized by comprising the following steps of: step 1, initializing a workpiece model, establishing a tri-pixel model of the workpiece, converting the tri-pixel model into voxel data, and loading the voxel data into a GPU video memory; Step 2, judging a material increasing and decreasing area according to a cutter path in each rendering frame in the machining process, and executing dynamic updating operation on the tri-pixel model, wherein the dynamic updating operation comprises point removal and point addition; Step 3, immediately synchronizing the voxel data after dynamic updating to the GPU; Step 4, performing visual rendering processing, projecting a sight line from the camera to each pixel of the screen, and judging whether each sight line intersects with a voxel; step 5, if the judgment result is that the sight line intersects with the voxel, reconstructing a local triangular patch in real time according to voxel information near the intersection point of the sight line and the voxel, calculating the normal vector and the corresponding color of the triangular patch, and coloring the pixel by using the calculation result; Step 6, if the judgment result shows that the sight line does not intersect with the voxels, the pixel point is kept colorless; step 7, repeatedly executing the steps 4 to 6 until all pixels of the screen are processed, and outputting a final rendering result; Loading an initial STL file of a workpiece, defining a boundary range and a sampling interval of the model, calculating the boundary range and a triangular patch normal vector of the model, and constructing a complete Dexel structure through Dexel Boolean operation in three directions of X, Y, Z and three-way Dexel sampling to obtain a tri-Dexel model; The method comprises the specific processes of converting a tri-pixel model into voxel data in the step 1, namely, establishing a three-dimensional voxel grid matched with a pixel sampling interval, traversing X, Y, Z Depixel data in three directions, calculating coverage of intersecting line segments on each ray in a voxel space, mapping a line segment starting point and a line segment ending point to corresponding voxel indexes, calculating density values of voxels, and simultaneously processing normal vector information to generate 12-channel voxel data comprising three directional density fields and a complete normal vector field; When the density value of the voxel is calculated, a UInt coding mode is adopted, floating point density values in the range of 0-1 are multiplied by 255 and rounded upwards, and the floating point density values are mapped to the integer range of 0-255; When the normal vector information is processed, the normal vector is normalized and shifted from the floating point range of [ -1,1] to the range of [0,1], then converted into UInt format for storage, the surface normal vector of the line segment end point is assigned to the corresponding boundary voxel, and the normal vector is smoothly transited in the surface area through the neighborhood diffusion algorithm.
  2. 2. The method for synchronously updating and rendering in real time based on a tri-model of claim 1, wherein the visualized rendering in step 4 adopts a voxel-based RAYMARCHING rendering method comprising GPU data initialization, camera system setup, line-of-sight ray generation, three-way voxel sampling, surface reconstruction and coloring, and background color processing.
  3. 3. The method for synchronously updating and rendering real time based on a tri-model of claim 2, wherein the camera system is configured to define the position and direction of the camera, calculate the view matrix and the projection matrix, and set the near clipping plane and the far clipping plane of the camera.
  4. 4. The synchronous updating and real-time rendering method based on the tri-pixel model according to claim 3, wherein the specific process of generating the sight ray is that the ray direction corresponding to the pixel is calculated, the ray starting point and the initialization stepping parameter are determined, then the judgment of the ray stepping sampling cycle is carried out, if the cycle is judged to be ended, the background color processing is directly carried out, otherwise, the three-way voxel sampling is carried out.
  5. 5. The synchronous updating and real-time rendering method based on the tri-model of claim 4, wherein the three-dimensional voxel sampling specifically comprises the steps of starting from a near clipping surface, performing step sampling to a far clipping surface, calculating the position of a current sampling point, sampling from volumeX, volumeY, volumeZ textures, obtaining the density of the sampling point through tri-linear interpolation, performing threshold detection on the density, judging whether the density is greater than a preset threshold, if so, performing surface reconstruction and coloring, otherwise, returning to the judgment of a ray step sampling cycle.
  6. 6. The synchronous updating and real-time rendering method based on the tri-model according to claim 5, wherein the specific contents of surface reconstruction and coloring are that normal vector textures are sampled, diffuse reflection illumination and high illumination are calculated by combining the view angle direction and the light source information, and preset material and color parameters are applied.

Description

Synchronous updating and real-time rendering method based on tri-pixel model Technical Field The invention relates to the field of computer graphics and numerical control machining simulation, in particular to a synchronous updating and real-time rendering method based on a tri-model. Background In the fields of computer graphics and numerical control machining simulation, the geometric form of a workpiece can be changed in real time and in a complex manner along with a cutter path in the machining processes of numerical control milling, additive manufacturing and the like. The high-reality and low-delay visualization of the dynamic model is a key link for realizing on-line monitoring and process optimization. Especially when processing high-value parts, the real-time performance of rendering and the accuracy of the model directly determine the credibility and practicability of the simulation system. If the visual effect is distorted or the response is slow, the real processing state can be covered up, so that the process decision is wrong, and a great amount of time and resources are wasted, therefore, the construction of a real-time rendering scheme capable of accurately reflecting the dynamic change of the model and smooth is important. There are significant limitations to the current mainstream real-time rendering methods. The method is based on the Boolean operation of the triangular mesh model, when the model topology is frequently changed, huge calculation load is needed, high frame rate is difficult to maintain, real-time requirements cannot be met, and applicability is extremely poor in a scene of continuous evolution of the model form in the processing process. The other type is a traditional voxel method, and although model updating logic is simplified, the problems of low model precision and easy occurrence of saw-tooth flaws on boundaries are generally existed, the memory consumption is extremely high, and meanwhile, a general mechanism for efficiently managing and synchronizing voxel data on a GPU is lacked, so that the method is difficult to be applied to a dynamic high-precision processing scene. The prior art cannot satisfy the requirements of high-precision visualization with arbitrary geometric shapes and dynamic material increasing and decreasing processes, and cannot satisfy the dynamic update efficiency, model representation precision and running performance, so that a general real-time rendering method capable of fully considering model dynamic changes and directly synchronously updating voxel data on a GPU is needed to solve the technical pain. Disclosure of Invention The invention aims to provide a synchronous updating and real-time rendering method based on a tri-pixel model, which solves the problem of real-time rendering of a high-precision model in a dynamic processing scene in the prior art. In order to achieve the above object, the present invention provides a method for synchronously updating and rendering in real time based on a tri-model, comprising the steps of: step 1, initializing a workpiece model, establishing a tri-pixel model of the workpiece, converting the tri-pixel model into voxel data, and loading the voxel data into a GPU video memory; Step 2, judging a material increasing and decreasing area according to a cutter path in each rendering frame in the machining process, and executing dynamic updating operation on the tri-pixel model, wherein the dynamic updating operation comprises point removal and point addition; Step 3, immediately synchronizing the voxel data after dynamic updating to the GPU; Step 4, performing visual rendering processing, projecting a sight line from the camera to each pixel of the screen, and judging whether each sight line intersects with a voxel; step 5, if the judgment result is that the sight line intersects with the voxel, reconstructing a local triangular patch in real time according to voxel information near the intersection point of the sight line and the voxel, calculating the normal vector and the corresponding color of the triangular patch, and coloring the pixel by using the calculation result; Step 6, if the judgment result shows that the sight line does not intersect with the voxels, the pixel point is kept colorless; and 7, repeatedly executing the steps 4 to 6 until all pixels of the screen are processed, and outputting a final rendering result. Preferably, the specific process of establishing the tri-Dexel model of the workpiece in the step 1 comprises the steps of loading an initial STL file of the workpiece, defining a boundary range and a sampling interval of the model, calculating the boundary range and a normal vector of a triangular patch of the model, and constructing a complete Dexel structure through Dexel Boolean operation in X, Y, Z directions and three-way Dexel sampling to obtain the tri-Dexel model. Preferably, the specific process of converting the tri-pixel model into voxel data in the step 1 is that a thre