Multi-model surface complementing method based on template buffering, terminal and storage medium

By adopting a multi-model face-filling method based on template buffer sharing in the three-dimensional model cut and face-filling method, using bit-by-bit numbering rules and double-sided rendering technology, the problem of inefficient cross-cutting and face-filling in multi-model scenarios is solved, and efficient real-time rendering performance is achieved.

CN119919557AActive Publication Date: 2025-05-02ZHEJIANG HUADONG ENG DIGITAL TECH CO LTD +1

Patent Information

Application Number
CN202510409170.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-02
Publication Date
2025-05-02
Estimated Expiration
2045-04-02

AI Technical Summary

Technical Problem

The existing three-dimensional model cut and surface-complement methods have problems such as inefficiency and unstable rendering effects in terms of multi-model scenarios, dynamic scenarios and real-time rendering requirements. Especially in the context of parallel rendering and batch processing technology, it is difficult to make full use of parallel computing resources.

Method used

The multi-model face-filling method based on template buffer sharing is adopted. Through the bit-by-bit numbering rules and mask control mechanism, the template mask value of the to-processed model and its face-filling plane is set to the n power of 2, so that multiple models can share the same template buffer, and the number of coverage marks of the front and back pieces are completed using double-sided rendering and parity judgment methods.

Benefits of technology

It improves the efficiency of cutting and surface filling processing in multi-model scenarios, reduces the dependence on rendering order, adapts to the parallel pipeline and delayed rendering mode of modern graphics engines, and significantly improves real-time rendering performance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919557A_ABST
    Figure CN119919557A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of three-dimensional graphic rendering, in particular to a multi-model surface filling method based on template buffering, a terminal and a storage medium, and the method comprises the following steps: obtaining a plurality of to-be-processed models and sectioning planes, and generating corresponding surface filling planes; setting corresponding numbers according to bits for the to-be-processed model and the patch plane; performing double-sided rendering on the to-be-processed model, and performing single-sided rendering on the complement plane; and discarding the slice elements of the patch plane of which the binary bit corresponding to the serial number is not 1 in the template value, and finishing trimming of the patch plane. According to the method, a bitwise corresponding numbering rule, combination of double-sided rendering and bitwise negation and a parallelization mechanism that multiple models share a single template value are utilized, and the problems that a traditional method frequently empties template values, strictly depends on sequential rendering, is insufficient in support for multiple models and the like are solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of three-dimensional graphics rendering, and in particular to a multi-model cutting and surface filling method based on template buffering applied to three-dimensional models. Background Art

[0002] With the continuous advancement of computer graphics and 3D modeling technology, dynamic sectioning and surface generation technology of 3D models has been widely used in many fields such as architectural design, virtual reality, medical imaging, geological survey, engineering visualization, etc. Through sectioning and surface generation, the internal structure of the model can be more intuitively displayed, helping users understand and analyze complex 3D data.

[0003] However, existing technologies still face many challenges in multi-model scenes, dynamic scenes, and real-time rendering requirements. Traditional cutting and patching methods often require explicit sorting or multiple rendering of different models, resulting in low efficiency and difficulty in maintaining stable rendering effects. Especially in the context of modern graphics engines widely adopting parallel rendering and batch processing technology, forcibly controlling the rendering order of models is not only costly and difficult, but also greatly affects the cutting and patching performance in multi-model dynamic scenes. The following will introduce the limitations of existing technologies from two typical technologies: traditional geometric cutting and patching methods and template buffer-based cutting and patching methods.

[0004] 1. Traditional geometric sectioning method: The Chinese patent with publication number CN109685914A discloses a method for automatically filling the cutting contour based on a triangular mesh model, which realizes cutting by modifying the model geometric data (such as vertices and triangular facets). This type of method has the following problems: 1. High computational overhead. When faced with complex models, geometric data must be frequently reconstructed. One sectioning often requires dynamic updates of a large number of vertices and faces, which requires large amounts of computation and high time complexity, making it difficult to meet real-time rendering requirements.

[0005] 2. Complex algorithm design. Once the sectioning is completed, the gap needs to be automatically or semi-automatically filled, which usually involves geometric algorithms such as topology update, boundary detection and reconstruction. This process places high demands on algorithm design and can easily become a system bottleneck; if it is not implemented properly, it will lead to poor connection between the sectioning surface and the filling surface, and the overall efficiency will be significantly reduced.

[0006] (II) Sectioning and patching method based on template buffer: The existing template buffer-based cutting and patching methods have insufficient utilization of template buffer resources. One template value can only mark one model, and the template buffer bit operation capability cannot be fully utilized, making it difficult to adapt to the needs of multi-model patching.

[0007] The relationship between sectioning and patching is not handled accurately enough, and it relies more on timing control, with sectioning done first and patching next. There is a lack of precise management of the relationship between the two, and the effects of sectioning and patching are prone to inconsistency, which also places high demands on the rendering mechanism.

[0008] Parallel rendering and rendering order control are difficult. Traditional template buffer methods often require rendering the back and front sides separately and processing the models one by one. Modern engines rely heavily on parallel and batch processing. Forcibly controlling the rendering order will form a performance bottleneck and make it difficult to fully utilize parallel computing resources.

[0009] Stencil buffer limitation: In modern graphics engines such as UE5, only a single stencil buffer can be used for one rendering. If multiple sections and patching are required, the traditional method can only rely on multiple renderings and multiple stencil buffers, which makes it difficult to maintain efficiency and stability in large multi-model scenes.

[0010] For example, the prior art (such as patents CN102013113A, CN115690378A, etc.) proposed to use template buffer to mark the sectioning area and update the template value multiple times to achieve sectioning and filling. The number of coverages is recorded by decimal operations such as minus 1 for the front side and plus 1 for the back side, resulting in a template value that can only represent the gap state of a single object. And the filling must be done immediately after rendering an object, otherwise the addition and subtraction operations of subsequent objects will destroy the previous information; in addition, the process of clearing the template value needs to be frequently inserted between multiple objects. Summary of the invention

[0011] In order to overcome the problems of insufficient utilization of template buffer resources and inaccurate processing of the relationship between sectioning and sectioning in existing surface patching methods, the present invention proposes a multi-model surface patching method based on template buffer sharing, which can make full use of the template buffer bit computing capability and realize efficient processing of multi-model sectioning and sectioning.

[0012] The technical solution provided by the present invention is as follows: a multi-model face filling method based on template buffer, comprising the following steps: Obtaining several models to be processed and defined cutting planes, and generating corresponding patching planes; A number n corresponding to the binary bit of the template value in the template buffer is set for the model to be processed, and the patch plane and its corresponding model to be processed use the same number; Setting the rendering state of the model to be processed and the patching plane, including: setting the template mask value of the model to be processed and the patching plane to the power of 2; setting the initial value of the template value to 0; The first process of starting rendering includes: performing double-sided rendering on the model to be processed, and performing a negation operation on the template value based on the template mask value each time the pixel is covered by the fragment, so as to write the information of the model gap into the template value; Start the second rendering process, perform single-sided rendering on the patch plane, retain the patch plane fragments whose template values ​​correspond to binary bits of 1 after the first rendering process, and discard the patch plane fragments whose template values ​​correspond to binary bits of 0, thereby cutting off the part of the patch plane that exceeds the area to be patched, and completing the trimming of the patch plane.

[0013] Preferably, the method further includes setting the rendering state of the patch plane before starting the second rendering process, wherein the setting content includes: Passes when the template test function is set to equality; Set both the template mask value and the reference value to powers of 2.

[0014] Preferably, before starting the first rendering process, the "template test operation" of the template buffer is set to be bitwise inverted, and the template test function is set to always pass.

[0015] Preferably, the number n starts from 0 to number the models to be processed.

[0016] Preferably, the step further includes transferring the cutting plane information to the shader to form a cutting plane, wherein: The cutting plane is defined by a general plane equation. When the coordinates of a given fragment are substituted into the plane equations of all the cutting planes and the resulting values ​​are greater than 0, the fragment is deleted, otherwise the fragment is retained, thereby forming a cutting plane.

[0017] Preferably, the patching plane is used to fill the gap generated after sectioning, and the step of generating the patching plane includes: traversing each model to be processed, and generating a corresponding patching plane according to the intersection position of the model with the sectioning plane.

[0018] Preferably, the setting of the rendering state of the patch plane further includes: setting the template operation to remain unchanged.

[0019] A smart terminal comprises a processor and a memory, wherein the memory stores a computer program, the processor is in communication connection with the memory, and the processor executes the above-mentioned template buffer-based multi-model face filling method through the computer program.

[0020] A computer-readable storage medium stores program data, wherein the program data is used to execute the template buffer-based multi-model surface filling method as described above.

[0021] Compared with the prior art, the present invention has the following beneficial effects: 1. For multi-model scenes, the template mask values ​​of the model to be processed and its patch plane are set to the power of 2 (n is the number of the model to be processed or the patch plane) through the bit-by-bit numbering rule and mask control mechanism. That is, when the models to be processed and the patch planes with different numbers are rendered, only the corresponding binary bits in the template value are operated, so that the gap marks of multiple models can be processed simultaneously in the same template value. Multiple models to be processed and the corresponding patch planes share the same template buffer, and one template value manages the gap information of multiple models through different binary bits, without frequent clearing or resetting, breaking the limitation that the template value "addition and subtraction operation" in the traditional method can only store the gap of a single model.

[0022] 2. Through double-sided rendering and parity judgment, with the help of bitwise inversion and mask control mechanism, the number of coverage times of front and back fragments can be marked at one time, without the need for multiple renderings such as "front minus 1, back plus 1". Each model only affects the binary bits it occupies, thereby achieving unified processing of multiple models in one template buffer process, without relying on strict control of the front and back rendering order of the model, greatly improving the efficiency of parallel rendering, effectively reducing the strict dependence on rendering order, especially adapting to the parallel pipeline and deferred rendering mode of modern graphics engines, and significantly improving the real-time efficiency in large-scale, multi-model scenarios.

[0023] 3. Set the template test function of the patching plane to EQUAL (pass when equal), and use the template mask value and reference value corresponding to the same number as the model to be processed to accurately patch the gaps, so that the patching plane can automatically identify and fill the gaps of their respective models. There is no need to patch immediately or rely on complex sequential control; at the same time, the material can be changed freely, and the transparency or texture can be controlled to meet diverse visual needs.

[0024] 4. It can adapt to modern engine deferred rendering and batch processing, and make full use of the deferred rendering and parallel characteristics of modern graphics engines. There is no need to force sorting or frequently clear template values. It can allow the rendering engine to process sectioning and patching in parallel or deferred pipelines, maximize the parallel computing capabilities of GPU, and make multi-model dynamic sectioning and patching truly real-time and flexible. BRIEF DESCRIPTION OF THE DRAWINGS

[0025] Figure 1 This is a schematic diagram of a process of Embodiment 1 of the present invention; Figure 2 It is a schematic diagram of the state of the model to be processed (geological model) before being cut and filled; Figure 3 The state diagram of the model to be processed after being numbered; Figure 4 It is a schematic diagram of the state of the model to be processed after being cut by a single cutting plane; Figure 5 for Figure 4 Based on this, a schematic diagram of the patch plane indicated by semi-transparency is generated; Figure 6 for Figure 5 A schematic diagram after the template value is marked in the gap; Figure 7 It is a schematic diagram of the model state after pruning according to the template value; Figure 8 This is a schematic diagram of the final filling effect after removing the template value; Fig. 9 It is a schematic diagram of the state of two intersecting cubes before being cut and patched as the model to be processed; Fig.10 It is a schematic diagram of the state of two intersecting cubes after being cut and patched; Fig.11 The diagram is a state diagram of the template values ​​corresponding to the gap areas when two intersecting cubes are cut and patched. DETAILED DESCRIPTION

[0026] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. Based on the described embodiments of the present invention, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present invention. Unless otherwise defined, the technical terms or scientific terms used herein should be the common meanings understood by people with ordinary skills in the field to which the present invention belongs.

[0027] Embodiment 1, A multi-model face filling method based on template buffer, the specific steps are as follows.

[0028] S1, obtain the model to be processed and generate the cutting plane and the filling plane.

[0029] S11, obtaining the model to be processed, the model to be processed is as follows Figure 2 As shown, this embodiment takes three models to be processed as examples.

[0030] The model to be processed can be loaded from the hard disk or generated by the program in real time, as long as it is a closed mesh model.

[0031] S12, defining the cutting plane, that is, passing the cutting plane information to the shader.

[0032] Define one or more cutting planes as required. This embodiment takes a single plane as an example. If multiple planes are required, the fragment will be cut only when it falls on the positive side of all planes. The cutting plane can be defined using a general plane equation, such as ax+by+cz+d=0, where (a,b,c) is the normal vector of the plane and d is a constant. The plane can be directly described by the coefficients a,b,c,d. For a given point P(x1,y1,z1), substitute its coordinates into the plane equation to obtain F=ax1+by1+cz1+d. If: F>0, indicating that the point is on the positive side of the plane (the side to which the normal vector points); F<0 means the point is on the negative side of the plane; F=0 means the point lies on the plane.

[0033] In this embodiment, the front side of the plane is regarded as the area to be cut away, and the front side fragments are discarded in the fragment shader to obtain the cutting effect. Figure 5 As described above, the semi-transparent plane is a schematic diagram of the cutting plane, the model fragments in the positive side area are deleted, and the negative side part is retained.

[0034] If you need to use multiple cutting planes, the fragment will be cut only if it is on the positive side of all planes, such as Figure 9-11 Shown is the effect of multi-plane sectioning.

[0035] The specific steps are to apply the cutting plane to the fragment shader to form a cutting surface, that is, use F=ax+by+cz+d to describe the cutting plane, and pass the four coefficients a, b, c, d to the fragment shader (i.e., Pixel Shader). For the fragment world coordinates (x1, y1, z1), calculate F=ax1+by1+cz1+d. If F>0, the fragment is discarded to achieve the cutting of the positive side area of ​​the plane; otherwise, it is retained. In this way, the positive side part of the intersection of the model and the cutting plane will be "cut off", while the negative side part will be retained to form a clear cutting surface.

[0036] S13, generating a patching plane.

[0037] Traverse each model to be processed, and generate a corresponding patch plane according to the intersection position between it and the cutting plane. The patch plane is a mesh model that can be actually rendered, which is used to fill the gap after cutting. Usually, the patch plane can be a rectangle, and its size can be as long as it can cover the gap. By default, the material of the patch plane is the same as that of the model to be processed to maintain visual consistency, and other materials can be replaced according to needs.

[0038] S2, setting a number n corresponding to the binary bits of the template value in the template buffer for the model to be processed, and the patch plane and its corresponding model to be processed use the same number.

[0039] In order to make multiple models to be processed and their corresponding patch planes correspond one-to-one in the template buffer, it is necessary to set bit-by-bit corresponding numbers for the models to be processed and the patch planes. The specific setting of the numbering rules is as follows: The models to be processed and the planes to be filled are managed in a sequential numbering manner. The numbers of multiple models to be processed are incremented one by one starting from 0. For example, when there are five models to be processed in the scene, their numbers are 0, 1, 2, 3, and 4. In this implementation, there are three models to be processed, and their numbers are 0, 1, and 2.

[0040] The model to be processed in this embodiment is a geological model, such as Figure 2 As shown, it consists of multiple geological layers that fit each other, and each geological layer is regarded as a model to be processed. Figure 3 The numbers of the three models to be processed are identified in FIG. In this embodiment, only the three models to be cut are assigned numbers and subsequent operations are performed.

[0041] After each model to be processed is numbered, in order to achieve a one-to-one correspondence in the subsequent template buffer, the patch plane and its corresponding model to be processed use the same number.

[0042] S3, setting the rendering state of the model to be processed.

[0043] Enable Stencil Test. Stencil test is a common function of existing graphics engines. Configure the stencil test parameters, including: S31, setting the template mask value (ie, MASK) of the model to be processed to the nth power of 2, where n is the number of the model to be processed, and setting the "template test operation" of the template buffer to bitwise inversion (ie, INVERT).

[0044] S311, setting the template mask value to the nth power of 2, where n is the number of the model, that is, reading and writing the n+1th bit in the template value.

[0045] There is a one-to-one correspondence between the number of each model to be processed and the patch plane and the binary bit of the template value. Assuming that the number of the model to be processed is n, the corresponding binary bit in the template value is the n+1th bit, and the corresponding decimal expression is 2 to the power of n, for example: 1) The model numbered 0 corresponds to the first digit of the binary number, which is expressed as 2 raised to the power of 0 in decimal (1 in binary and 1 in decimal).

[0046] 2) The model numbered 1 corresponds to the second digit of the binary number, which is expressed as 2 to the power of 1 in decimal (10 in binary and 2 in decimal); 3) Model numbered 2 corresponds to the third digit of the binary number, expressed as 2 to the power of 2 in decimal (100 in binary, 4 in decimal); 4) Model number 3 corresponds to the fourth digit of the binary number, which is expressed as 2 to the power of 3 in decimal (1000 in binary and 8 in decimal); 5) Model number 4 corresponds to the fifth digit of the binary number, which is expressed as 2 to the power of 4 in decimal (10000 in binary and 16 in decimal); Therefore, the template mask values ​​of the model to be processed and its patching plane are set to 2 to the power of n (n is the number of the model or the patching plane), so that the template mask values ​​corresponding to the model to be processed and its patching plane are all 2 to the power of n. When the models to be processed and patching planes with different numbers are rendered, only the corresponding binary bits in the template value are operated, so that the gap marks of multiple models can be processed simultaneously in the same template value.

[0047] S312, two-sided rendering (i.e. Two-Sided) is turned on, and the stencil test operation (i.e. StencilOp) is set to bitwise inversion (INVERT).

[0048] A fragment is a data unit generated at a stage in the graphics rendering pipeline. It is the result of rasterizing three-dimensional graphics and can be understood as a fragment of graphics data corresponding to each pixel on the screen. Simply put, when we draw a geometric figure such as a triangle on the screen, after a series of transformations and processing, the triangle will be converted into fragments. Each fragment contains information such as color, depth, texture coordinates, etc., which are ultimately used to determine the display effect of each pixel on the screen.

[0049] When rendering the model to be processed, it is necessary to determine which fragments belong to the "model gap" and need to be filled. Model gap refers to the internal surface of the model exposed after the model to be processed is cut. The model solid part refers to the external surface of the model to be processed.

[0050] In double-sided rendering, if a pixel is covered by fragments an odd number of times during the rendering process, it means that the pixel is ultimately located in the gap of the model and should be patched; if the number of coverages is an even number, it means that the pixel is in the solid part of the model and does not need to be patched. Therefore, by judging the odd or even number of coverages, it is possible to distinguish between pixel positions that need to be patched and those that do not.

[0051] Specifically, when rendering, the "template test operation" of the template buffer is set to INVERT (bitwise inversion). The initial state of the template buffer has a binary bit value of 0 corresponding to the template value; when the fragment of the model to be processed covers the pixel for the first time, the binary bit corresponding to the template value will be inverted to 1; the second time it covers, the binary bit corresponding to the template value will be inverted to 0; and so on.

[0052] When the number of times a pixel is covered by a fragment is an odd number, the corresponding binary bit = 1, indicating that this is a model gap; when the number of coverage is an even number, the binary bit = 0, indicating that the fragment is still in the solid part of the model. When rendering the patching plane later, the gap can be determined by reading whether the corresponding binary bit in the template value is 1. The patching plane can accurately identify the "gaps" of multiple models in a single template value, and ultimately achieve multiple models sharing a template value and patching at the same time.

[0053] S32 other settings, including: Set the template test function (StencilFunc) of the model to be processed: ALWAYS (always pass).

[0054] Set the reference value (ie REF) of the model to be processed: it can be set to any value at this time, because the test function always passes, the key lies in the template mask and the negation operation.

[0055] So far, steps S1 to S3 complete the setting of the rendering state of the model to be processed.

[0056] S4, starts the first rendering process, that is, double-sided rendering (i.e. Two-Sided) of the model to be processed, and operates the corresponding template value to write the information of the model gap, that is, each time a pixel is covered by a fragment, the template value is inverted based on the template mask value to record the fragment at the model gap.

[0057] Double-sided rendering is performed. When the fragment of the model to be processed is finally clipped by the cutting plane, the binary bit corresponding to the template value will be inverted from 0→1 or 1→0 according to the template mask value. When there are odd-numbered overlays, this bit = 1, indicating a gap; when there are even-numbered overlays, this bit = 0, indicating a solid part of the model.

[0058] When performing double-sided rendering, compared with the traditional "front side minus 1, back side plus 1" method, the traditional method requires two single-sided renderings and strictly controls the order to record whether the model has gaps; the present invention uses bitwise inversion and double-sided rendering to complete the parity judgment of the number of times the fragment is covered at one time, which is more efficient and does not require a forced model rendering order.

[0059] like Figure 6The values ​​in the figure are the template values ​​written in the gap area after double-sided rendering of each model to be processed. Figure 5 From the numbers in, we can see that at this time, The template value written into the fragment at the gap of the model to be processed with number 0 is binary 001 (decimal 1); The template value written into model number 1 is binary 010 (decimal 2); The template value written to model number 2 is binary 100 (decimal 4).

[0060] because Figure 2 to Figure 8 There is no internal intersection of the model, so at this time, the template value at the gap only has the binary bit corresponding to the number as 1, and the other binary bits are 0.

[0061] Figures 9 to 11 Shown are the schematic states of each stage when two intersecting cubes (models to be processed) are cut and patched with cubes, and the template value state at the intersection of the two models to be processed is displayed.

[0062] If there is an intersection between models, the binary bits corresponding to multiple models to be processed may be written into the same gap position at the same time. For example, the template value corresponding to the intersection of two cube models can be binary 011 (decimal 3), which means that both the first and second bits are set to 1, reflecting that the position is composed of the gaps of the two models. This also shows that by applying the bit-by-bit numbering rules, when multiple models share a template value, the states will not overlap each other.

[0063] S5, setting the rendering state of the patching plane, starting the second rendering process, that is, performing single-sided rendering on the patching plane, and processing the part that exceeds the gap of the model to be processed. Among them, the setting of the rendering state of the patching plane can also be completed in advance in step S3, and then the first rendering process and the second rendering process are started. In this embodiment, the setting of the rendering state of the patching plane is arranged in step S5 only for the convenience of understanding, and does not represent the operation sequence in actual operation. After completing the rendering of all the models to be processed and writing their gap information, the patching planes at these gap positions need to be processed.

[0064] S51, enable the stencil test to set the rendering state of the patch plane, including: Set the stencil test function (StencilFunc option in the graphics engine): Set it to Pass when equal (EQUAL option in the image engine). This means that the fragment will pass the test only when the "stencil value & mask" is equal to the "reference value". & is the binary AND operator, that is, if the stencil value and the stencil mask value have the same bit and are both 1, then output 1, otherwise output 0.

[0065] In order to discard the fragments with a template value of 0 after applying the template mask value, and retain the fragments of the patch plane with a template value corresponding to a binary bit of 1, set the mask (MASK) and reference value (REF): both are set to decimal 2^n (2^n is 2 to the power of n), where n is the model number corresponding to the patch plane (consistent with the corresponding model to be processed). Set the template operation (StencilOp option in the image engine): set to remain unchanged (KEEP option in the image engine). Because at this time, you only need to read the existing template value to determine the gap, and there is no need to make any changes to the template value.

[0066] At this point, the rendering status settings of the cutting plane, the model to be processed, and the patching plane are completed.

[0067] Since each number is mapped to a different binary bit in the template value, MASK=2^n means that only the n+1th bit is tested. The effect is that when this bit is equal to 1, it means that the fragment is a gap in the model to be processed with number n, and the corresponding fragment of the patch plane with number n passes the test; when this bit is equal to 0, the fragment of the patch plane with number n is directly discarded.

[0068] S52, start the second rendering process, including: When the binary bit of the template value read by the fragment of the patch plane is finally 1, that is, the "template value & mask" is 2^n, which is equal to the reference value 2^n, the template test passes, and the fragment of the patch plane is retained.

[0069] In this embodiment, for ease of understanding, three models to be processed are used as examples. For example, the final template value corresponding to a pixel is 110 in binary, indicating that the pixel is located at the gap between model 1 to be processed and model 2 to be processed, and the outside or solid part of model 0 to be processed; at this time, the patch plane corresponding to model 2 to be processed is being processed, so the template mask value is 100 and the reference value is 100; Then, 110 (template value) & 100 (template mask value) is 100, which is equal to the reference value, that is, the template value binary bit corresponding to the pixel at the patch plane is finally 1, so the template test passes, thereby retaining the patch plane fragment corresponding to the pixel position.

[0070] When the template value binary bit corresponding to the pixel at the patch plane is finally 0, that is, the "template value & template mask" is 0, which is not equal to the reference value 2^n, the template test fails, and the patch plane fragment corresponding to the pixel position is discarded, and the part of the patch plane that exceeds the gap of the model to be processed is cut off.

[0071] In this embodiment, for ease of understanding, three models to be processed are still used as examples. For example, the final template value corresponding to a pixel is 010 in binary, indicating that the pixel is located at the gap of model 1 to be processed, the outside or solid part of model 0 to be processed and model 2 to be processed; at this time, the patch plane corresponding to model 2 to be processed is being processed, so the template mask value is 100 and the reference value is 100; Then, 010 (template value) & 100 (template mask value) is 000, which is not equal to the reference value, that is, the template value corresponding to the pixel at the patch plane is finally 0, so the template test fails, and the fragment corresponding to the patch plane at the pixel position is discarded.

[0072] In summary, the pruning method of this embodiment is completed by setting the template mask (MASK) and the reference value (REF) to decimal 2^n and setting the template test function to pass when they are equal.

[0073] The beneficial effects of this embodiment include: 1. The rendering order is adapted to parallel rendering, that is, render all models first, and then render the patch faces.

[0074] The traditional method must fill in the gaps immediately after rendering each model, and the template value must be repeatedly cleared between different models; when there are many models, the performance is severely limited. The method of this embodiment uses the "bit-by-bit corresponding numbering rule" so that one template value can record multiple model gaps at the same time without interfering with each other. Therefore, multiple models to be processed can be batch rendered first, and then the filling plane can be rendered uniformly.

[0075] 2. Suitable for automatic sorting of transparent materials: In modern graphics engines (such as UE5 and Unity), setting the patch plane material to the "transparent" rendering mode will automatically sort it after all opaque objects without manually forcing the order. If you do not want the patch plane to actually present a transparent effect, you can only enable the "transparent" rendering channel in the material properties, and the actual shading can still maintain an opaque visual effect.

[0076] 3. Apply multi-model parallel rendering: Since each model only modifies its own bit in the template value, it can make full use of the parallel pipeline or delayed rendering mechanism, reducing pipeline switching and template clearing operations. For complex applications with large scenes and multiple objects (such as architectural visualization, geological exploration, etc.), the method of this embodiment can greatly improve rendering efficiency.

[0077] 4. The present invention can be widely applied to various graphics APIs (such as OpenGL, Vulkan, DirectX, etc.) and modern graphics engines (such as UE5, Unity, etc.), and has good cross-platform and compatibility.

[0078] It must be pointed out that the order of the above steps is not fixed, and the order of operations can be changed as needed. For example, after completing the settings of all the above rendering states, the scene can be batch rendered to obtain the final sectioning and filling effect.

[0079] like Figure 8 As shown, the cutouts of each model to be processed are accurately filled by the corresponding patch plane, and the overall visual effect is consistent with the original model. Compared with the traditional method of "subtracting the front and adding the back" or clearing the template value in batches, the present invention greatly simplifies the rendering process and significantly improves the parallelization efficiency by virtue of the bit-by-bit numbering rules and double-sided rendering. It is especially suitable for the deferred rendering pipeline of modern graphics engines and large-scale multi-model scenes.

[0080] Compared with the prior art, this embodiment can record the gaps of multiple models in the same template buffer value by bitwise inversion (INVERT) and number mask (MASK= 2^n). The patch plane is rendered only when the corresponding binary bit is equal to 1, without relying on additional sequence control, and can be perfectly combined with the delay and parallel pipeline of modern rendering engines.

[0081] The present invention utilizes bitwise corresponding numbering rules, a combination of double-sided rendering and bitwise negation, and a parallel mechanism in which multiple models share a single template value, to solve the problems of traditional methods such as frequent clearing of template values, strict reliance on sequential rendering, and insufficient support for multiple models. It also seamlessly connects with the deferred rendering pipeline of modern graphics engines, greatly improving rendering efficiency and maintainability in complex scenarios.

[0082] Embodiment 2, an intelligent terminal includes a processor and a memory, the memory stores a computer program, the processor is in communication with the memory, and the processor executes the template buffer-based multi-model face filling method of embodiment 1 through the computer program.

[0083] Embodiment 3 is a computer-readable storage medium, wherein the computer-readable storage medium stores program data, and the program data is used to execute the template buffer-based multi-model surface filling method of embodiment 1.

[0084] The preferred embodiments of the present invention are described in detail above in conjunction with the accompanying drawings. However, the present invention is not limited to the specific details in the above embodiments. Within the technical concept of the present invention, a variety of simple modifications can be made to the technical solution of the present invention, and these simple modifications all belong to the protection scope of the present invention.

Claims

1. A multi-model face filling method based on template buffer, characterized in that: The steps include: Obtaining several models to be processed and defined cutting planes, and generating corresponding patching planes; A number n corresponding to the binary bit of the template value in the template buffer is set for the model to be processed, and the patch plane and its corresponding model to be processed use the same number; Setting the rendering state of the model to be processed and the patching plane, including: setting the template mask value of the model to be processed and the patching plane to the power of 2; setting the initial value of the template value to 0; The first process of starting rendering includes: performing double-sided rendering on the model to be processed, and performing a negation operation on the template value based on the template mask value each time the pixel is covered by the fragment, so as to write the information of the model gap into the template value; Start the second rendering process, perform single-sided rendering on the patch plane, retain the patch plane fragments whose template values ​​correspond to binary bits of 1 after the first rendering process, and discard the patch plane fragments whose template values ​​correspond to binary bits of 0, thereby cutting off the part of the patch plane that exceeds the area to be patched, and completing the trimming of the patch plane.

2. The multi-model surface filling method based on template buffer according to claim 1 is characterized in that: It also includes setting the rendering state of the patch plane before starting the second rendering process, and the settings include: Passes when the template test function is set to equality; Set both the template mask value and the reference value to powers of 2.

3. The multi-model surface filling method based on template buffer according to claim 2 is characterized in that: It also includes setting the "template test operation" of the template buffer to bitwise inversion and the template test function to always pass before starting the first rendering process.

4. The multi-model surface filling method based on template buffer according to claim 1, 2 or 3, characterized in that: The number n starts from 0 to number the models to be processed.

5. The multi-model surface filling method based on template buffer according to claim 1, 2 or 3, characterized in that: It also includes passing the cutting plane information to the shader to form a cutting surface, and the steps are: The cutting plane is defined by a general plane equation. When the coordinates of a given fragment are substituted into the plane equations of all the cutting planes and the resulting values ​​are greater than 0, the fragment is deleted, otherwise the fragment is retained, thereby forming a cutting plane.

6. The multi-model surface filling method based on template buffer according to claim 1, 2 or 3, characterized in that: The patching plane is used to fill the gap generated after sectioning. The step of generating the patching plane includes: traversing each model to be processed, and generating a corresponding patching plane according to the intersection position of the model with the sectioning plane.

7. The multi-model surface filling method based on template buffer according to claim 1, 2 or 3, characterized in that: The settings for the rendering status of the patch plane also include: setting the template operation to remain unchanged.

8. An intelligent terminal, characterized in that: The intelligent terminal includes a processor and a memory, the memory stores a computer program, the processor is in communication with the memory, and the processor executes the template buffer-based multi-model face filling method according to any one of claims 1 to 7 through the computer program.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program data, and the program data is used to execute the template buffer-based multi-model surface filling method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method for dynamically sectioning multiple-object model based on template buffering

    CN102013113A

  • A triangular mesh model-based automatic surface patching algorithm for a sectioned contour

    CN109685914A

  • Web end three-dimensional geological model dynamic sectioning and profile filling method

    CN113487718A

  • Solid sectioning method of three-dimensional object, terminal and storage medium

    CN115690378A

  • Method and apparatus for rendering semi-transparent surfaces

    US20070103462A1

Cited By

  • Multi-model surface complementing method based on texture mixed accumulation, terminal and storage medium

    CN121392105A

  • Multi-model patching method based on texture blending accumulation, terminal and storage medium

    CN121392105B