Method for implementing interactive ship spray simulation coating thickness accurate rendering
Patent Information
- Application Number
- CN202211570109.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-08
- Publication Date
- 2026-09-15
- Estimated Expiration
- 2042-12-08
AI Technical Summary
[0003]本发明针对现有技术中船舶部件模型较大、网格稀疏造成的喷涂涂层仿真困难,与实际喷涂过程中涂层累积难以完全一致,降低船舶涂装培训的真实性与沉浸感的不足,提出一种交互式船舶喷涂仿真涂层厚度精确渲染实现方法,根据船舶模型的高分辨率贴图提升涂层厚度的计算精度,利用邻接像素的透明度填充涂层裂隙,提升喷涂仿真的真实感,计算速度更高能满足交互式喷涂仿真及机器人喷涂仿真
[0020] Compared with existing technologies, this invention uses high-resolution texture maps to store the coating thickness on ship component models with large meshes, and uses the transparency of adjacent pixels to fill coating gaps, significantly improving the realism of spraying simulation.
Smart Images

Figure CN115731333B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a technology in the field of computer-aided design, specifically a method for accurately rendering the coating thickness in an interactive ship painting simulation. Background Technology
[0002] Ship painting is one of the three pillar processes of shipbuilding. However, the painting process generates pollution and paint waste. To meet the demands for green ship painting, interactive simulations of ship painting in virtual environments can be used in training to achieve green ship painting while effectively improving the technical skills of ship painting personnel. However, the prerequisite for using interactive simulations in ship painting training is realism; the coating thickness must continuously change during the spraying process, and the corresponding brightness and color must not deviate from reality. Summary of the Invention
[0003] This invention addresses the difficulties in simulating coating thickness in existing ship component models due to their large size and sparse mesh, which makes it difficult to completely match the coating accumulation during actual spraying and reduces the realism and immersion of ship painting training. It proposes an interactive ship spraying simulation method for accurate coating thickness rendering. This method improves the calculation accuracy of coating thickness by using high-resolution textures of the ship model, and fills coating gaps using the transparency of adjacent pixels, enhancing the realism of the spraying simulation. The method also boasts higher calculation speed, meeting the requirements of interactive spraying simulation and robotic spraying simulation.
[0004] This invention is achieved through the following technical solution:
[0005] This invention relates to an interactive ship spraying simulation coating thickness accurate rendering method. At least three high-definition texture maps are created based on the mesh model of the ship component. The coating thickness accumulation rate at each point on the ship component model is calculated based on the spray gun pose, the sampling point position and normal vector of the ship component model, the spray gun flow rate and the spray gun flow rate distribution in the virtual scene. The thickness data is recorded in the texture map in real time. After texture gap elimination processing, the coating is displayed to achieve accurate rendering.
[0006] The mesh model is preferably a triangular mesh model.
[0007] The high-definition texture map refers to a texture map with a sampling point count much higher than the grid point count of the mesh model and defined on the UV coordinate system, which can cover the corresponding model. The pixel color format of the texture map is ARGB.
[0008] The spray gun pose refers to: establishing a spray gun coordinate system with the center of the spray gun nozzle as the origin, the spray gun orientation as the positive x-axis, and the area directly above the nozzle as the positive y-axis, and the homogeneous transformation matrix of the spray gun coordinate system relative to the world coordinate system.
[0009] The sampling point position and normal vector of the ship component model mentioned above refer to the coordinates of the point on the ship component model corresponding to each point on the high-definition texture map in the world coordinate system and the normal vector of the face where the point is located.
[0010] The spray gun flow rate refers to the volume of liquid sprayed by the spray gun per unit time.
[0011] The spray gun flow distribution refers to the distribution of the ratio obtained by dividing the volume of liquid ejected from the nozzle at a point on a plane parallel to the nozzle outlet section at a certain distance from the nozzle outlet within the maximum spraying distance of the spray gun at the same time by the total volume of liquid ejected from the nozzle through the plane.
[0012] The cumulative rate of coating thickness is obtained in the following way:
[0013] 1) Collect the UV coordinates of each unobstructed sampling point in the texture map corresponding to the ship component model, and convert the UV coordinates into 3D coordinates P = (x, y, z) and normal vector.
[0014] 2) Calculate the distance between the spray gun and the sampling point based on the position Q of the spray gun. With direction in: Let P be the vector from Q. for The model, for , unit vector;
[0015] 3) When the distance dis between the spray gun and the sampling point is greater than the maximum spraying distance dis of the spray gun max At that time, the cumulative coating thickness rate at each point on the ship component is 0 m / s; when the distance dis between the spray gun and the sampling point is less than or equal to the maximum spraying distance dis of the spray gun... max At that time, based on distance dis and direction The spray gun flow rate and flow distribution determine the cumulative coating thickness velocity v at the sampling point, and then calculate... and The inner product is used to obtain the cumulative coating thickness rate at each sampling point on the ship component.
[0016] The aforementioned real-time recording refers to converting the pixel colors R, G, and B at the corresponding sampling points of a texture map into decimal numbers. s=R*255*255*255+G*255*255+B*255, the cumulative thickness rate of the paint at this point is divided by the frame rate to obtain the thickness increase value Δh at this moment. In each frame, the decimal number at the corresponding sampling point of the texture map is increased by the corresponding thickness value, and then converted back to the color value to complete the recording of thickness data.
[0017] The aforementioned texture crack elimination specifically includes:
[0018] 1) Select two more high-resolution texture maps, TextureA and TextureB, that do not contain thickness data. Set their initial color to the model color. Divide the thickness data of each point obtained by the maximum coating thickness to obtain the interpolation ratio. If the thickness data is greater than the maximum coating thickness, the ratio is set to 1. Interpolate the color of the corresponding point of TextureA according to the interpolation ratio, with the sprayed paint color as the target.
[0019] 2) For all pixels in TextureA, if the transparency A of a pixel in TextureA is ≥ 0.5, directly draw the high-resolution textureA onto the high-resolution textureB for rendering and display; otherwise, obtain the color values of the four adjacent pixels col0, col1, col2, and col3, and calculate the weighted average of the RGB values of the four pixels according to their respective transparency Alpha values to obtain a new color value. Then, draw TextureA onto another textureB for rendering and display. When calculating the new color value in each frame, the color values of the four adjacent pixels used are the color values calculated in the previous frame. Technical effect
[0020] Compared with existing technologies, this invention uses high-resolution texture maps to store the coating thickness on ship component models with large meshes, and uses the transparency of adjacent pixels to fill coating gaps, significantly improving the realism of spraying simulation. Attached Figure Description
[0021] Figure 1 This is a schematic diagram of the spray gun spray flow distribution for an example.
[0022] Figure 2 This is a schematic diagram of the process of the present invention;
[0023] Figure 3 This is a schematic diagram of a scenario for an example embodiment;
[0024] Figure 4 This is a standard error diagram of the information from 30 sampling points in Example 1. Detailed Implementation
[0025] like Figure 1As shown, the spray gun parameters in this embodiment are: nozzle angle θ = 43°, spray gun flow rate Q = 0.00233 L / s, and the air spraying paint utilization rate is set to 40%. When the spray gun is stationary, the paint sprayed onto a flat plate parallel to the nozzle cross-section is rectangular in shape, with an aspect ratio L:W = 10:1. The coating thickness is the same along the width direction, and the coating thickness along the length direction follows a parabolic distribution. δ0 is the thickness at the center. The calculated cumulative rate of coating thickness at the point where the projection of the coating onto the long side of the rectangle at a distance d from the center is:
[0026] like Figure 2 As shown in this embodiment, an interactive ship painting simulation coating thickness accurate rendering method is implemented, including the following steps:
[0027] 1) Import the ship's deck and spray gun models. Use Unity to import the deck and spray gun models. The imported deck model is a triangular mesh model, and the color is gray.
[0028] 2) Set up the camera and materials, and prepare the C# script and Unity shader.
[0029] 2.1) Bind a spray gun model to a spraying camera and a depth detection camera. Set the minimum and maximum spraying distances of the spraying camera to 0.01m and 0.2m respectively, and the camera's vertical FOV to 43°. Attach a script, Drawer.cs, to the spraying camera to control the movement and spraying of the spray gun, setting the frame rate to 1000FPS. Bind two materials, Drawing Mat and Thickness Mat, to the script. The Drawing Mat is created by the Drawing shader and used for coating rendering and display; the Thickness Mat is created by the Thickness shader and used for coating thickness recording. For the depth detection camera, create a 2048×2048 texture image with a depth of 16 and an RFloat format as the target texture for the camera. Use a depth detection shader to store the depth of the image acquired by the depth detection camera in the depth texture image.
[0030] 2.2) Attach the script Drawable.cs to the deck model to show that the deck has been painted and to remove coating cracks.
[0031] 3) Create three high-resolution texture maps. In Drawable.cs, create two 4096×4096 texture maps, output1, output2, and output3, with a depth of 0 and an ARGB32 format. These will be used to display the coating on the deck and eliminate coating cracks. The initial color is gray. Output1 will be used as the Drawing Mat output during program execution. Create one 1024×1024 texture map, outputThickness, with a depth of 0 and an ARGB32 format. This will be used to record the coating thickness. The initial color is black. OutputThickness will be used as the Thickness Mat output during program execution.
[0032] 4) Calculate the cumulative coating thickness rate at each point on the texture map.
[0033] 4.1) Rewrite the fragment function `frag` in the Drawing shader and Thickness shader, passing the vertex's world coordinates `P`, UV coordinates `P.uv`, and fragment normal vector to the `frag` function. The position G of the spray gun nozzle and the positive direction the nozzle is pointing. The spray gun should be pointed at a vertical angle of 90°. Camera vertical FOV, spray gun flow rate Q, calculate GP in Projection on GP in Projection on and GP Projection on Then, based on the parabolic distribution, the cumulative rate of coating thickness at point P is calculated as follows:
[0034] 4.2) Convert the world coordinates of the vertex to screen space coordinates, and then use depth texture mapping combined with the camera's field of view to determine the visibility of vertex P. If the coating thickness accumulation rate at the visible point P is v... p If it is not visible, then it is 0.
[0035] 5) Record the coating thickness in the thickness texture map. In the fragment function `frag` of the Thickness shader, obtain the RGB values of each pixel: `col.r`, `col.g`, and `col.b`, and calculate `sum = col.r * 255 * 255 * 255 + col.g * 255 * 255 + col.b * 255 + v`. p / 1000, then convert back to RGB values and save.
[0036] 6) Draw the coating on the rendered realistic texture map and remove the cracks.
[0037] 6.1) Write a FillCrack shader and set the corresponding material to remove cracks. In this shader, rewrite the fragment function frag and take the UV coordinates of the vertex as the parameter. Select the color at the vertex as col, and the colors of the four pixels adjacent to the vertex as col0, col1, col2, and col3. Use the transparency of col, col.a, as the criterion. If col.a > 0.5, return col directly; otherwise, calculate a new color value. Then return the new color value;
[0038] 6.2) In the fragment function `frag` of the Drawing shader, obtain the RGB values `col.r`, `col.g`, and `col.b` for each pixel, and calculate the coating thickness `sum = col.r * 255 * 255 * 255 + col.g * 255 * 255 + col.b * 255 + v`. p / 1000, the ratio of thickness sum to spray sag threshold is used to interpolate color col towards the sprayed paint color to obtain a new color value.
[0039] 6.3) In Drawable.cs, output2 is used as the texture for rendering. The Drawing shader is used to render and color output3. Then, the FillCrack material is used to copy output3 to output2 to remove cracks. Then, output2 is copied to output1 for subsequent applications such as displaying spray training results.
[0040] Based on specific practical experiments, in Unity In the 2019.4.33.f1 environment, a 1.6m*0.8m planar area on the deck model was used for testing. The lower left corner was designated as (0, 0), and the x-axis was the horizontal axis. During spraying, the spray gun started from (0.2, 0.6) and moved laterally, spraying to (1.4, 0.6) for the first time. Subsequent sprays were applied every 0.08m in the y-direction (overlapping area width 0.075m), for a total of 6 coats. The final coat was sprayed from (0.2, 0.2) to (1.4, 0.2). Sampling points excluded the 0.1m coating thickness on the left and right sides, the first coat's trajectory, and the last coat's trajectory. Therefore, the actual sampling points ranged from (0.31, 0.21) to (1.29, 0.59), with one sampling point every 0.02m. Thus, there were 50 sampling points in the X-direction and 20 sampling points in the Y-direction, for a total of 1000 sampling points. The coating appearance after spraying was as follows. Figure 3 As shown; each 6 coats of paint constitutes a complete test, and 5 tests are conducted. The average value of the 5 tests at each point is calculated. The error between the average value and the actual coating thickness is less than 10%. Figure 4 As shown.
[0041] Compared with existing technologies, this invention improves the accuracy of coating thickness calculation based on high-resolution textures of ship models and fills coating gaps by utilizing the transparency of adjacent pixels, thereby enhancing the realism of spraying simulation.
[0042] The above-described specific implementations can be partially adjusted by those skilled in the art in different ways without departing from the principles and purpose of the present invention. The scope of protection of the present invention is defined by the claims and is not limited to the above-described specific implementations. All implementation schemes within the scope of the claims are bound by the present invention.
Claims
1. A method for accurately rendering coating thickness in interactive ship painting simulation, characterized in that, Create at least three high-resolution texture maps based on the mesh model of the ship component. Calculate the cumulative paint thickness rate at each point on the ship component model based on the spray gun pose, the sampling point position and normal vector of the ship component model, and the spray gun flow rate and distribution in the virtual scene. The thickness data is recorded in the texture map in real time, and the coating is displayed after texture crack elimination to achieve accurate rendering. The cumulative rate of coating thickness It is obtained in the following way: 1) Collect the UV coordinates of each unobstructed sampling point in the texture map corresponding to the ship component model, and convert the UV coordinates into 3D coordinates. With normal vector ; 2) Based on the position of the spray gun Calculate the distance between the spray gun and the sampling point With direction ,in: For the reason arrive The vector, for The model, for , unit vector; 3) The distance between the spray gun and the sampling point Greater than the maximum spraying distance of the spray gun At that time, the cumulative coating thickness at each point on the ship component was 0 m / s; when the distance between the spray gun and the sampling point... Less than or equal to the maximum spraying distance of the spray gun At that time, the cumulative coating thickness velocity v at the sampling point is determined based on the spray gun flow rate and flow distribution, and then the calculation is performed. and The inner product is used to obtain the cumulative coating thickness rate at each sampling point on the ship component. ; The cumulative coating thickness velocity v is obtained as follows: when the spray gun is stationary, the coating shape sprayed onto a flat plate parallel to the nozzle cross-section is rectangular, the coating thickness is the same along the width direction, and the coating thickness along the length direction is parabolic. , Given the thickness at the center, the cumulative rate of paint thickness along the projection d of any point on the long side of the rectangle from the center point is calculated as follows: , Let Q be the length of the rectangle, and let Q be the flow rate of the spray gun, which is the volume of liquid sprayed out by the spray gun per unit time. The aforementioned real-time recording refers to recording the pixel color at the corresponding sampling point of a texture map. Convert to decimal number The rate of cumulative coating thickness at this point Divide by the frame rate to get the thickness increase at that point in time. Each frame adds a corresponding thickness value to the decimal number at the corresponding sampling point of the texture map, and then converts it back to a color value to complete the recording of thickness data; The aforementioned texture crack elimination specifically includes: 1) Select two more high-resolution texture maps, TextureA and TextureB, that do not contain thickness data. Set their initial color to the model color. Divide the thickness data of each point obtained by the maximum coating thickness to obtain the interpolation ratio. If the thickness data is greater than the maximum coating thickness, the ratio is set to 1. Interpolate the color of the corresponding point of TextureA according to the interpolation ratio, with the sprayed paint color as the target. 2) For all pixels in TextureA, determine the transparency of a pixel's color. If the desired result is achieved, the high-resolution texture map TextureA is directly drawn onto the high-resolution texture map TextureB for rendering and display; otherwise, the four adjacent pixels of the given pixel are obtained. The color value is obtained by weighting the RGB values of the four pixels according to their respective transparency alpha values. Then, the texture map TextureA is drawn onto another texture map TextureB for rendering and display. When calculating the new color value in each frame, the color values of the four adjacent pixels are used as the color values calculated in the previous frame.
2. The interactive ship painting simulation coating thickness accurate rendering method according to claim 1, characterized in that, The mesh model described is a triangular mesh model.
3. The interactive ship painting simulation coating thickness accurate rendering method according to claim 1, characterized in that, The spray gun pose refers to: establishing a spray gun coordinate system with the center of the spray gun nozzle as the origin, the spray gun orientation as the positive x-axis, and the area directly above the nozzle as the positive y-axis, and the homogeneous transformation matrix of the spray gun coordinate system relative to the world coordinate system.
4. The interactive ship painting simulation coating thickness accurate rendering method according to claim 1, characterized in that, The sampling point position and normal vector of the ship component model mentioned above refer to the coordinates of the point on the ship component model corresponding to each point on the high-definition texture map in the world coordinate system and the normal vector of the face where the point is located.
5. The interactive ship painting simulation coating thickness accurate rendering method according to claim 1, characterized in that, The spray gun flow distribution refers to the distribution of the ratio obtained by dividing the volume of liquid ejected from the nozzle at a point on a plane parallel to the nozzle outlet section at a certain distance from the nozzle outlet within the maximum spraying distance of the spray gun at the same time by the total volume of liquid ejected from the nozzle through the plane.