Depth testing method and device, computer equipment and storage medium

By setting grid priority for each grid of the object to be displayed and comparing it based on the depth value and grid priority in the depth test, the problem in the prior art is solved that in-depth tests are difficult to accurately judge the depth difference of the fragments. Improve image display quality and reduce z-fighting phenomenon.

CN119444823APending Publication Date: 2025-02-14WUHAN UNITED IMAGING HEALTHCARE SURGICAL TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310954369.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-31
Publication Date
2025-02-14

AI Technical Summary

Technical Problem

When conducting depth tests in the prior art, it is difficult to accurately judge the depth difference between the two triangle surfaces, resulting in z-fighting and affecting the display quality of the image.

Method used

The target fragment is determined by setting grid priority for each grid of the object to be displayed and comparing the depth value and grid priority of the chip corresponding to the current screen coordinates in the depth test.

Benefits of technology

It significantly improves the display quality of the rendered image, realizes the improvement of the global stability and local stability of the rendered image from the cellular level, and reduces the occurrence of z-fighting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119444823A_ABST
    Figure CN119444823A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of image display, in particular to a depth testing method and device, computer equipment and a storage medium, and the method comprises the steps: obtaining a plurality of grids of a to-be-displayed object; each grid is provided with a corresponding grid priority; processing each grid to obtain a fragment to which each grid belongs; the grid priority of each slice element is determined based on the grid priority corresponding to the corresponding grid; and under the condition that the number of the fragments corresponding to the current screen coordinate is at least two, determining a target fragment displayed in the current screen coordinate based on the depth value of each fragment corresponding to the current screen coordinate and a comparison result between the grid priorities of the fragments corresponding to the current screen coordinate.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of image display technology, and in particular to a depth testing method, device, computer equipment and storage medium. Background Art

[0002] In the process of rendering graphics for object mesh models, each mesh will be rasterized into multiple small fragments, and fragments belonging to different meshes may be projected into the same screen pixel in the graphical user interface. In order to determine the fragment corresponding to this type of screen pixel, it is necessary to compare the depth values ​​of different fragments through depth testing to select the fragment for display in the screen pixel of the graphical user interface.

[0003] However, when the triangles of two meshes are almost coplanar, it is often difficult to accurately determine the depth difference between the fragments of the two triangles based on existing depth testing technology. This problem will cause the two triangles to frequently switch their order when displayed in the graphical user interface, resulting in depth conflicts (z-fighting) such as screen flickering and screen jitter, which will have a significant impact on the display quality of the rendered image. Summary of the invention

[0004] Based on this, it is necessary to provide a depth testing method, device, computer equipment and storage medium to address the above technical issues.

[0005] In a first aspect, the present application provides a depth testing method, the method comprising:

[0006] Acquire multiple grids of the object to be displayed; each of the grids is set with a corresponding grid priority;

[0007] Processing each of the grids to obtain the fragments to which each of the grids belongs; the grid priority of each of the fragments is determined based on the grid priority corresponding to the corresponding grid;

[0008] When the number of fragments corresponding to the current screen coordinates is at least two, the target fragment displayed in the current screen coordinates is determined based on the comparison result between the depth values ​​of the fragments corresponding to the current screen coordinates and the grid priorities of the fragments corresponding to the current screen coordinates.

[0009] In one of the embodiments, determining the target fragment displayed in the current screen coordinates based on a comparison result between the depth values ​​of the fragments corresponding to the current screen coordinates and the grid priorities of the fragments corresponding to the current screen coordinates includes:

[0010] Obtaining a difference between depth values ​​of any two fragments corresponding to the current screen coordinates; and determining the target fragment according to a comparison result between the difference and a depth comparison threshold.

[0011] In one of the embodiments, determining the target fragment according to a comparison result between the difference value and a depth comparison threshold value includes:

[0012] According to the comparison result between the difference value and the depth comparison threshold, determine whether the arbitrary two fragments meet the depth difference judgment condition; if the arbitrary two fragments do not meet the depth difference judgment condition, then the fragment with a higher corresponding grid priority among the arbitrary two fragments is determined as the target fragment.

[0013] In one of the embodiments, determining whether the two arbitrary fragments satisfy a depth difference judgment condition according to a comparison result between the difference value and a depth comparison threshold value includes:

[0014] When the difference is greater than or equal to the negative number of the depth comparison threshold and less than or equal to the depth comparison threshold, it is determined that the arbitrary two fragments do not satisfy the depth difference judgment condition.

[0015] In one of the embodiments, determining the target fragment according to the comparison result between the difference value and the depth comparison threshold value further includes:

[0016] If the target fragment screening condition is to preferentially display fragments that are closer to the observer, then when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold, the fragment with the larger corresponding depth value among any two fragments is determined as the target fragment.

[0017] In one embodiment, the method further comprises:

[0018] If the target fragment screening condition is to preferentially display fragments that are farther away from the observer, then when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold, the fragment with the smaller corresponding depth value among any two fragments is determined as the target fragment.

[0019] In one embodiment, after processing each of the grids to obtain the fragments to which each of the grids belongs, the method further includes:

[0020] When the number of fragments corresponding to the current screen coordinates is only one, the fragment corresponding to the current screen coordinates is determined as the target fragment.

[0021] In a second aspect, the present application further provides a depth testing device, the device comprising:

[0022] A grid acquisition module, used to acquire multiple grids of the object to be displayed; each of the grids is provided with a corresponding grid priority;

[0023] A fragment acquisition module is used to process each of the grids to obtain the fragments to which each of the grids belongs; the grid priority of each of the fragments is determined based on the grid priority corresponding to the corresponding grid;

[0024] A target fragment determination module is used to determine the target fragment displayed in the current screen coordinates based on the comparison results between the depth values ​​of the fragments corresponding to the current screen coordinates and the grid priorities of the fragments corresponding to the current screen coordinates when the number of fragments corresponding to the current screen coordinates is at least two.

[0025] In a third aspect, the present application further provides a computer device, wherein the computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.

[0026] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above method when executed by a processor.

[0027] In a fifth aspect, the present application further provides a computer program product, wherein the computer program product comprises a computer program, and when the computer program is executed by a processor, the steps of the above method are implemented.

[0028] The above-mentioned depth testing method, device, computer equipment and storage medium first obtain multiple grids of the object to be displayed, and each grid is set with a corresponding grid priority. Then, each grid is processed to obtain the fragment to which each grid belongs, and the grid priority of each fragment is determined based on the grid priority corresponding to the corresponding grid. Finally, when the number of fragments corresponding to the current screen coordinates is at least two, based on the comparison result between the depth value of each fragment corresponding to the current screen coordinates and the grid priority of each fragment corresponding to the current screen coordinates, the target fragment displayed in the current screen coordinates is determined. The present application can not only significantly improve the display quality of the rendered image by setting the corresponding grid priority for each grid of the object to be displayed before rendering the image, but also effectively improve the global stability and local stability of the rendered image from the fragment level. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] Figure 1 A schematic diagram of a flow chart of a depth testing method provided in an embodiment;

[0030] Figure 2 A flowchart of a specific method for determining a target fragment according to a comparison result between a depth value difference and a depth comparison threshold provided in an embodiment;

[0031] Figure 3 A flowchart of a specific method for determining a target fragment based on a grid priority corresponding to a fragment provided in an embodiment;

[0032] Figure 4 A schematic diagram of a specific application flow of a depth testing method provided by the present application in an actual application is provided in an embodiment;

[0033] Figure 5 A schematic diagram of a specific application flow of another depth testing method provided by the present application in practical application provided in one embodiment;

[0034] Figure 6 A schematic diagram of a specific representation form of a two-dimensional depth texture with four channels provided in an embodiment;

[0035] Figure 7 is a structural block diagram of a depth testing device provided in an embodiment;

[0036] Figure 8 An internal structure diagram of a computer device provided in one embodiment. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present application. It should be understood that the specific embodiments described herein are only used to explain the present application and are not intended to limit the present application.

[0038] When used herein, the singular forms "a", "an", and "said / the" may also include plural forms, unless the context clearly indicates otherwise. It should also be understood that the terms "include / comprise" or "have" and the like specify the presence of stated features, wholes, steps, operations, components, parts, or combinations thereof, but do not exclude the possibility of the presence or addition of one or more other features, wholes, steps, operations, components, parts, or combinations thereof. At the same time, the term "and / or" used in this specification includes any and all combinations of the relevant listed items.

[0039] The depth testing method provided in the embodiment of the present application can be applied to a server or a terminal for execution. The terminal can communicate with the server through a network; the data storage system can store data that the server needs to process; the data storage system can be integrated on the server, or placed on the cloud or other network servers; the terminal can be, but is not limited to, various personal computers, laptops, and tablet computers; the server can be implemented as an independent server or a server cluster consisting of multiple servers.

[0040] In one embodiment, Figure 1 As shown, a depth testing method is provided, comprising the following steps:

[0041] Step S110, obtaining a plurality of grids of the object to be displayed; each grid is set with a corresponding grid priority.

[0042] In this step, the object to be displayed refers to the target object that needs to be displayed on the screen; multiple grids, i.e., multiple grids of the object to be displayed, refer to multiple grids contained in the object grid model of the object to be displayed; the grid priority refers to the grid priority set for each grid contained in the object grid model of the object to be displayed.

[0043] Specifically, the grid priority set for each grid included in the object grid model of the to-be-displayed object may be unique, that is, the grid priority corresponding to each grid is different from that of other grids.

[0044] In actual applications, the priority allocation rules used when setting the grid priority corresponding to each grid can be set by the user based on actual display needs. For example, according to the importance of each grid, the corresponding grid priority is set for it. The higher the importance of the grid, the higher the grid priority set for it. In the case of needing to draw multiple grids at the same time, the grid priority corresponding to each grid can be flexibly adjusted by statically setting or dynamically setting the grid priority corresponding to each grid.

[0045] Step S120, processing each grid to obtain the fragment to which each grid belongs; the grid priority of each fragment is determined based on the grid priority corresponding to the corresponding grid.

[0046] In this step, each grid, that is, each grid of the object to be displayed, refers to each grid contained in the object grid model of the object to be displayed; the fragment refers to a pixel-sized fragment obtained by rasterizing the grid primitives; the fragment to which each grid belongs, that is, the fragment to which each grid of the object to be displayed belongs, refers to the fragment to which each grid of the object to be displayed belongs when it is displayed on the screen; the grid priority of each fragment refers to the grid priority of the fragment to which each grid of the object to be displayed belongs when it is displayed on the screen, and the grid priority corresponding to each fragment is determined based on the grid priority of the grid used to obtain the fragment.

[0047] In practical applications, the specific method for processing each grid to obtain the fragments belonging to each grid is to rasterize the primitives of each grid in the rendering pipeline of the grid (i.e., rasterize the primitives of the grid into multiple small fragments), and then obtain the fragments belonging to each grid.

[0048] Step S130, when the number of fragments corresponding to the current screen coordinates is at least two, determine the target fragment displayed in the current screen coordinates based on the comparison result between the depth value of each fragment corresponding to the current screen coordinates and the grid priority of each fragment corresponding to the current screen coordinates.

[0049] In this step, the current screen coordinates refer to the screen coordinates where the currently rendered pixel (pixel, i.e., the smallest unit of the image containing RGBA values ​​that is finally presented on the screen) is located when it is displayed on the screen; the number of fragments corresponding to the current screen coordinates refers to the specific number of fragments that are consistent with the screen coordinates where the currently rendered pixel is located when it is displayed on the screen; the depth value of each fragment corresponding to the current screen coordinates refers to the depth value corresponding to each fragment that is consistent with the screen coordinates where the currently rendered pixel is located when it is displayed on the screen; the grid priority of each fragment corresponding to the current screen coordinates refers to the grid priority corresponding to each fragment that is consistent with the screen coordinates where the currently rendered pixel is located when it is displayed on the screen; the target fragment, i.e., the target fragment displayed in the current screen coordinates, refers to the target fragment displayed in the current screen coordinates determined based on the comparison result between the depth value corresponding to each fragment that is consistent with the screen coordinates where the currently rendered pixel is located when it is displayed on the screen and the grid priority when the number of fragments corresponding to the current screen coordinates is at least two.

[0050] In practical applications, the depth test method provided by the present application can be used not only to determine the target fragment displayed in the current screen coordinates, but also to determine the color mixing order to adapt to various types of rendering algorithms (for example, the commonly used semi-transparent grid drawing algorithm, the opaque grid rendering algorithm). In addition, since the depth test method provided by the present application does not change the position coordinate relationship of each vertex of the primitive of each grid in space, it can also effectively ensure the accuracy of the depth size relationship between the determined fragments.

[0051] The above-mentioned depth testing method first obtains multiple grids of the object to be displayed, and each grid is set with a corresponding grid priority. Then, each grid is processed to obtain the fragment to which each grid belongs, and the grid priority of each fragment is determined based on the grid priority corresponding to the corresponding grid. Finally, when the number of fragments corresponding to the current screen coordinates is at least two, based on the comparison result between the depth value of each fragment corresponding to the current screen coordinates and the grid priority of each fragment corresponding to the current screen coordinates, the target fragment displayed in the current screen coordinates is determined. The present application can not only significantly improve the display quality of the rendered image by setting the corresponding grid priority for each grid of the object to be displayed before rendering the image, but also effectively improve the global stability and local stability of the rendered image from the fragment level.

[0052] Regarding the specific method of determining the target fragment according to the comparison result between the depth value difference and the depth comparison threshold, in one embodiment, as follows: Figure 2 As shown, the above step S130 specifically includes:

[0053] Step S210, obtaining the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates.

[0054] In this step, the current screen coordinates refer to the screen coordinates where the currently rendered pixel is located when it is displayed on the screen; any two fragments corresponding to the current screen coordinates refer to any two fragments among the fragments corresponding to the current screen coordinates that are obtained when the number of fragments corresponding to the current screen coordinates is at least two; the difference, that is, the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates, refers to the difference between the depth values ​​corresponding to any two fragments among the fragments corresponding to the current screen coordinates that are obtained when the number of fragments corresponding to the current screen coordinates is at least two.

[0055] Step S220: determining a target fragment according to a comparison result between the difference value and a depth comparison threshold.

[0056] In this step, the difference, i.e., the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates, refers to the difference between the depth values ​​corresponding to any two fragments among the fragments corresponding to the current screen coordinates, when the number of fragments corresponding to the current screen coordinates is at least two; the depth comparison threshold refers to the depth comparison threshold used to determine whether the numerical difference between the depth values ​​corresponding to any two fragments among the fragments corresponding to the current screen coordinates meets the depth difference judgment condition; the target fragment, i.e., the target fragment displayed in the current screen coordinates, refers to the target fragment displayed in the current screen coordinates determined based on the comparison result between the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates and the depth comparison threshold.

[0057] In practical applications, the specific form of the depth comparison threshold can be any value set by the user based on actual display requirements, or it can be a default value automatically assigned by the computer device.

[0058] The embodiment of the present application obtains the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates, and determines the target fragment according to the comparison result between the difference and the depth comparison threshold, thereby effectively improving the global stability and local stability of the rendered image from the fragment level, thereby effectively ensuring the display quality of the rendered image.

[0059] Regarding the specific method of determining the target fragment based on the grid priority corresponding to the fragment, in one embodiment, as follows Figure 3 As shown, the above step S220 specifically includes:

[0060] Step S310: Determine whether any two fragments meet a depth difference judgment condition according to a comparison result between the difference value and a depth comparison threshold.

[0061] In this step, the difference, that is, the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates, refers to the difference between the depth values ​​corresponding to any two fragments of the fragments corresponding to the current screen coordinates when the number of fragments corresponding to the current screen coordinates is at least two; the depth comparison threshold refers to the depth comparison threshold used to determine whether the numerical difference between the depth values ​​corresponding to any two fragments of the fragments corresponding to the current screen coordinates meets the depth difference judgment condition; any two fragments, that is, any two fragments corresponding to the current screen coordinates, refer to any two fragments of the fragments corresponding to the current screen coordinates when the number of fragments corresponding to the current screen coordinates is at least two; the depth difference judgment condition can be a depth difference judgment condition used to characterize whether the depth size relationship between the two fragments can be directly judged based only on the depth values ​​corresponding to the two fragments.

[0062] Specifically, the specific reason why the depth size relationship between two fragments cannot be directly determined may be that the triangular facets of the primitives of the grid used to obtain the two fragments are coplanar, which makes the difference between the depth values ​​corresponding to the two fragments too small, exceeding the specific range that the hardware GPU can distinguish. Further, since it is difficult for the GPU to accurately determine the depth size relationship between the two fragments during graphics rendering, there may be a phenomenon of "in the first frame, it is determined that the depth of some triangular facets of the first grid is large, and the depth of some triangular facets of the second grid is small, and in the second frame, it is just the opposite, and the depth of some triangular facets of the first grid is small, and the depth of some triangular facets of the second grid is large", which leads to the problem of poor image quality, more noise, and frequent screen flickering (i.e., causing the z-fighting phenomenon). In addition, in the case of using a semi-transparent grid drawing algorithm, if the difference between the depth values ​​of the two fragments is too small, the GPU is very likely to be unable to accurately determine the depth size relationship between the two fragments, and it is difficult to determine the accurate color mixing order (i.e., the color mixing order determined based on the depth size of each fragment), which will also directly lead to the occurrence of the z-fighting phenomenon.

[0063] Step S320: If any two fragments do not satisfy the depth difference judgment condition, the fragment with a higher corresponding grid priority among the two fragments is determined as the target fragment.

[0064] In this step, any two fragments, that is, any two fragments corresponding to the current screen coordinates, refer to any two fragments among the fragments corresponding to the current screen coordinates that are acquired when the number of fragments corresponding to the current screen coordinates is at least two; the depth difference judgment condition may be a depth difference judgment condition used to characterize whether the depth relationship between the two fragments can be directly judged based only on the depth values ​​corresponding to the two fragments; the target fragment, that is, the target fragment displayed in the current screen coordinates, refers to the target fragment displayed in the current screen coordinates determined based on the fragment with a higher corresponding grid priority among the two fragments when it is determined that the two fragments do not meet the depth difference judgment condition based on the comparison result between the depth values ​​of any two fragments corresponding to the current screen coordinates and the depth comparison threshold.

[0065] The embodiment of the present application determines whether any two fragments meet the depth difference judgment condition based on the comparison result between the difference value and the depth comparison threshold, and when any two fragments do not meet the depth difference judgment condition, the fragment with a higher corresponding grid priority among the any two fragments is determined as the target fragment, thereby effectively improving the display quality of the rendered image.

[0066] Regarding the specific method of determining whether any two fragments meet the depth difference judgment condition, in one embodiment, the above step S310 specifically includes:

[0067] When the difference is greater than or equal to the inverse of the depth comparison threshold and less than or equal to the depth comparison threshold, it is determined that any two fragments do not meet the depth difference judgment condition.

[0068] Among them, the difference, that is, the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates, refers to the difference between the depth values ​​corresponding to any two fragments of the fragments corresponding to the current screen coordinates when the number of fragments corresponding to the current screen coordinates is at least two; the depth comparison threshold refers to the depth comparison threshold used to determine whether the numerical difference between the depth values ​​corresponding to any two fragments of the fragments corresponding to the current screen coordinates meets the depth difference judgment condition; the depth difference judgment condition can be a depth difference judgment condition used to characterize whether the depth size relationship between the two fragments can be directly judged based only on the depth values ​​corresponding to the two fragments.

[0069] Exemplarily, when it is known that the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates is d and the depth comparison threshold is threshold, a specific method for determining that any two fragments do not meet the depth difference judgment condition may be that when -threshold<=d<=threshold, it is determined that the depth relationship between the two fragments cannot be directly judged based solely on the depth values ​​corresponding to the two fragments (that is, the two fragments do not meet the depth difference judgment condition).

[0070] The embodiment of the present application determines that any two fragments do not meet the depth difference judgment condition when the difference is greater than or equal to the inverse of the depth comparison threshold and less than or equal to the depth comparison threshold, thereby effectively improving the global stability and local stability of the rendered image at the fragment level.

[0071] Regarding the specific method of determining the target fragment when preferentially displaying the fragments closer to the observer, in one embodiment, the above step S220 specifically includes:

[0072] If the target fragment screening condition is to preferentially display fragments closer to the observer, then when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold, the fragment with the larger corresponding depth value of any two fragments is determined as the target fragment.

[0073] Among them, the target fragment screening condition refers to the specific screening condition used to screen out the target fragments that pass the depth test; the difference value, that is, the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates, refers to the difference between the depth values ​​corresponding to any two fragments of each fragment corresponding to the current screen coordinates when the number of fragments corresponding to the current screen coordinates is at least two; the depth comparison threshold refers to the depth comparison threshold used to determine whether the numerical difference between the depth values ​​corresponding to any two fragments of each fragment corresponding to the current screen coordinates meets the depth difference judgment condition; the target fragment, that is, the target fragment displayed in the current screen coordinates, refers to the target fragment displayed in the current screen coordinates determined based on the fragment with the larger corresponding depth value of the two fragments when the target fragment screening condition is to give priority to displaying the fragments closer to the observer, and the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates is greater than the depth comparison threshold, or less than the inverse of the depth comparison threshold.

[0074] Exemplarily, when it is known that the target fragment filtering condition is to give priority to displaying fragments that are closer to the observer, and the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates is d, and the depth comparison threshold is threshold, the specific method of determining the fragment with the larger corresponding depth value of any two fragments as the target fragment may be that when d>threshold or d<-threshold, the fragment with the larger corresponding depth value of the two fragments is used as the target fragment displayed in the current screen coordinates.

[0075] The embodiment of the present application effectively improves the display quality of the rendered image by determining the fragment with the larger corresponding depth value between any two fragments as the target fragment when the target fragment screening condition is to give priority to displaying fragments that are closer to the observer and when the difference is greater than a depth comparison threshold, or when the difference is less than the opposite of the depth comparison threshold.

[0076] Regarding the specific manner of determining the target fragment when preferentially displaying the fragments farther from the observer, in one embodiment, the method further includes:

[0077] If the target fragment screening condition is to preferentially display fragments farther from the observer, then when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold, the fragment with the smaller corresponding depth value of any two fragments is determined as the target fragment.

[0078] Among them, the target fragment screening condition refers to the specific screening condition used to screen out the target fragments that pass the depth test; the difference value, that is, the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates, refers to the difference between the depth values ​​corresponding to any two fragments of each fragment corresponding to the current screen coordinates when the number of fragments corresponding to the current screen coordinates is at least two; the depth comparison threshold refers to the depth comparison threshold used to determine whether the numerical difference between the depth values ​​corresponding to any two fragments of each fragment corresponding to the current screen coordinates meets the depth difference judgment condition; the target fragment, that is, the target fragment displayed in the current screen coordinates, refers to the target fragment displayed in the current screen coordinates determined based on the fragment with the smaller corresponding depth value of the two fragments when the target fragment screening condition is to give priority to displaying the fragments farther from the observer, and the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates is greater than the depth comparison threshold, or less than the inverse of the depth comparison threshold.

[0079] Exemplarily, when it is known that the target fragment screening condition is to give priority to displaying fragments that are farther away from the observer, and the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates is d, and the depth comparison threshold is threshold, the specific method of determining the fragment with the smaller corresponding depth value of any two fragments as the target fragment may be that when d>threshold or d<-threshold, the fragment with the smaller corresponding depth value of the two fragments is used as the target fragment displayed in the current screen coordinates.

[0080] In the embodiment of the present application, when the target fragment screening condition is to give priority to displaying fragments that are farther away from the observer, when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold, the fragment with the smaller corresponding depth value between any two fragments is determined as the target fragment, thereby effectively expanding the applicable application scenarios of the depth testing method provided by the present application.

[0081] Regarding the specific method of determining the target fragment when the number of fragments corresponding to the current screen coordinates is only one, in one embodiment, after the above step S120, the following is further included:

[0082] When the number of fragments corresponding to the current screen coordinates is only one, the fragment corresponding to the current screen coordinates is determined as the target fragment.

[0083] Among them, the current screen coordinates refer to the screen coordinates where the currently rendered pixel is located when it is displayed on the screen; the number of fragments corresponding to the current screen coordinates refers to the specific number of fragments that are consistent with the screen coordinates where the currently rendered pixel is located when it is displayed on the screen; the target fragment, that is, the target fragment displayed in the current screen coordinates, refers to the target fragment displayed in the current screen coordinates determined directly based on the fragment when there is only one fragment consistent with the screen coordinates where the currently rendered pixel is located when it is displayed on the screen.

[0084] Specifically, when the number of fragments corresponding to the current screen coordinates is only one, the specific method of determining the fragment corresponding to the current screen coordinates as the target fragment can be that when there is only one fragment that is consistent with the screen coordinates where the currently rendered pixel is displayed on the screen, the fragment is directly used as the target fragment displayed in the current screen coordinates.

[0085] The embodiment of the present application effectively improves the image rendering efficiency by determining the fragment corresponding to the current screen coordinate as the target fragment when the number of fragments corresponding to the current screen coordinate is only one, thereby effectively improving the global stability and local stability of the rendered image from the fragment level.

[0086] In combination with the above embodiments, Figure 4 and Figure 5 As shown, the specific application process of the depth testing method provided by this application in practical applications is generally described as follows:

[0087] First, multiple grids of the object to be displayed are obtained, and based on the importance of each grid, a corresponding grid priority Priority is set for each grid. The depth comparison threshold threshold is determined by the user setting it based on actual display requirements or by the computer device automatically assigning a default value.

[0088] Among them, the specific setting rule of the grid priority Priority can be that the smaller the value, the higher the grid priority represented. For example, the value 1 is used to represent the highest grid priority, and the value 0 is used to represent an invalid grid priority. For other integers greater than the value 1, the smaller the value, the higher the grid priority represented.

[0089] Then, a depth texture that is consistent with the size of a screen (or other graphical user interface (GUI)) for displaying the object to be displayed is constructed, and each channel value of the depth texture is initialized.

[0090] Among them, Figure 6As shown, the above-mentioned depth texture is a two-dimensional depth texture with four channels. For each pixel in the depth texture, the first channel value ch1 is used to characterize the depth value corresponding to the fragment displayed by the current screen coordinates of the pixel, the second channel value ch2 is used to characterize the grid priority corresponding to the fragment displayed by the current screen coordinates of the pixel, and the third channel value ch3 is used to characterize whether the current screen coordinates of the pixel have been written into the fragment (for example, 0 can be used to indicate that the current screen coordinates of the pixel have not been written into the fragment, and 1 can be used to indicate that the current screen coordinates of the pixel have been written into the fragment), and the fourth channel value ch4 is temporarily reserved, and the specific content of the written information is not limited for the time being. The specific way to initialize the channel values ​​of the depth texture is to set the first channel value ch1, the second channel value ch2, the third channel value ch3, and the fourth channel value ch4 corresponding to each pixel of the depth texture to the initial value 0.

[0091] Next, in the rendering pipeline, rasterization processing is completed for the primitives of each grid to obtain the fragments belonging to each grid.

[0092] Among them, since the depth value (z) of the current fragment Frag is in the range of -1 to 1 when the rasterization process is just completed, before shading the current fragment, the depth value of the current fragment Frag needs to be converted to the range of 0 to 1, and then the updated depth value Z of the current fragment is obtained. cur Furthermore, the updated depth value Z of the current fragment cur , can be calculated based on the following formula:

[0093]

[0094] Afterwards, based on the screen coordinates, each pixel in the depth texture is sampled in turn (ie, each channel value corresponding to each pixel is obtained), and according to the sampling result, the depth texture is updated in real time during the rendering process.

[0095] Specifically, when the target fragment screening condition is to give priority to displaying fragments that are closer to the observer, the above sampling results can be expressed in the following specific forms:

[0096] 1. The third channel value corresponding to a pixel is equal to 0, which means that the current screen coordinates of the pixel are not written into the fragment. At this time, the relevant information of the fragment corresponding to the current screen coordinates can be directly written into the current screen coordinates of the pixel in the depth texture (that is, the first channel value ch1 of the pixel is set to the depth value corresponding to the current fragment, the second channel value ch2 of the pixel is set to the grid priority corresponding to the current fragment, and the third channel value ch3 of the pixel is set to 1, to indicate that the current screen coordinates of the pixel have been written into the fragment).

[0097] 2. If the third channel value corresponding to a pixel is not equal to 0, it means that the current screen coordinates of the pixel have been written into the fragment. At this time, in the depth texture, the difference between the depth values ​​corresponding to the fragment written in the current screen coordinates of the pixel and the current fragment (that is, the current fragment whose corresponding screen coordinates are also the current screen coordinates) can be compared with the above-mentioned depth comparison threshold threshold, and based on the result of the above-mentioned comparison, it is determined whether the two fragments meet the depth difference judgment condition (that is, whether the depth difference judgment condition of the depth size relationship between the two fragments can be directly judged based only on the depth values ​​corresponding to the two fragments).

[0098] Among them, it is assumed that the above difference is known to be d (d is equal to the depth value Z of the current fragment cur Subtract the first channel value ch1 of the current screen coordinates), and the depth difference judgment condition is "when -threshold<=d<=threshold, it is determined that the depth size relationship between the two fragments cannot be directly determined", then when the two fragments do not meet the depth difference judgment condition, the fragment with a higher grid priority in the two fragments can be used as the target fragment displayed in the current screen coordinates (that is, if the fragment with a higher grid priority in the two fragments is the current fragment, it is confirmed that the current fragment has passed the depth test, and the relevant information of the current fragment is rewritten in the current screen coordinates where the pixel is located to update the first channel value ch1 and the second channel value c corresponding to the current screen coordinates). h2; if the fragment with a higher grid priority in the two fragments is a written fragment, it is confirmed that the current fragment cannot pass the depth test, and there is no need to change any channel value corresponding to the current screen coordinates in the depth texture); and when the two fragments meet the depth difference judgment condition, if d>threshold, it is determined that the current fragment cannot pass the depth test, and there is no need to change any channel value corresponding to the current screen coordinates in the depth texture; if d<-threshold, it is confirmed that the current fragment has passed the depth test, and it is necessary to rewrite the relevant information of the current fragment in the current screen coordinates where the pixel is located to update the first channel value ch1 and the second channel value ch2 corresponding to the current screen coordinates.

[0099] Furthermore, when the target fragment screening condition is to preferentially display fragments that are farther from the observer, based on the above sampling results, it can be determined whether the current fragment can pass the depth test in the following manner:

[0100] When d>threshold, it is determined that the current fragment passes the depth test;

[0101] When d<-threshold, it is determined that the current fragment fails the depth test.

[0102] In one embodiment, the z-fighting phenomenon caused by depth error, fluctuating depth values, etc. will significantly affect the image display quality (i.e., the real-time rendered image will have more noise and poor image quality), and the poor image display quality is very likely to mislead doctors during the process of diagnosing diseases or performing surgery, thereby causing doctors to misdiagnose. In view of the fact that the depth testing method provided by the present application can significantly improve the display quality of real-time rendered images, when the depth testing method provided by the present application is applied to the field of medical imaging, it can also effectively reduce the misdiagnosis caused by poor image display quality during the process of doctors diagnosing clinical diseases and performing surgery.

[0103] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0104] Based on the same inventive concept, the embodiment of the present application also provides a depth testing device for implementing the depth testing method involved above. The implementation solution provided by the device to solve the problem is similar to the implementation solution recorded in the above method, so the specific limitations in one or more depth testing device embodiments provided below can refer to the limitations on the depth testing method above, and will not be repeated here.

[0105] In one embodiment, Figure 7 As shown, a depth testing device is provided, the device comprising:

[0106] A grid acquisition module 710 is used to acquire multiple grids of the object to be displayed; each of the grids is set with a corresponding grid priority;

[0107] The fragment acquisition module 720 is used to process each of the grids to obtain the fragments to which each of the grids belongs; the grid priority of each of the fragments is determined based on the grid priority corresponding to the corresponding grid;

[0108] The target fragment determination module 730 is used to determine the target fragment displayed in the current screen coordinates based on the comparison results between the depth values ​​of the fragments corresponding to the current screen coordinates and the grid priorities of the fragments corresponding to the current screen coordinates when the number of fragments corresponding to the current screen coordinates is at least two.

[0109] In one of the embodiments, the target fragment determination module 730 is specifically configured to obtain the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates; and determine the target fragment according to a comparison result between the difference and a depth comparison threshold.

[0110] In one of the embodiments, the target fragment determination module 730 is also used to determine whether the any two fragments meet the depth difference judgment condition based on the comparison result between the difference and the depth comparison threshold; if the any two fragments do not meet the depth difference judgment condition, then the fragment with a higher corresponding grid priority among the any two fragments is determined as the target fragment.

[0111] In one of the embodiments, the target fragment determination module 730 is further used to determine that the arbitrary two fragments do not satisfy the depth difference judgment condition when the difference is greater than or equal to the inverse of the depth comparison threshold and less than or equal to the depth comparison threshold.

[0112] In one of the embodiments, the target fragment determination module 730 is also used to determine the fragment with the larger corresponding depth value among any two fragments as the target fragment if the target fragment screening condition is to preferentially display fragments that are closer to the observer, when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold.

[0113] In one of the embodiments, the above-mentioned device also includes: a depth threshold comparison module, which is used to determine the fragment with the smaller corresponding depth value among any two fragments as the target fragment if the target fragment screening condition is to preferentially display fragments that are farther away from the observer, when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold.

[0114] In one of the embodiments, the above-mentioned device further includes: a target fragment writing module, which is used to determine the fragment corresponding to the current screen coordinate as the target fragment when the number of fragments corresponding to the current screen coordinate is only one.

[0115] Each module in the above-mentioned depth testing device can be implemented in whole or in part by software, hardware and their combination. Each of the above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0116] In one embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 8 As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. Among them, the processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and the external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. When the computer program is executed by the processor, a depth testing method is implemented. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0117] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0118] In one embodiment, a computer device is provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above-mentioned method embodiments when executing the computer program.

[0119] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above method embodiments are implemented.

[0120] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0121] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant laws, regulations and standards of relevant countries and regions.

[0122] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, etc., but are not limited to this.

[0123] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0124] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A depth testing method, characterized in that: The method comprises: Acquire multiple grids of the object to be displayed; each of the grids is set with a corresponding grid priority; Processing each of the grids to obtain the fragments to which each of the grids belongs; the grid priority of each of the fragments is determined based on the grid priority corresponding to the corresponding grid; When the number of fragments corresponding to the current screen coordinates is at least two, the target fragment displayed in the current screen coordinates is determined based on the comparison result between the depth values ​​of the fragments corresponding to the current screen coordinates and the grid priorities of the fragments corresponding to the current screen coordinates.

2. The method according to claim 1, characterized in that The determining the target fragment displayed in the current screen coordinates based on the comparison result between the depth value of each fragment corresponding to the current screen coordinates and the grid priority of each fragment corresponding to the current screen coordinates includes: Get the difference between the depth values ​​of any two fragments corresponding to the current screen coordinates; The target fragment is determined according to a comparison result between the difference and a depth comparison threshold.

3. The method according to claim 2, characterized in that The step of determining the target fragment according to a comparison result between the difference value and a depth comparison threshold value includes: Determining whether the two fragments satisfy a depth difference judgment condition according to a comparison result between the difference value and a depth comparison threshold; If the arbitrary two fragments do not satisfy the depth difference judgment condition, the fragment with a higher corresponding grid priority among the arbitrary two fragments is determined as the target fragment.

4. The method according to claim 3, characterized in that: The determining, according to a comparison result between the difference value and a depth comparison threshold, whether the two arbitrary fragments satisfy a depth difference judgment condition comprises: When the difference is greater than or equal to the negative number of the depth comparison threshold and less than or equal to the depth comparison threshold, it is determined that the arbitrary two fragments do not satisfy the depth difference judgment condition.

5. The method according to claim 2, characterized in that: The determining the target fragment according to the comparison result between the difference value and the depth comparison threshold value further includes: If the target fragment screening condition is to preferentially display fragments that are closer to the observer, then when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold, the fragment with the larger corresponding depth value among any two fragments is determined as the target fragment.

6. The method according to claim 5, characterized in that The method further comprises: If the target fragment screening condition is to preferentially display fragments that are farther away from the observer, then when the difference is greater than the depth comparison threshold, or the difference is less than the opposite of the depth comparison threshold, the fragment with the smaller corresponding depth value among any two fragments is determined as the target fragment.

7. The method according to any one of claims 1 to 6, characterized in that After processing each of the grids to obtain the fragments to which each of the grids belongs, the method further includes: When the number of fragments corresponding to the current screen coordinates is only one, the fragment corresponding to the current screen coordinates is determined as the target fragment.

8. A depth testing device, characterized in that: The device comprises: A grid acquisition module, used to acquire multiple grids of the object to be displayed; each of the grids is provided with a corresponding grid priority; A fragment acquisition module is used to process each of the grids to obtain the fragments to which each of the grids belongs; the grid priority of each of the fragments is determined based on the grid priority corresponding to the corresponding grid; A target fragment determination module is used to determine the target fragment displayed in the current screen coordinates based on the comparison results between the depth values ​​of the fragments corresponding to the current screen coordinates and the grid priorities of the fragments corresponding to the current screen coordinates when the number of fragments corresponding to the current screen coordinates is at least two.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.