Smoothing method, device and electronic equipment for voxel model

By calculating new vertex and normal parameters in the voxel model and combining them with lighting effects, the smoothing problem of the voxel model was solved, achieving a visually smooth effect and optimizing storage and video memory usage.

CN116797486BActive Publication Date: 2026-05-12LAYABOX NETWORK TECH (BEIJING) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
LAYABOX NETWORK TECH (BEIJING) CO LTD
Filing Date
2020-04-27
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In existing technologies, 3D models constructed through voxel editing are prone to pixelation or mosaic visual effects, making it difficult to achieve a smooth effect.

Method used

By determining the vertex coordinate parameters to be smoothed in the voxel model, a preset smoothing algorithm is applied to calculate new vertex coordinates and normal parameters, and the original vertex normal parameters are replaced. Smoothing is achieved in combination with lighting effects.

Benefits of technology

Without altering the voxel model architecture, a smoothing effect was achieved, making it suitable for subsequent operations and reducing storage and video memory requirements.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116797486B_ABST
    Figure CN116797486B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a smoothing method and device for a voxel model and an electronic device. In the method, a coordinate parameter of a first voxel vertex to be smoothed in the voxel model is determined; a coordinate parameter of a second voxel vertex corresponding to the first voxel vertex after smoothing is calculated based on a preset smoothing algorithm; a normal parameter of the second voxel vertex is calculated according to the coordinate parameter of the second voxel vertex; and the normal parameter of the first voxel vertex is replaced by the normal parameter of the second voxel vertex, so that the voxel model has a smooth and beautiful effect without modifying the original architecture of the voxel model.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This patent application is a divisional application of patent application number 202010347774.7, filed on April 27, 2020, and entitled "Smoothing method, apparatus and electronic device for voxel model". Technical Field

[0002] This application relates to the field of computer technology, and in particular to a smoothing method, apparatus, and electronic device for voxel models. Background Technology

[0003] A voxel is the basic unit of digital data segmentation in three-dimensional space. Voxels are used in fields such as 3D imaging, game design, scientific data, and medical imaging. Conceptually, they can be similar to pixels, the basic unit of two-dimensional space, which are used in image data of two-dimensional computer images.

[0004] 3D voxel editing allows for the assembly of 3D voxels to construct corresponding scene models, such as various electronic buildings, characters, and plants. For example, game developers can use 3D voxels to build and design various voxel models or scenes in their games. Users only need to assemble simple cubes (a representation of 3D voxels) like placing building blocks. There's no need to understand the points, lines, and surfaces that make up the cubes, nor is there any need for coding. This lowers the barrier to entry for game development and makes it accessible to a wider range of creators.

[0005] Currently, voxel models constructed using 3D voxels may result in a "pixelated" or "mosaic" visual effect (e.g., Figure 1 As shown in the figure, it may not be able to achieve the smoothness of some models built by professional software in terms of visual perception.

[0006] Therefore, after creating a voxel model using voxel editing, how to make the voxel model smoother and no longer have a mosaic-like effect without the help of additional specialized software is a problem that the industry urgently needs to solve. Summary of the Invention

[0007] In view of this, embodiments of this application provide a smoothing method, apparatus, and electronic device for voxel models, which at least solves the problem of poor smoothing effect of voxel models achieved by voxel editing in the current related art.

[0008] The embodiments of this application adopt the following technical solutions:

[0009] This application provides a smoothing method for a voxel model, comprising: determining the coordinate parameters of a first voxel vertex to be smoothed in the voxel model; calculating the coordinate parameters of a second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm; calculating the normal parameters of the second voxel vertex based on the coordinate parameters of the second voxel vertex; and replacing the normal parameters of the first voxel vertex with the normal parameters of the second voxel vertex.

[0010] This application embodiment also provides a smoothing device for a voxel model, comprising: a target vertex coordinate determination unit configured to determine the coordinate parameters of a first voxel vertex in the voxel model to be smoothed; a smooth vertex coordinate calculation unit configured to calculate the coordinate parameters of a second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm; a normal parameter calculation unit configured to calculate the normal parameters of the second voxel vertex based on the coordinate parameters of the second voxel vertex; and a normal parameter replacement unit configured to replace the normal parameters of the first voxel vertex with the normal parameters of the second voxel vertex.

[0011] This application also provides an electronic device, including: at least one processor; and a memory storing instructions that, when executed by the at least one processor, cause the at least one processor to perform the method described above.

[0012] This application also provides a machine-readable storage medium storing executable instructions, which, when executed, cause the machine to perform the method described above.

[0013] The above-described technical solutions adopted in the embodiments of this application can achieve the following beneficial effects:

[0014] The smoothing effect is cleverly achieved by changing the normals and lighting, without altering the original structure of the voxel model, which is beneficial for subsequent operations on the voxel model. Attached Figure Description

[0015] The accompanying drawings, which are included to provide a further understanding of the embodiments of this application and constitute a part of this application, illustrate exemplary embodiments of this application and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0016] Figure 1 This diagram illustrates an example of the effect of a voxel model in current related technologies.

[0017] Figure 2 A flowchart illustrating an example of a storage optimization method for voxel models according to an embodiment of this application is shown;

[0018] Figure 3 A flowchart illustrating an example of a storage optimization method for voxel models implemented using distributed storage according to an embodiment of this application is shown.

[0019] Figure 4 A schematic diagram illustrating an example of cubic layering for a voxel model according to an embodiment of this application is shown;

[0020] Figure 5A A flowchart illustrating an example of a storage optimization method for voxel models in external memory according to an embodiment of this application is shown;

[0021] Figure 5B A schematic diagram illustrating an example of the Box4 distribution in a voxel model according to an embodiment of this application is shown.

[0022] Figure 6 A flowchart illustrating an example of a storage optimization method for voxel models in video memory according to an embodiment of this application is shown.

[0023] Figure 7 A schematic diagram illustrating an example of smoothing a voxel model edited from voxels is shown.

[0024] Figure 8 A flowchart illustrating an example of a smoothing method for a voxel model according to an embodiment of this application is shown;

[0025] Figure 9 A schematic diagram illustrating an example of smoothing a voxel model according to an embodiment of this application is shown;

[0026] Figure 10 A schematic diagram showing an example of the effect of smoothing and faceting reduction of a voxel model after applying embodiments of this application is provided.

[0027] Figure 11A A schematic diagram illustrating the effect of an example of lossless surface reduction is shown;

[0028] Figure 11B A schematic diagram illustrating the effect of a lossy surface reduction is shown;

[0029] Figure 12 A flowchart illustrating an example of a face reduction process in a smoothing method for a voxel model according to an embodiment of this application is shown.

[0030] Figure 13 A schematic diagram illustrating the effect of an example of a face reduction and merging operation according to an embodiment of this application is shown.

[0031] Figure 14A flowchart illustrating an example of a face reduction process in a smoothing method for a voxel model according to an embodiment of this application is shown;

[0032] Figure 15A A schematic diagram illustrating an example of the effect of a voxel model obtained through facet reduction processing in current related techniques is shown.

[0033] Figure 15B A schematic diagram illustrating an example of the effect of a voxel model obtained through the face reduction operation of an embodiment of this application is shown.

[0034] Figure 16 A schematic diagram illustrating the effect of an example smoothed voxel model according to an embodiment of this application is shown.

[0035] Figure 17 A structural block diagram of an example storage optimization apparatus for voxel models according to an embodiment of this application is shown;

[0036] Figure 18 A structural block diagram of an example of a smoothing apparatus for a voxel model according to an embodiment of this application is shown. Detailed Implementation

[0037] Currently, traditional solutions struggle to store voxel models in extremely large scenes, limiting the application scope and customer base of voxel models. Specifically, in traditional solutions, storing the coordinate and color information (x, y, z, color) of each voxel, calculated at 4 bytes per piece of information, requires a total memory usage of 16 bytes * 260 million ≈ 3GB, making it impossible to run on mobile devices.

[0038] To make the objectives, technical solutions, and advantages of this application clearer, the technical solutions of this application will be clearly and completely described below in conjunction with specific embodiments and corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of this application.

[0039] As used herein, the term "comprising" and its variations are open terms meaning "including but not limited to". The term "based on" means "at least partially based on". The terms "one embodiment" and "an embodiment" mean "at least one embodiment". The term "another embodiment" means "at least one other embodiment". The terms "first", "second", etc., may refer to different or the same objects. Other definitions, whether explicit or implicit, may be included below. Unless explicitly indicated by the context, the definition of a term remains consistent throughout the application.

[0040] The term "vertex" can refer to the individual vertices of a voxel. The term "normal" can refer to a point normal, a line normal, or a surface normal. In a voxel model, the normal depends on the type of voxel object being lit, and the direction of the lighting corresponds to the direction of the normal.

[0041] Figure 2 A flowchart illustrating an example of a storage optimization method for voxel models according to an embodiment of this application is shown.

[0042] In step 210, the computer representation value of the color corresponding to each voxel vertex in the voxel model is obtained. Here, the computer representation value of the color can be the numerical value corresponding to the color information in the computer, and generally uint32 can be used to represent the color, which includes RGBA information. For example, 0xfffffff = white, 0xffff0000 = red.

[0043] Therefore, in a computer's storage format, if the color of each voxel vertex is stored using uint32, it will occupy 4 bytes.

[0044] In step 220, corresponding color key values ​​are defined for different color computer representation values, and each obtained color computer representation value is converted into a corresponding color key value. Here, corresponding color key values ​​are defined according to the different color computer representation values. For example, when there are 4 colors in the voxel model, corresponding color key values ​​of 0, 1, 2 and 3 can be defined for these 4 colors respectively.

[0045] In step 230, a color key value table is constructed based on different color computer representation values ​​and corresponding color key values.

[0046] A color key value table as shown in Table 1 below can be obtained as an example:

[0047] key value 0 1 2 3 Color computer representation value 0xffff0000 0xffffff00 0xff0000ff 0xffffffff

[0048] Table 1

[0049] In step 240, the color key value table and the color key value corresponding to each voxel vertex are stored in memory.

[0050] In this way, compared with the storage method of storing color computer representation values ​​using uint32 (4 bytes) in the existing technology, the storage amount of color information in the voxel model can be effectively reduced.

[0051] Specifically, referring to Table 2 below, when the number of colors in the voxel model (or the number of different color calculation representations) does not exceed 2 8When seeding, the key-value pair occupies 1 byte of memory, which can be stored using the byte data type, saving 3 bytes. When the number of colors in the voxel model does not exceed 2... 16 When storing data, the key-value pairs occupy 2 bytes of memory. You can use the short data type to store the corresponding key-value pairs, saving 2 bytes.

[0052] condition Number of colors ≤256 Color quantity ≤ 65536 Color quantity > 65536 Key-value storage method Use byte storage Use short storage No need to build a key-value table Memory usage 1 byte 2 bytes 4 bytes

[0053] Table 2

[0054] Statistics show that the number of colors in a single voxel model generally does not exceed 256 (accounting for >98%). Therefore, when the number of colors in a voxel model does not exceed 256, the color data for the voxel model only needs to be stored in one byte. When actually used, the color key-value table is then consulted, greatly reducing memory consumption and supporting voxel models in extremely large scenes.

[0055] Figure 3 A flowchart illustrating an example of a storage optimization method for voxel models implemented using distributed storage according to an embodiment of this application is shown.

[0056] In some 3D voxel scenes (such as 3D voxel sandbox games), there are a large number of repetitive blocks in the models and buildings, and the coordinates of the voxels are regular. By using distributed storage to effectively utilize the regularity of these repetitive blocks, a large amount of memory can be saved.

[0057] like Figure 3 As shown, in step 310, the voxel model is divided according to voxel cubes, and the coordinate parameters of the voxel vertices at corresponding predetermined positions in each voxel cube are determined. Each voxel cube is a cube composed of a predetermined number of voxels. Here, the predetermined positions can be predefined, such as the position of the voxel vertex at the upper left corner of the main view of the cube.

[0058] Specifically, the entire model can be divided into multiple storage structures (two or more layers) using voxel cubes. In some examples of embodiments of this application, the entire model can be divided into multiple Box4s, each Box4 being composed of 4*4*4 = 64 voxels, thus forming a two-layer storage structure. In other examples of embodiments of this application, the entire model can be divided into a three-layer storage structure, containing multiple Box32s, each Box32 containing multiple Box4s. It should be noted that the number of Boxes (or voxel cubes) (or the number of voxels contained in their sides) can be varied and adjusted according to business needs, and should not be limited here.

[0059] In step 320, for each voxel cube, it is determined whether the colors of all voxel vertices in the voxel cube are the same.

[0060] If the result of the determination in step 320 indicates that the colors of all voxel vertices in one or more voxel cubes (also referred to as the first voxel cube) are the same, proceed to step 331. If the result of the determination in step 320 indicates that the colors of all voxel vertices in one or more voxel cubes (also referred to as the second voxel cube) are not the same (i.e., there are multiple colors in the voxel cube), proceed to step 333.

[0061] In step 331, it is determined whether the first voxel cube has a set number of voxel vertices. That is, it is determined whether the first voxel cube has a complete number of voxel units. For example, there may be cases where some voxel cubes located at the edges are missing corner voxels.

[0062] If the result of the judgment in step 331 indicates that the first voxel cube has a set number of voxel vertices, proceed to step 341. If the result of the judgment in step 331 indicates that the first voxel cube does not have a set number of voxel vertices (i.e., less than the set number), proceed to step 343.

[0063] In step 341, the coordinate parameters of the voxel vertices at the set position of the first voxel cube and the color key value corresponding to the first voxel cube are stored in the memory space.

[0064] In step 343, the identification code of each voxel in the first voxel cube and the color key value corresponding to the first voxel cube are stored in the memory space, and each identification code corresponds to a voxel at a unique position in the voxel cube.

[0065] In step 333, the identifier code and corresponding color key value of each voxel in the second voxel cube are stored in the memory space.

[0066] Through the embodiments of this application, it is not necessary to store the three-dimensional coordinates (x, y, z) of each voxel in the voxel model. Only the overall coordinate parameters of the voxel cube (i.e., the coordinate parameters of the voxel vertices at the set positions of the cube) and color values ​​need to be stored. Different voxels in the voxel cube are identified by identification codes, which can reduce the amount of memory consumed by the coordinate parameters of each voxel in the voxel model.

[0067] Figure 4 A schematic diagram illustrating an example of cubic layering for a voxel model according to an embodiment of this application is shown.

[0068] like Figure 4As shown, the entire model is divided into a three-layer storage structure, containing multiple Box32s, and each Box32 contains multiple Box4s.

[0069] Combination Figure 3 The distributed storage method described in the paper only needs to store the overall coordinate information (x, y, z) of Box32, the starting coordinates of Box4, and the coordinates of each voxel in Box4. Based on the index in the container, the specific coordinate value of each voxel can be directly calculated.

[0070] Specifically, you can also refer to the storage example in conjunction with Box4 described in Table 3 below:

[0071]

[0072] Table 3

[0073] Referring to the examples in Table 3, when all voxels in the voxel cube (or Box 4) have the same color and are complete (with 64 voxels), only the color value corresponding to the entire voxel cube (Box 4) needs to be stored. When all voxels in the voxel cube (or Box 4) have the same color but are incomplete (less than 64 voxels), it is necessary to store the color value corresponding to the entire voxel cube (Box 4) and the identification code of each voxel. Each identification code can correspond to a voxel at a unique position on the cube (for example, 64 identification codes can be used to represent different voxels in Box 4), thereby marking which voxels in Box 4 are missing.

[0074] In some embodiments of this application, distributed storage and data templates can be used to construct object templates for Box4 objects of the same color. The objects can be quickly located by key-value pairs, avoiding repeated object construction and memory usage, and improving efficiency.

[0075] Is it FULL? key value template FULL color The actual object (containing the data area) NOTFULL Color + 64-bit integer The actual object (containing the data area)

[0076] Table 4

[0077] Figure 5A A flowchart illustrating an example of a storage optimization method for voxel models in external memory according to an embodiment of this application is shown.

[0078] It should be noted that after a user builds a voxel model in memory through voxel editing, the voxel model needs to be generated into a corresponding file and stored in external storage (e.g., hard drive) for later uploading to a server or other uses.

[0079] Therefore, in addition to optimizing memory space, file storage is also crucial for ultra-large-scale scenarios, and optimizing file size is equally important. Smaller file sizes not only reduce server storage pressure and network traffic but also improve file loading and parsing efficiency.

[0080] like Figure 5A As shown, in step 510, the voxel model is divided according to a voxel cube. For details regarding step 510, please refer to the reference above. Figure 3 The description of step 310 in the previous section will not be repeated here.

[0081] In step 520, each voxel cube in the voxel model is traversed to identify whether the distribution of each voxel cube in the voxel model satisfies at least one preset voxel distribution rule. Each voxel distribution rule is pre-configured with a unique corresponding voxel compression method.

[0082] In step 530, for each voxel cube that satisfies the first voxel distribution rule, it is compressed into a storage file using a voxel compression method corresponding to the first voxel distribution rule.

[0083] In step 540, the storage file is saved to external storage.

[0084] In this embodiment, the pattern of identical voxel cubes can be used for compressed storage. This is because large-scale repetition occurs in voxel editing scenarios; for example, a large area might repeatedly store green "Full" Box4s. Normal storage would require storing information for each Box4, but rule-based compression can further reduce file size. Combined with... Figure 5B The example described is the same for all Box4s, and the file size can be reduced using some compression methods.

[0085] In one example of an embodiment of this application, the voxel distribution rule includes: the existence of voxel cubes with the same color in continuous distribution exceeding a first set threshold, and / or the existence of voxel cubes with two corresponding colors in continuous interval distribution exceeding a second set threshold.

[0086] Refer to the examples of file optimization for Box4 in Table 5 below:

[0087]

[0088] Table 5

[0089] For example, when Box4 with ID number = X appears consecutively from position N to position M, it is only necessary to store "N~M, Box4, X" instead of storing the ID of each Box4, which can effectively reduce the file size.

[0090] Figure 6 A flowchart illustrating an example of a storage optimization method for voxel models in video memory according to an embodiment of this application is shown.

[0091] When rendering an image, DrawCalls are used. These are the CPU's graphical programming interface calls that instruct the GPU (graphics card processor) to perform rendering operations. Before each DrawCall call, the CPU needs to send a lot of information to the GPU, including data, status, and commands. During this stage, the CPU needs to perform many tasks, such as organizing data and checking the rendering status. Once the CPU has completed these preparations, the GPU can begin rendering. The GPU's rendering capabilities are very strong; rendering 300 triangles and 3000 triangles usually makes little difference. Effectively utilizing the GPU's rendering capabilities and reducing the number of DrawCalls can significantly improve program efficiency.

[0092] In 3D rendering, the shape of all objects depends on a point in three-dimensional space. These points are connected (connection methods include points, lines, and surfaces) to form the different shapes of three-dimensional models that we see. VertexBuffer is the vertex data of this model, called the vertex buffer. The vertex buffer is uploaded to the graphics card, and the graphics card then draws it according to some rules.

[0093] The IndexBuffer is used in conjunction with the VertexBuffer. In other words, the values ​​in the IndexBuffer are used to inform the GPU which points to use for drawing.

[0094] For example, if the following vertex data (v1, v2, v3, v4, v5) are stored in VertexBuffer, and the data in indexBuffer is (014), then the graphics card will draw a triangle composed of the three points v1, v2, and v5 in the vertex buffer.

[0095] Depending on rendering requirements, the data for each voxel vertex in video memory typically consists of coordinate parameters (x, y, z), normal parameters (normalX, normalY, normalZ), and color parameters (R, G, B, A), currently generally represented using float (occupying 4 bytes of video memory), totaling 40 bytes. If a very large scene model has 260 million voxels, each voxel is composed of 6 faces, and each face has 4 vertices, the calculated video memory usage is enormous (e.g., 260 million * 6 * 4 * 40).

[0096] In order to support extremely large models or scenes, the video memory must also be optimized to the extreme.

[0097] like Figure 6 As shown, in step 610, the color key values ​​corresponding to each voxel vertex in the voxel model are restored to their respective color computer representation values ​​according to the color key value table.

[0098] In some examples, when the model needs to be rendered, the CPU restores the color key values ​​to the original computer representation of the colors and passes them to the graphics card processor.

[0099] In step 620, the colors corresponding to the restored computer representations of each color are compared with a pre-stored color texture map array to determine the array position information of each voxel vertex's color within the color texture map array. Here, the color texture map array is an array composed of multiple color texture maps (e.g., color texture maps corresponding to all colors), such as 256*256 colors, so that all colors can be represented in the color texture map. Figure 2 Find the unique corresponding array position point in the 3D array.

[0100] In some examples, the graphics card processor can be invoked to compare the various colors in the voxel model with a pre-stored array of color texture maps to determine the corresponding array position information.

[0101] In step 630, the array position information corresponding to each voxel vertex is stored in the video memory space for later retrieval during the color rendering stage of the voxel model. This way, only the array position information needs to be stored to determine the corresponding color of the voxel vertex, without needing to record the color information (RGBA) of each voxel vertex, significantly reducing the video memory footprint of the voxel model data.

[0102] Specifically, the following steps can be used to reduce the size of 4 float values ​​(RGBA) to 2 bytes:

[0103] 1) Create a 256*256 texture map and upload all the colors used in the entire model scene, with each color occupying one pixel, to this texture, which can hold a total of 65536 colors.

[0104] 2) Use bytes to represent UV values, between 0 and 256. In the graphics card's shader language, uv / 256 is used to calculate the floating-point UV coordinates. Here, U can represent the horizontal coordinate and V can represent the vertical coordinate.

[0105] 3) By sampling this texture map using UVs, the corresponding color effect can be achieved.

[0106] In some embodiments of this application, bytes can also be used to describe coordinate information to optimize video memory space.

[0107] To reduce the memory usage of ultra-large model scenes, byte can be used instead of float to represent coordinate information, but the value range of byte is between -128 and 127.

[0108] Since each voxel in the 3D voxel system has a certain pattern, this invention uses a 128*128*128 voxel as a single draw call, and then combines it with... Figure 3 The distributed storage in the graphics card passes the initial coordinates of the voxel cube (i.e., the coordinate parameters of the voxel vertices at the specified positions) to the graphics card via the shader uniform method. The graphics card then uses its shader language to calculate the actual coordinates of each voxel vertex. For example, the definition of shaderUniform representing the overall position is:

[0109] vec3 u_vertextPostion; three float values ​​represent the overall position information.

[0110] The command word for changing the coordinates of each vertex is:

[0111] Byte3 a_position; (This value is between -127 and 128)

[0112] Therefore, the true value of this point, realPosition, is:

[0113] realPosition=u_vertextPostion+a_position;

[0114] In this way, by using the initial coordinate information of the voxel cube and the relative coordinate position of each vertex, the true coordinate position of each voxel vertex can be accurately found.

[0115] In some examples of embodiments of this application, bytes may also be used to describe normal information (or normal parameters).

[0116] In traditional 3D rendering, the normal (x, y, z) information of each point is also represented by three float values. In order to save more video memory, and taking into account the characteristics of 3D voxels, in some embodiments of this application, three bytes can be used to represent the normal information. In the graphics card's shader language, this is then divided by 128 to obtain a floating-point number to represent the vertex's normal information.

[0117] In this embodiment, the three memory optimization methods described above can be combined to compress the 40 bytes occupied by the conventional x, y, z, normalX, normalY, normalZ, R, G, G, A to 8 bytes, which is only 1 / 5 of the original size, thus saving memory space.

[0118] Figure 7 A schematic diagram illustrating an example of smoothing a voxel model edited from voxels is shown.

[0119] like Figure 7 As shown, the point in the solid black circle (i.e., 701) is smoothed to obtain the point in the hollow circle (i.e., 703) in the figure. This creates a new vertex, which changes the original regular voxel (or cube) data. It is no longer a true cube but becomes an irregular shape, breaking the original cube operation method and making it inconvenient to perform secondary editing (e.g., it is impossible to stack new cubes).

[0120] Figure 8 A flowchart illustrating an example of a smoothing method for a voxel model according to an embodiment of this application is shown.

[0121] like Figure 8 As shown, in step 810, the coordinate parameters of the first voxel vertex to be smoothed in the voxel model are determined.

[0122] In step 820, based on a preset smoothing algorithm, the coordinate parameters of the second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex are calculated. Here, various existing or potential smoothing calculation algorithms can be used, for example, such as... Figure 7 The calculation method shown is smoothed.

[0123] In step 830, the normal parameters of the second voxel vertex are calculated based on the coordinate parameters of the second voxel vertex.

[0124] In step 840, the normal parameters of the first voxel vertex are replaced with the normal parameters of the second voxel vertex.

[0125] It should be noted that the number of the first voxel vertices and the second voxel vertices can be one or more, for example, two vertices of a line or three vertices of a face, and all of these fall within the protection scope of this application.

[0126] For reference Figure 9 For example, a smoothing effect can be achieved using the following methods:

[0127] 1) A new point C can be obtained by smoothing two points A and B using a smoothing algorithm.

[0128] 2) Calculate the normal to point C, and a new normal NC is obtained.

[0129] 3) Do not modify the actual position coordinates of points A and B, only modify the normal information of points A and B to NC.

[0130] 4) Use lighting effects to make the model appear smooth.

[0131] In this embodiment, a smoothing effect is cleverly achieved by changing the normals and lighting, which does not change the original structure of the voxel, and is beneficial for subsequent operations on the voxel model.

[0132] It should be noted that during the smoothing process of the voxel model, not all faces should be smoothed indiscriminately. Instead, smoothing can be performed only on the corners and edges of the voxel model. Specifically, the edges and corners of the voxel model's surface can be identified, and the coordinate parameters of the voxel vertices corresponding to the identified edges and corners can be determined as the coordinate parameters of the first voxel vertex to be smoothed.

[0133] Furthermore, if simply passing through such Figure 9 The technical solution described in the text, after smoothing the voxel model, results in a very high number of faces, easily exceeding 100,000 triangles. Due to the limitations of graphics card performance, it cannot be used in large quantities, so face reduction processing is necessary.

[0134] As some preferred embodiments of this application, a reduction of the number of voxel faces on the surface of the voxel model can be performed. However, it should be understood that it is also feasible to perform the reduction operation first and then the smoothing operation, as long as it is done before the rendering operation, and both are within the scope of protection covered by this application.

[0135] Figure 10 An example of a voxel model after smoothing and face reduction by applying embodiments of this application is shown. It is easy to see that when the face count is reduced to 7000, the voxel model compared to... Figure 1 The existing voxel models in the software can achieve good smoothing effects, almost eliminating the mosaic style.

[0136] It should be noted that polygon subtraction algorithms are divided into lossless polygon subtraction and lossy polygon subtraction. The most basic principle of lossless polygon subtraction is to merge points on the same horizontal plane without affecting the display effect, as shown below. Figure 11A As shown, many points lie on a plane, and merging them does not affect the final display effect or shape. Lossy subtraction, on the other hand, increases the tolerance threshold; points below this threshold can be merged, as shown below. Figure 11B As shown, even though many points are not exactly on the same plane, they are still merged because they are smaller than the tolerance value. Figure 11A A schematic diagram illustrating the effect of an example of a lossless surface is shown. Figure 11B A schematic diagram illustrating the effect of a lossy surface is shown.

[0137] Figure 12 A flowchart illustrating an example of a face reduction process in a smoothing method for a voxel model according to an embodiment of this application is shown.

[0138] like Figure 12 As shown, in step 1210, it is determined whether the angle between the normals of the adjacent first voxel vertex and the second voxel vertex on the surface of the voxel model is less than the angle threshold.

[0139] In step 1220, when the included angle of the normals is less than the included angle threshold, it is assumed that one of the first voxel vertex and the second voxel vertex is eliminated, and it is determined whether the distance between the voxel vertex that is not eliminated and each voxel face with the voxel vertex that is assumed to be eliminated is less than the distance threshold.

[0140] In step 1230, when all distances are less than the distance threshold, it is determined that a reduction operation will be performed on the voxel vertex that was assumed to be reduced.

[0141] In this embodiment, a preset angle threshold and a distance threshold are used. The angle between the normals of two vertices is compared with the angle threshold to determine whether to perform a hypothetical merging (or reduction). Finally, the distance between the unmerged voxel vertices and the voxel faces with hypothetically merged voxel vertices is compared to determine whether to perform a vertex merging operation. This avoids merging two planes with significantly different orientations, ensuring the model's performance after face reduction.

[0142] Figure 13 A schematic diagram illustrating the effect of an example of a face reduction and merging operation according to an embodiment of this application is shown.

[0143] Reference Figure 13For example, we can first determine whether the normals of points P5 and P6 are less than a preset angle threshold. If the condition is met, we can then merge points P5 and P6 into a new P5+. Then we can calculate the distance from point P5+ to the surfaces T1, T2, T3, T4, and T5 before merging (which contain point P6). If the distance is less than a preset distance threshold, we can then merge points P5 and P6.

[0144] Figure 14 A flowchart illustrating an example of a face reduction process in a smoothing method for a voxel model according to an embodiment of this application is shown.

[0145] It should be understood that during face reduction, points of different colors cannot be merged. Traditional face reduction algorithms typically set these different colored points as non-mergeable. This results in faces that could otherwise be merged being unable to be merged, leading to significant waste. Figure 15A As described in the text, there are many triangular faces, and the face reduction effect is not sufficient. Figure 15A A schematic diagram showing an example of the effect of a voxel model obtained by facet reduction processing in current related techniques is provided.

[0146] like Figure 14 As shown, in step 1410, it is determined whether there are color intersections between adjacent voxel faces on the surface of the voxel model.

[0147] In step 1420, an auxiliary voxel surface is set at the color intersection, wherein the angle between the auxiliary voxel surface and each intersecting voxel surface is greater than the angle threshold.

[0148] In this embodiment, it is not necessary to define that points of different colors cannot be merged; instead, auxiliary voxel surfaces (e.g., perpendicular voxel surfaces) are set at the intersection of colors, and then combined with... Figure 12 The face reduction method described herein can effectively complete the face reduction operation and has a better face reduction effect.

[0149] Figure 15B A schematic diagram illustrating an example of the effect of a voxel model obtained through the face reduction operation according to an embodiment of this application is shown. Figure 15B As shown, by setting a vertical plane, no additional triangular faces exist in the same color range, thus reducing more faces and achieving an excellent face reduction effect.

[0150] It should be noted that these auxiliary voxel faces may be used solely in the face reduction and merging operation, and may not be submitted to the graphics card for rendering. For example, the auxiliary voxel faces may be eliminated after the face reduction operation for the voxel model is completed.

[0151] Figure 16A schematic diagram illustrating the effect of an example of a smoothed voxel model according to an embodiment of this application is shown.

[0152] Reference Figure 16 In the example above, combining the face reduction process described earlier, it is necessary to avoid merging some points in some application scenarios. For example, although the values ​​of the normals of P1 and P3 are very close and they meet the conditions for merging, they should not be easily merged in order to preserve the smooth curvature.

[0153] Therefore, incorrect merging of smoothed points in the voxel model can be avoided by setting weight information. Specifically, each voxel vertex has a calibration weight with respect to the included angle threshold and / or the distance threshold. Furthermore, the calibration weight corresponding to the smoothed voxel vertex can be lower than the calibration weight corresponding to the unsmoothed voxel vertex. This prevents the curvature of the smoothed points from being affected, ensuring the smoothness of the model. Specifically, the calibration weights of the first and second voxel vertices with respect to the included angle threshold and / or distance threshold are reduced.

[0154] For example, based on the smoothed influence point data, each point is assigned a different weight value. For example, the weight of unsmoothed points is 1, and the weight of smoothed points is set to 0.3 (i.e., point P1 has a weight of 1, and point P3 has a weight of 0.3). This weight value is used to calibrate the thresholds in the facet reduction process (e.g., angle thresholds and / or distance thresholds). The formula for the actual threshold is now:

[0155] The actual threshold used = preset threshold * weight value

[0156] In this way, due to the influence of weights, points P1 and P3 are not so easy to merge, thus preserving the expected smooth effect.

[0157] Figure 17 A structural block diagram of an example storage optimization apparatus for voxel models according to an embodiment of this application is shown.

[0158] like Figure 17 As shown, the storage optimization device 1700 for voxel models includes a computer color value acquisition unit 1710, a color key value configuration unit 1720, a color key value table construction unit 1730, and a color information storage unit 1740.

[0159] The computer color value acquisition unit 1710 is configured to acquire the computer representation value of the color corresponding to each voxel vertex in the voxel model.

[0160] The color key value configuration unit 1720 is configured to define corresponding color key values ​​for different color computer representation values, and to convert each acquired color computer representation value into a corresponding color key value.

[0161] The color key value table construction unit 1730 is configured to construct a color key value table based on the different color computer representation values ​​and the corresponding color key values.

[0162] The color information storage unit 1740 is configured to store the color key value table and the color key values ​​corresponding to each voxel vertex into memory space.

[0163] As per the above reference Figures 1 to 17 Embodiments of the storage optimization method and apparatus for voxel models according to the embodiments of this application have been described. The details mentioned in the above description of the method embodiments also apply to the embodiments of the apparatus of this application. The smoothing apparatus for voxel models described above can be implemented in hardware, software, or a combination of hardware and software.

[0164] Figure 18 A structural block diagram of an example of a smoothing apparatus for a voxel model according to an embodiment of this application is shown.

[0165] like Figure 18 As shown, the smoothing device 1800 for voxel models includes a target vertex coordinate determination unit 1810, a smooth vertex coordinate calculation unit 1820, a normal parameter calculation unit 1830, and a normal parameter replacement unit 1840.

[0166] The target vertex coordinate determination unit 1810 is configured to determine the coordinate parameters of the first voxel vertex to be smoothed in the voxel model.

[0167] The smoothing vertex coordinate calculation unit 1820 is configured to calculate the coordinate parameters of the second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm.

[0168] The normal parameter calculation unit 1830 is configured to calculate the normal parameters of the second voxel vertex based on the coordinate parameters of the second voxel vertex.

[0169] The normal parameter replacement unit 1840 is configured to replace the normal parameter of the first voxel vertex with the normal parameter of the second voxel vertex.

[0170] As per the above reference Figures 1 to 18 Embodiments of a smoothing method and apparatus for voxel models according to embodiments of this application have been described. The details mentioned in the above description of the method embodiments also apply to the embodiments of the apparatus of this application. The above-described smoothing apparatus for voxel models can be implemented in hardware, software, or a combination of hardware and software.

[0171] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using a hardware physical module. For example, a Programmable Logic Device (PLD) (e.g., a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program a digital system themselves to "integrate" it onto a PLD, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0172] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0173] For ease of description, the above devices are described separately by function as various units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.

[0174] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, embodiments of this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0175] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0176] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0177] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0178] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0179] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0180] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0181] Embodiments of this application can be described in the general context of computer-executable instructions, such as program modules, that are executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This application can also be practiced in distributed computing environments where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0182] The various embodiments in this application are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0183] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A smoothing method for voxel models, said voxel models being constructed using 3D voxels, said method comprising: Determine the coordinate parameters of the first voxel vertex to be smoothed in the voxel model; Based on a preset smoothing algorithm, the coordinate parameters of the second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex are calculated. Calculate the normal parameters of the second voxel vertex based on its coordinate parameters; Replace the normal parameters of the first voxel vertex with the normal parameters of the second voxel vertex, without modifying the coordinate parameters of the first voxel vertex; Smoothing is achieved using lighting effects through the replaced normal parameters, where the normal depends on the type of voxel object being lit, and the lighting direction corresponds to the normal direction.

2. The smoothing method for voxel models as described in claim 1, wherein, Determine the coordinate parameters of the first voxel vertex to be smoothed in the voxel model, specifically including: Identify the edges and corners of the voxel model's exterior; The coordinate parameters of the voxel vertices corresponding to the identified edges and corners are determined as the coordinate parameters of the first voxel vertex to be smoothed.

3. The smoothing method for voxel models as described in claim 1, wherein before the rendering operation is completed, a face reduction process is first performed on multiple voxel faces on the surface of the voxel model, and then a smoothing process is performed; or before the rendering operation is completed, a smoothing process is performed first, and then a face reduction process is performed on multiple voxel faces on the surface of the voxel model.

4. The smoothing method for voxel models as described in claim 3, wherein facet reduction processing is performed on multiple voxel faces on the surface of the voxel model, specifically including: Determine whether the angle between the normals of the adjacent first voxel vertex and the third voxel vertex on the surface of the voxel model is less than the angle threshold. When the included angle of the normal is less than the included angle threshold, it is assumed that one of the first voxel vertex and the third voxel vertex is eliminated, and it is determined whether the distance between the voxel vertex that is not eliminated and each voxel face with the voxel vertex that is assumed to be eliminated is less than the distance threshold. When all distances are less than the distance threshold, it is determined that a reduction operation will be performed on the voxel vertex that was assumed to be reduced.

5. The smoothing method for voxel models as described in claim 4, wherein, Each voxel vertex has calibration weights for the included angle threshold and / or the distance threshold. After replacing the normal parameters of the first voxel vertex with the normal parameters of the second voxel vertex, the method further includes: Reduce the calibration weights of the first voxel vertex and the third voxel vertex with respect to the included angle threshold and / or the distance threshold.

6. The smoothing method for voxel models as described in claim 3 or 4, wherein, The surface reduction process is performed on multiple voxel faces of the voxel model, specifically including: Identify whether there are color intersections between adjacent voxel faces on the surface of the voxel model; An auxiliary voxel surface is provided at the intersection of the colors, wherein the angle between the auxiliary voxel surface and each intersecting voxel surface is greater than the angle threshold.

7. The smoothing method for voxel models as described in claim 6, further comprising, after performing facet reduction processing on multiple voxel faces of the voxel model's surface, the method includes: Eliminate the auxiliary voxel surface.

8. A smoothing device for a voxel model, the voxel model being constructed using 3D voxels, the device comprising: The target vertex coordinate determination unit is configured to determine the coordinate parameters of the first voxel vertex to be smoothed in the voxel model; The smoothing vertex coordinate calculation unit is configured to calculate the coordinate parameters of the second voxel vertex corresponding to the smoothed coordinate parameters of the first voxel vertex based on a preset smoothing algorithm. The normal parameter calculation unit is configured to calculate the normal parameters of the second voxel vertex based on the coordinate parameters of the second voxel vertex. The normal parameter replacement unit is configured to replace the normal parameter of the first voxel vertex with the normal parameter of the second voxel vertex, without modifying the coordinate parameters of the first voxel vertex. Smoothing is achieved using lighting effects through the replaced normal parameters, where the normal depends on the type of voxel object being lit, and the lighting direction corresponds to the normal direction.

9. An electronic device, comprising: At least one processor; as well as A memory that stores instructions that, when executed by the at least one processor, cause the at least one processor to perform the method as described in any one of claims 1 to 7.

10. A machine-readable storage medium storing executable instructions that, when executed, cause the machine to perform the method as described in any one of claims 1 to 7.