Method and system for solving Z-Flight based on image evaluation
By judging and processing the Z-Flighting phenomenon in 3D model rendering, and selecting the appropriate mesh ID using the aggregation processing and scoring model, the automatic judgment and correction of the Z-Flighting phenomenon in 3D rendering is solved, and stable and accurate rendering results are achieved.
Patent Information
- Application Number
- CN202510168521.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-17
- Publication Date
- 2025-06-06
AI Technical Summary
In computer graphics, during three-dimensional rendering, due to the closeness of the depth (Z value) of the geometry or surface, the rendering engine cannot accurately determine the rendering order, and random flickering of the surface occurs, which is called Z-Flighting. The existing technology cannot automatically judge and correct this problem.
By determining whether there is a Z-Flighting phenomenon at the beginning of the three-dimensional model rendering, if there is, the pixels with Z-Flighting phenomenon occur are aggregated to form a mesh ID tuple, and the image corresponding to the highest-rated mesh ID is evaluated and selected for template testing through the scoring model. If it is passed, the corresponding pixels will be presented to the final rendering result.
Automatic judgment and correction of Z-Flighting phenomenon is achieved, manual intervention is avoided, and the stability and accuracy of rendering results are ensured, and the calculation cost is not significantly increased.
Smart Images

Figure CN120107442A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of computer graphics processing, and in particular to a method and system for solving Z-Flighting based on image evaluation. Background Art
[0002] Z-Flighting is a common problem in computer graphics, especially in 3D rendering. It usually occurs when two or more geometries or surfaces share the same space and their depths (Z values) are very close, causing the rendering engine to be unable to accurately determine which surface should be displayed in front of the other surface, resulting in random flickering of the surface.
[0003] Currently, the renderer cannot determine whether Z-Flighting occurs in the rendered result. The only way to eliminate this phenomenon is to correct the model after manual judgment. Summary of the invention
[0004] In order to at least partially solve the above technical problems, the present application provides a method and system for solving Z-Flighting based on image evaluation.
[0005] In a first aspect, the present application provides a method for solving Z-Flighting based on image evaluation, which adopts the following technical solution.
[0006] A method for solving Z-Flighting based on image evaluation, comprising:
[0007] After the 3D model rendering starts, determine whether the Z-Flighting phenomenon exists; if not, obtain the final rendering result;
[0008] If it exists, the pixels with Z-Flighting phenomenon are aggregated, and the pixels whose interval distance does not exceed a% of the viewport diagonal length are processed into a set U; a is a positive number;
[0009] For each set U, traverse the mesh ID values of all pixels in the set U to form a mesh ID tuple S{id1, id2, id3,...} without duplicate values;
[0010] All pixels in the set U are assigned the values in the mesh ID tuple S in turn; the rendering results of all images are evaluated using the scoring model, and the image corresponding to the mesh ID with the highest score is selected;
[0011] A template test is performed on the image corresponding to the mesh ID with the highest score; if the template test is passed, the corresponding pixel is presented in the final rendering result.
[0012] Optionally, determine whether the Z-Flighting phenomenon exists, including:
[0013] Generate an ID for each mesh contained in the 3D model;
[0014] Write each mesh ID into the corresponding vertex information so that the vertex information corresponding to each mesh ID includes position coordinates, normal direction, UV value and mesh ID;
[0015] Get a texture with the size of the viewport as the rendering target, and each pixel is used to store the ID of the mesh where the pixel is located;
[0016] Continuously calculate to obtain N rendering targets; compare whether the values of pixels at the same position on N and N+1 are consistent; if they are inconsistent, Z-Flighting phenomenon exists.
[0017] Optionally, the method for generating the scoring model includes:
[0018] Collect rendering images of different 3D models at different camera angles; half of the rendering images have Z-Flighting phenomenon, and the other half do not; randomly select half of the rendering image data as training set, one quarter as validation set, and one quarter as test set;
[0019] Preprocess the rendered image and crop the rendered image to a uniform size;
[0020] Label and score each rendered image;
[0021] Design a neural network structure, including convolutional layers, pooling layers, fully connected layers, etc., with an input of an image and an output of a score ranging from 0 to 5;
[0022] Select cross entropy loss as the loss function to train the model; use the training set to train the model and validate it on the validation set, and adjust the hyperparameters to improve the model performance;
[0023] Use the test set to evaluate the performance of the scoring model;
[0024] When the evaluation result of the scoring model meets the predetermined target, the scoring model is saved.
[0025] Optionally, pixels with Z-Flighting phenomenon are aggregated, including:
[0026] For each pixel P[i,j], check whether its surrounding pixels belong to the Z-Flighting phenomenon;
[0027] If there are pixels with Z-Flighting around P[i,j], calculate the distance D[i,j] between P[i,j] and its surrounding pixels;
[0028] If D[i,j] is less than or equal to a% of the length of the viewport diagonal, then add pixel P[i,j] to set U.
[0029] Optionally, generate an ID for each mesh contained in the 3D model, including:
[0030] Assign an initial ID to the first mesh in the 3D model. Assign incremental IDs to each subsequent mesh in sequence; and create an associative array to store each mesh's ID and its corresponding information;
[0031] Write each mesh ID into the corresponding vertex information, including: extending the existing vertex data format and adding a field for storing the mesh ID.
[0032] Optional neural network architecture, including:
[0033] Input layer: used to accept standardized image data;
[0034] Convolutional layer: used to extract local features of the image; each convolutional layer is followed by an activation function to increase nonlinear expression capabilities;
[0035] Pooling layer: used to reduce the spatial dimension of the feature map;
[0036] Fully connected layer: maps the features generated by the convolutional layer to a higher dimensional space, and finally connects to an output layer to output a single value;
[0037] Output layer: A linear activation function is used to output a score ranging from 0 to 5, reflecting the image rating.
[0038] In the second aspect, the present application provides a system for solving Z-Flighting based on image evaluation, which adopts the following technical solution.
[0039] A system for solving Z-Flighting based on image evaluation, characterized by comprising:
[0040] The first processing module is used to: after the 3D model rendering starts, determine whether there is a Z-Flighting phenomenon; if not, obtain the final rendering result;
[0041] The second processing module is used to: when the Z-Flighting phenomenon exists, aggregate the pixels where the Z-Flighting phenomenon occurs, and process the pixels whose interval distance does not exceed a% of the diagonal length of the viewport into a set U; a is a positive number;
[0042] The third processing module is used to: for each set U, traverse the mesh ID values of all pixels in the set U to form a mesh ID tuple S{id1, id2, id3, ...} with duplicate values removed;
[0043] The fourth processing module is used to: assign values in the mesh ID tuple S to all pixels in the set U in turn; and evaluate the rendering results of all images through the scoring model, and select the image corresponding to the mesh ID with the highest score;
[0044] The fifth processing module is used to: perform a template test on the image corresponding to the mesh ID with the highest score; if the template test is passed, present the corresponding pixel in the final rendering result.
[0045] In a third aspect, the present application discloses an electronic device, comprising a memory and a processor, wherein the memory stores a computer program that is loaded by the processor and executes any of the above methods.
[0046] In a fourth aspect, the present application discloses a computer-readable storage medium storing a computer program that can be loaded by a processor and execute any of the above methods. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 is a flow chart of a method for solving Z-Flighting based on image evaluation in an embodiment of the present application;
[0048] Figure 2 This is a system block diagram of a system for solving Z-Flighting based on image evaluation in an embodiment of the present application;
[0049] In the figure, 201 is a first processing module; 202 is a second processing module; 203 is a third processing module; 204 is a fourth processing module; 205 is a fifth processing module. DETAILED DESCRIPTION
[0050] The following is combined with Figure 1-2 The present application is further described with specific embodiments:
[0051] First of all, it should be noted that in the description of this application, if the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inside", "outside" and other directional words appear, the orientation or position relationship indicated is based on the orientation or position relationship shown in the drawings, which is only for the convenience of description, and does not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation of this application; in addition, if the terms "first", "second", "third" and other numerical quantifiers appear, they are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in this application, unless otherwise clearly specified and limited, if the terms "installed", "connected", and "connected" appear, they should be understood in a broad sense, for example, it can be a fixed connection, or a detachable connection, a limited connection such as an interference fit, a transition fit, or an integral connection; it can be directly connected or indirectly connected through an intermediate medium; therefore, for ordinary technicians in this field, the specific meanings of the above terms in this application can be understood according to the specific circumstances.
[0052] Z-Flighting is a common problem in computer graphics, especially in 3D rendering. It usually occurs when two or more geometries or surfaces share the same space and their depths (Z values) are very close, causing the rendering engine to be unable to accurately determine which surface should be displayed before the other surface, resulting in random flickering of the surface. Specifically for architectural model rendering, unexpected rendering effects will occur in the following situations:
[0053] Closely spaced planes: When two planes in a building model are very close and share the same viewing angle, their depth values may be very close. In this case, Z-Flighting causes the surfaces of the two planes to appear alternately when rendered, creating a visual flickering effect.
[0054] Edges and corners: At the edges, corners or subtle structures of buildings, Z-Flighting may cause unclear outlines of these edges or corners due to the proximity of multiple geometries or polygons, resulting in intermittent visual effects.
[0055] Transparent materials and glass surfaces: Transparent materials common in architectural models (such as glass windows) are also prone to Z-Flighting problems, especially when transparent surfaces overlap with opaque surfaces, the limitations of the Z buffer may lead to incorrect rendering order.
[0056] Complex structures and layers: Complex building structures, especially those with multiple layers or overlapping areas, are prone to Z-Flighting. For example, when the perspective changes for multi-layered floors or staggered building volumes, the depth relationship between different parts becomes complicated, which may lead to the appearance of Z-Flighting.
[0057] There are currently the following common methods to alleviate the Z-Flighting phenomenon:
[0058] Increase the precision of the Z buffer: Increasing the number of bits in the Z buffer can improve the precision of the depth information, thereby reducing the possibility of Z-Flighting. This can be achieved by increasing the number of bits in the Z buffer or using a higher precision depth buffer.
[0059] Polygon Offset: Some renderers support a polygon offset function that can fine-tune the depth values of polygons so that they are slightly offset to avoid Z wrapping. This method is usually suitable for situations where complex geometry needs to be rendered.
[0060] Use better depth testing methods: Sometimes more complex depth testing algorithms, such as dual depth peeling, can be used to deal with Z-Flighting issues, although this may increase computational cost.
[0061] However, the current renderer cannot determine whether Z-Flighting occurs in the rendered result. The only way to eliminate this phenomenon is to correct the model after manual judgment.
[0062] In order to at least partially solve the above technical problems, the embodiment of the present application discloses a method for solving Z-Flighting based on image evaluation, comprising the following steps:
[0063] Step 101: After the 3D model rendering starts, determine whether the Z-Flighting phenomenon exists; if not, obtain the final rendering result. Specifically, in 3D rendering, when two or more facets are very close in depth, due to the limitation of floating point precision or the insufficiency of the rendering algorithm, the rendering result may have flickering or unstable display effects. This situation is called the Z-Flighting phenomenon.
[0064] Step 102, if it exists, then perform aggregation processing on the pixels where the Z-Flighting phenomenon occurs, and process the pixels whose interval distance does not exceed a% of the viewport diagonal length into a set U; a is a positive number. Specifically, a pixel is the basic unit of an image and represents a point in the image. Each pixel has a specific color value. "a%" refers to the percentage of the diagonal length of the viewport (i.e., the window that displays the image). The viewport diagonal length refers to the length of the hypotenuse of the right triangle formed by the viewport width and height. In this application, a can be 5. The purpose of the aggregation processing is to deal with the Z-Flighting phenomenon in multiple different areas.
[0065] Step 103: For each set U, traverse the mesh ID values of all pixels in the set U to form a mesh ID tuple S{id1, id2, id3, ...} with duplicate values removed.
[0066] Step 104: assign values in the mesh ID tuple S to all pixels in the set U in turn; and evaluate the rendering results of all images using a scoring model, and select the image corresponding to the mesh ID with the highest score.
[0067] Step 105: Perform a template test on the image corresponding to the mesh ID with the highest score; if the template test is passed, the corresponding pixel is presented in the final rendering result.
[0068] Specifically, the technical solution of the present application modifies the depth detection result by scoring the current rendering result, thereby obtaining the correct mesh to be rendered, and finally outputting the expected rendering result. This method does not significantly increase the computational cost and does not require manual intervention.
[0069] As a specific implementation of a method for solving Z-Flighting based on image evaluation, determining whether the Z-Flighting phenomenon exists includes:
[0070] Generate an ID for each mesh contained in the 3D model;
[0071] Write each mesh ID into the corresponding vertex information so that the vertex information corresponding to each mesh ID includes position coordinates, normal direction, UV value and mesh ID;
[0072] Get a texture with the size of the viewport as the rendering target, and each pixel is used to store the ID of the mesh where the pixel is located;
[0073] Continuously calculate to obtain N rendering targets; compare whether the pixel values at the same position on N and N+1 are consistent; if they are inconsistent, there is a Z-Flighting phenomenon. For example, if the mesh ID of P[5]
[10] in the first texture value is 82 and the mesh ID of P[5]
[10] in the second texture value is 90, then a Z-Flighting phenomenon occurs.
[0074] Specifically, assign a unique identifier (ID) to each mesh. During the rendering process, add this mesh ID to all vertex data of each mesh. Create a texture that matches the size of the viewport and use it as the rendering target. Each pixel of this texture will be used to record the mesh ID at the corresponding screen space position. Write the ID of each mesh into the texture created above, continuously render multiple frames, and save the mesh ID textures of these frames. For any two frames (such as the Nth frame and the N+1th frame), compare whether their mesh IDs at the same pixel position are consistent. If an inconsistent situation is found, then this may indicate the occurrence of Z-Flighting.
[0075] As a specific implementation of a method for solving Z-Flighting based on image evaluation, the method for generating the scoring model includes:
[0076] Collect rendering images of different 3D models at different camera angles; among them, half of the rendering images have the Z-Flighting phenomenon, and the other half of the rendering images do not have the Z-Flighting phenomenon; randomly select one-half of the data of the rendering images as the training set, one-fourth as the validation set, and one-fourth as the test set;
[0077] Preprocess the rendering images and crop the sizes of the rendering images to a unified size;
[0078] Score the labels of each rendering image. The scoring criteria can be: no Z-Flighting phenomenon, 5 points; 0 < Z-Flighting phenomenon accounts for the image area ≤ 10%, 4 points; 10% < Z-Flighting phenomenon accounts for the image area ≤ 20%, 3 points; 20% < Z-Flighting phenomenon accounts for the image area ≤ 30%, 2 points; 30% < Z-Flighting phenomenon accounts for the image area ≤ 40%, 1 point; Z-Flighting phenomenon accounts for the image area > 40%, 0 points.
[0079] Design a neural network structure, including convolutional layers, pooling layers, fully connected layers, etc., with an input of an image and an output of a score ranging from 0 to 5;
[0080] Select cross entropy loss as the loss function to train the model; use the training set to train the model and validate it on the validation set, and adjust the hyperparameters to improve the model performance;
[0081] Use the test set to evaluate the performance of the scoring model;
[0082] When the evaluation result of the scoring model meets the predetermined target, the scoring model is saved.
[0083] As a specific implementation of a method for solving Z-Flighting based on image evaluation, pixels with Z-Flighting phenomenon are aggregated, including:
[0084] For each pixel P[i,j], check whether its surrounding pixels belong to the Z-Flighting phenomenon;
[0085] If there are pixels with Z-Flighting around P[i,j], calculate the distance D[i,j] between P[i,j] and its surrounding pixels;
[0086] If D[i,j] is less than or equal to a% of the length of the viewport diagonal, then add pixel P[i,j] to set U.
[0087] As one implementation of a method for solving Z-Flighting based on image evaluation, an ID is generated for each mesh included in the 3D model, including:
[0088] Assign an initial ID to the first mesh in the 3D model. Assign incremental IDs to each subsequent mesh in sequence; and create an associative array to store each mesh's ID and its corresponding information;
[0089] Write each mesh ID into the corresponding vertex information, including: extending the existing vertex data format and adding a field for storing the mesh ID.
[0090] As one implementation of a method for solving Z-Flighting based on image evaluation, a neural network structure is designed, including:
[0091] Input layer: used to accept standardized image data;
[0092] Convolutional layer: used to extract local features of the image; each convolutional layer is followed by an activation function to increase nonlinear expression capabilities;
[0093] Pooling layer: used to reduce the spatial dimension of the feature map;
[0094] Fully connected layer: maps the features generated by the convolutional layer to a higher dimensional space, and finally connects to an output layer to output a single value;
[0095] Output layer: A linear activation function is used to output a score ranging from 0 to 5, reflecting the image rating.
[0096] The present application also provides a system for solving Z-Flighting based on image evaluation, as one implementation of the system for solving Z-Flighting based on image evaluation, including:
[0097] The first processing module 201 is used to: after the 3D model rendering starts, determine whether there is a Z-Flighting phenomenon; if not, obtain the final rendering result;
[0098] The second processing module 202 is used to: when the Z-Flighting phenomenon exists, aggregate the pixels where the Z-Flighting phenomenon occurs, and process the pixels whose interval distance does not exceed a% of the length of the viewport diagonal into a set U; a is a positive number;
[0099] The third processing module 203 is used to: for each set U, traverse the mesh ID values of all pixels in the set U to form a mesh ID tuple S{id1, id2, id3, ...} with duplicate values removed;
[0100] The fourth processing module 204 is used to: sequentially assign values in the mesh ID tuple S to all pixels in the set U; and evaluate the rendering results of all images using a scoring model, and select the image corresponding to the mesh ID with the highest score;
[0101] The fifth processing module 205 is used to: perform a template test on the image corresponding to the mesh ID with the highest score; if the template test is passed, present the corresponding pixel in the final rendering result.
[0102] The embodiment of the present application also discloses an electronic device.
[0103] Specifically, the device includes a memory and a processor, and the memory stores a computer program that can be loaded by the processor and execute any one of the above-mentioned methods for solving Z-Flighting based on image evaluation.
[0104] The embodiment of the present application also discloses a computer-readable storage medium. Specifically, the computer-readable storage medium stores a computer program that can be loaded by a processor and execute any of the above-mentioned methods for solving Z-Flighting based on image evaluation, and the computer-readable storage medium includes, for example: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0105] It should be noted that the above embodiments are only used to illustrate the present application and are not intended to limit the technical solutions described in the present application. Although the present application has been described in detail in this specification with reference to the above embodiments, a person of ordinary skill in the art should understand that a person of ordinary skill in the art can still modify or make equivalent substitutions to the present application, and all technical solutions and improvements thereof that do not depart from the spirit and scope of the present application should be included in the scope of the claims of the present application.
Claims
1. A method for solving Z-Flighting based on image evaluation, characterized in that: include: After the 3D model rendering starts, determine whether there is a Z-Flighting phenomenon; If it does not exist, the final rendering result is obtained; If it exists, the pixels with Z-Flighting phenomenon are aggregated, and the pixels whose interval distance does not exceed a% of the viewport diagonal length are processed into a set U; a is a positive number; For each set U, traverse the mesh ID values of all pixels in the set U to form a meshID tuple S{id1, id2, id3,...} without duplicate values; All pixels in the set U are assigned the values in the mesh ID tuple S in turn; the rendering results of all images are evaluated using the scoring model, and the image corresponding to the mesh ID with the highest score is selected; Performing a template test on the image corresponding to the mesh ID with the highest score; If the template test passes, the corresponding pixel will be presented to the final rendering result.
2. A method for solving Z-Flighting based on image evaluation according to claim 1, characterized in that: Determine whether Z-Flighting occurs, including: Generate an ID for each mesh contained in the 3D model; Write each mesh ID into the corresponding vertex information so that the vertex information corresponding to each mesh ID includes position coordinates, normal direction, UV value and mesh ID; Get a texture with the size of the viewport as the rendering target, and each pixel is used to store the ID of the mesh where the pixel is located; Continuously calculate to obtain N rendering targets; compare whether the values of pixels at the same position on N and N+1 are consistent; if they are inconsistent, Z-Flighting phenomenon exists.
3. The method for solving Z-Flighting based on image evaluation according to claim 2, characterized in that: The method for generating the scoring model includes: Collect rendering images of different 3D models at different camera angles; half of the rendering images have Z-Flighting phenomenon, and the other half do not; randomly select half of the rendering image data as training set, one quarter as validation set, and one quarter as test set; Preprocess the rendered image and crop the rendered image to a uniform size; Label and score each rendered image; Design a neural network structure, including convolutional layers, pooling layers, fully connected layers, etc., with an input of an image and an output of a score ranging from 0 to 5; Select cross entropy loss as the loss function to train the model; use the training set to train the model and validate it on the validation set, and adjust the hyperparameters to improve the model performance; Use the test set to evaluate the performance of the scoring model; When the evaluation result of the scoring model meets the predetermined target, the scoring model is saved.
4. The method for solving Z-Flighting based on image evaluation according to claim 3, characterized in that: Aggregate pixels with Z-Flighting, including: For each pixel P[i,j], check whether its surrounding pixels belong to the Z-Flighting phenomenon; If there are pixels with Z-Flighting around P[i,j], calculate the distance D[i,j] between P[i,j] and its surrounding pixels; If D[i,j] is less than or equal to a% of the length of the viewport diagonal, then add pixel P[i,j] to set U.
5. The method for solving Z-Flighting based on image evaluation according to claim 4, characterized in that: Generate an ID for each mesh contained in the 3D model, including: Assign an initial ID to the first mesh in the 3D model. Assign incremental IDs to each subsequent mesh in sequence; and create an associative array to store each mesh's ID and its corresponding information; Write each mesh ID into the corresponding vertex information, including: extending the existing vertex data format and adding a field for storing the mesh ID.
6. The method for solving Z-Flighting based on image evaluation according to claim 5, characterized in that: Design the neural network structure, including: Input layer: used to accept standardized image data; Convolutional layer: used to extract local features of the image; each convolutional layer is followed by an activation function to increase nonlinear expression capabilities; Pooling layer: used to reduce the spatial dimension of the feature map; Fully connected layer: maps the features generated by the convolutional layer to a higher dimensional space, and finally connects to an output layer to output a single value; Output layer: A linear activation function is used to output a score ranging from 0 to 5, reflecting the image rating.
7. A system for solving Z-Flighting based on image evaluation, characterized in that: include: The first processing module is used to: determine whether there is a Z-Flighting phenomenon after the three-dimensional model rendering starts; If it does not exist, the final rendering result is obtained; The second processing module is used to: when the Z-Flighting phenomenon exists, aggregate the pixels where the Z-Flighting phenomenon occurs, and process the pixels whose interval distance does not exceed a% of the diagonal length of the viewport into a set U; a is a positive number; The third processing module is used to: for each set U, traverse the mesh ID values of all pixels in the set U to form a mesh ID tuple S{id1, id2, id3, ...} with duplicate values removed; The fourth processing module is used to: assign values in the mesh ID tuple S to all pixels in the set U in turn; and evaluate the rendering results of all images through the scoring model, and select the image corresponding to the mesh ID with the highest score; A fifth processing module is used to: perform a template test on the image corresponding to the mesh ID with the highest score; If the template test passes, the corresponding pixel will be presented to the final rendering result.
8. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program according to any one of the methods of claims 1 to 6 which is loaded and executed by the processor.
9. A computer-readable storage medium, characterized in that: A computer program is stored which can be loaded by a processor and execute the method according to any one of claims 1 to 6.