A 3D model rendering method, device, equipment and computer-readable storage medium
By performing coordinate offset processing on the intersecting grids in the 3D model, the depth conflict problem is solved, the rendering effect and user experience are improved, and a more efficient rendering process is achieved.
Patent Information
- Application Number
- CN202311702212.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-12
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2043-12-12
AI Technical Summary
During the 3D model rendering process, the depth conflict (z-fighting) problem makes it difficult to identify the grid position, causing the rendering interface to flicker, reducing the rendering effect and user experience.
By obtaining the position of the grid on the 3D model in the coordinate system, determine the intersecting target grid, and perform coordinate offset processing on it to increase the distance between the grids, thereby avoiding depth conflicts and improving the rendering effect.
It effectively avoids the z-fighting problem, improves the rendering effect and user experience, and improves rendering efficiency and speed.
Smart Images

Figure CN117934681B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a 3D model rendering method, device, equipment and computer-readable storage medium. Background Art
[0002] When rendering 3D models, depth conflict (z-fighting) problems often occur. The z-fighting problem refers to the situation where two meshes on a 3D model are too close to each other, resulting in intersection. The rendering engine cannot accurately identify which mesh is in front and which is behind, causing the two meshes to flicker and alternate on the rendering interface after rendering, thereby reducing the rendering effect and user experience. Summary of the invention
[0003] In order to solve the above technical problems or at least partially solve the above technical problems, the present disclosure provides a rendering method, device, equipment and computer-readable storage medium for a 3D model.
[0004] In a first aspect, an embodiment of the present disclosure provides a method for rendering a 3D model, comprising:
[0005] Acquire a 3D model; determine a target grid that intersects and is perpendicular to the same coordinate axis in the coordinate system based on the position of the grid on the 3D model in the coordinate system of the 3D model; perform coordinate offset processing on the target grid to obtain the offset coordinates of the target grid; render the target grid based on the offset coordinates of the target grid.
[0006] In a second aspect, an embodiment of the present disclosure provides a 3D model rendering device, including:
[0007] An acquisition module, used to acquire a 3D model;
[0008] A determination module, configured to determine, based on the position of the grid on the 3D model in the coordinate system of the 3D model, a target grid that intersects and is perpendicular to the same coordinate axis in the coordinate system;
[0009] An offset module is used to perform coordinate offset processing on the target grid to obtain the offset coordinates of the target grid;
[0010] A rendering module is used to render the target grid based on the offset coordinates of the target grid.
[0011] In a third aspect, an embodiment of the present disclosure provides an electronic device, including:
[0012] Memory;
[0013] Processor; and
[0014] Computer programs;
[0015] The computer program is stored in the memory and is configured to be executed by the processor to implement the method as described in the first aspect.
[0016] In a fourth aspect, an embodiment of the present disclosure provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program is executed by a processor to implement the method described in the first aspect.
[0017] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the method described in the first aspect is implemented.
[0018] The embodiments of the present disclosure provide a 3D rendering method, apparatus, device and computer-readable storage medium. The method obtains a 3D model, determines target grids that intersect and are perpendicular to the same coordinate axis in the coordinate system based on the positions of grids on the 3D model in the coordinate system of the 3D model, performs coordinate offset processing on the target grids, and obtains the offset coordinates of the target grids. Thus, by offsetting the intersecting target grids, the distance between the target grids is increased, and then rendering is performed based on the coordinates of the target grids after the distance is increased, thereby avoiding the z-fighting problem in 3D model rendering, improving the rendering effect, and enhancing the user experience. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0020] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0021] Figure 1 A flow chart of a 3D model rendering method provided in an embodiment of the present disclosure;
[0022] Figure 2 A schematic diagram of an application scenario provided by an embodiment of the present disclosure;
[0023] Figure 3 A flowchart of a method for determining a target grid provided by an embodiment of the present disclosure;
[0024] Figure 4A schematic diagram of the structure of a 3D model rendering device provided by an embodiment of the present disclosure;
[0025] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present disclosure. DETAILED DESCRIPTION
[0026] In order to more clearly understand the above-mentioned objectives, features and advantages of the present disclosure, the scheme of the present disclosure will be further described below. It should be noted that the embodiments of the present disclosure and the features in the embodiments can be combined with each other without conflict.
[0027] In the following description, many specific details are set forth to facilitate a full understanding of the present disclosure, but the present disclosure may also be implemented in other ways different from those described herein; it is obvious that the embodiments in the specification are only part of the embodiments of the present disclosure, rather than all of the embodiments.
[0028] Generally, during 3D rendering, a zfighting phenomenon may occur. To address this problem, an embodiment of the present disclosure provides a method for rendering a 3D model, which is described below in conjunction with a specific embodiment.
[0029] Figure 1 A flowchart of a method for rendering a 3D model provided in an embodiment of the present disclosure. The method can be executed by a 3D model rendering device, which can be implemented in software and / or hardware, and can be configured in an electronic device, such as a server or a terminal.
[0030] like Figure 1 As shown, the method provided by the embodiment of the present disclosure may include the following steps:
[0031] S101: Obtain a 3D model.
[0032] Specifically, the 3D model referred to in the embodiments of the present disclosure may be a model of any object, such as a house model, a character model, etc.
[0033] In one implementation, the 3D model referred to in the embodiments of the present disclosure may be obtained from a preset server. For example, Figure 2 is a schematic diagram of a method for obtaining a 3D model provided by an embodiment of the present disclosure. Figure 2 In the embodiment, the terminal device 22 can be understood as a device equipped with the rendering device referred to in the embodiment of the present disclosure, or can also be understood as the rendering device itself. The terminal device can be, for example, a mobile phone, a laptop computer, or other device with 3D model rendering capabilities. The server 21 can be understood as a server storing the 3D model to be rendered. The server can be understood as any device with data storage and data exchange capabilities. Figure 2As shown, in one implementation of the embodiment of the present disclosure, the terminal device 22 and the server 21 can be connected in a wired manner or in a wireless manner, and the terminal device 21 obtains the 3D model from the server 21 through a preset data transmission protocol. Of course, this is only an example, not the only limitation on the 3D model acquisition scenario and method.
[0034] In another embodiment, the 3D model may be obtained from a preset database. For example, in one possible scenario, the preset database may be a database mounted on a terminal device equipped with the above-mentioned rendering apparatus, or in other scenarios, may be a database on another device independent of the terminal device.
[0035] In another feasible implementation, the 3D model referred to in the embodiment of the present disclosure may also be reconstructed based on pre-collected 3D point cloud data. The 3D point cloud data may be collected by a device equipped with the rendering device referred to in the embodiment of the present disclosure, or may be obtained from other collection devices or storage devices.
[0036] S102 . Based on the positions of the grids on the 3D model in the coordinate system of the 3D model, determine a target grid that intersects and is perpendicular to the same coordinate axis in the coordinate system.
[0037] Specifically, the target grid in the embodiment of the present disclosure may be understood as a grid that may cause the z-fighting problem.
[0038] After the 3D model is acquired, for each coordinate axis in the 3D model coordinate system, a grid perpendicular to the coordinate axis is searched in the 3D model.
[0039] Then, the grids perpendicular to the coordinate axis can be classified into the same group to obtain a grid group perpendicular to the coordinate axis, and then the intersecting grids are found from the grid group as the target grids.
[0040] Alternatively, grids perpendicular to the coordinate axis and having the same coordinates on the coordinate axis may be grouped into the same group to obtain a grid group, and then intersecting grids may be searched from the grid group as target grids.
[0041] The grid intersection means that as long as there are common points in the two grids, the two grids intersect.
[0042] The following takes the x-axis as an example to illustrate how to determine the target grid in a 3D model.
[0043] There are four grids a, b, c, and d in the 3D model. Among them, grids a, b, and c are perpendicular to the x-axis. In the grid perpendicular to the x-axis, the x-coordinates of grids a and b are the same, and grids a and b intersect. Grids a, b, and c can be grouped into the same grid group, and grids a and b can be found to intersect in the grid group a, b, and c, and grids a and b can be determined as target grids; or a and b can be grouped into the same grid group, and c can be grouped into a grid group, and grids a and b can be found to intersect in the grid group a, b, and grids a and b can be determined as target grids.
[0044] S103, performing coordinate offset processing on the target grid to obtain the offset coordinates of the target grid.
[0045] Specifically, the purpose of coordinate offset processing in the embodiment of the present disclosure is to separate the intersecting grids. Therefore, coordinate offset processing for the target grid can be understood as offsetting a part of the intersecting grids and not offsetting the other part of the grids, or it can also be understood as coordinate offsetting all the target grids.
[0046] For example, there are two target grids a and b, and a and b intersect. When performing grid offset processing, only one of grids a or b can be offset, or both grids a and b can be offset.
[0047] Coordinate offset can be exemplarily understood as increasing or decreasing the coordinates of the target grid corresponding to the vertical coordinate axis. It is understandable that only offsetting the coordinates of the target grid corresponding to the vertical coordinate axis will only change the position of the target grid, and will not change the shape of the target grid.
[0048] S104: Rendering the target grid based on the offset coordinates of the target grid.
[0049] Specifically, the method for rendering a 3D model in the embodiment of the present disclosure is similar to the prior art and will not be described in detail here.
[0050] The disclosed embodiment obtains a 3D model, determines target grids that intersect and are perpendicular to the same coordinate axis in the coordinate system based on the positions of grids on the 3D model in the coordinate system of the 3D model, performs coordinate offset processing on the target grids, and obtains the offset coordinates of the target grids. Thus, by offsetting the intersecting target grids, the distance between the target grids is increased, and then rendering is performed based on the coordinates of the target grids after the distance is increased, thereby avoiding the z-fighting problem in 3D model rendering, improving rendering effect, and enhancing user experience.
[0051] Figure 3A flow chart of a method for determining a target grid provided by an embodiment of the present disclosure. The method can also be executed by a rendering device of a 3D model.
[0052] like Figure 3 As shown, in some embodiments of the present disclosure, a method for determining a target grid may include the following steps:
[0053] S301. For any coordinate axis in the coordinate system, based on the position of the grid on the 3D model in the coordinate system, determine a grid on the 3D model that is perpendicular to the coordinate axis and a plane group that includes the grid.
[0054] S302: On each plane in the plane group, determine the intersecting grid as the target grid.
[0055] Specifically, after acquiring the 3D model, for each coordinate axis in the 3D model coordinate system, a grid perpendicular to the coordinate axis and a plane containing the grid are searched in the 3D model, and then the plane perpendicular to the coordinate axis is classified into a plane group perpendicular to the coordinate axis.
[0056] Here, it can be determined that the plane contains the grid according to the fact that the coordinates of the grid on the coordinate axis are consistent with the coordinates of the plane corresponding to the coordinate axis.
[0057] Then, from the planes in the plane group, find the intersecting mesh as the target mesh.
[0058] The following takes the x-axis as an example to illustrate how to determine the target grid in a 3D model.
[0059] In the 3D model, there are four meshes a, b, c, and d that are perpendicular to the x-axis. The x-coordinates of the three meshes a, b, and c are the same, and a and b intersect. There are three planes A, B, and C that are perpendicular to the x-axis. The x-coordinate of plane A is the same as that of mesh a, and the x-coordinate of plane B is the same as that of mesh d. Plane A contains three meshes a, b, and c, and plane B contains mesh d. Planes A and B are classified as a plane group perpendicular to the x-axis. In plane A of the plane group perpendicular to the x-axis, meshes a and b intersect, and a and b are determined as target meshes.
[0060] The disclosed embodiment divides the grids into planes, thereby reducing the number of grids that need to be judged when determining whether the grids intersect, alleviating the processing burden, improving the efficiency of determining whether the grids intersect, and shortening the time for determining whether the grids intersect, thereby improving the rendering efficiency of the 3D model and shortening the rendering time of the 3D model.
[0061] For example, in other embodiments, the above step S103 performs coordinate offset processing on the target grid to obtain the offset coordinates of the target grid, including:
[0062] According to the mapping relationship between the area order of the target grids and the size of the offset, the coordinates of the target grids are offset.
[0063] Specifically, when the target grids are sorted by area in the embodiment of the present disclosure, the target grids in a grid group may be sorted, the target grids in a plane may be sorted, the target grids perpendicular to the same coordinate axis may be sorted, or all the target grids may be sorted.
[0064] The sorting result can be a sorting of the target grids from large to small, or a sorting of the target grids from small to large.
[0065] The mapping relationship between the area sorting and the offset size refers to increasing or decreasing the offset of the target grid in sequence according to the area sorting.
[0066] For example, if there are two target grids a and b, both of which are perpendicular to the x-axis, the sorting results are a and b. The x-coordinate of grid a is increased or decreased by 1, and the x-coordinate of grid b is increased or decreased by 2.
[0067] Optionally, in some embodiments, if the target grid intersects with a grid in another plane in the plane group after being offset, coordinate offset processing is performed on the target grid and the grid in the other plane so that the target grid does not intersect with the grid in the other plane.
[0068] Specifically, after the target grid is processed for coordinate offset, it will enter a plane and search for the plane in the plane group. If the plane cannot be found, the plane is added to the plane group.
[0069] If the plane can be found in the plane group, then check whether there is a grid intersecting with the target grid in the plane. If so, coordinate offset processing is performed on the target grid again. For the grid intersecting with the target grid in the plane, coordinate offset processing is performed, and the offset of the grid is different from the offset of the target grid.
[0070] The disclosed embodiment detects the target grid after the offset, and when it is detected that the target grid after the offset intersects with other grids in the plane after the offset, the target grid continues to be offset until it does not intersect with other grids in the plane after the offset, thereby preventing the recurrence of the z-fighting problem after the offset and improving the rendering effect.
[0071] Figure 4The schematic diagram of the structure of the 3D model rendering device provided in the embodiment of the present disclosure. The 3D model rendering device can be understood as the terminal device in the above embodiment, or the 3D model rendering device can also be understood as a component or assembly in the above terminal device. The 3D model rendering device provided in the embodiment of the present disclosure can execute the processing flow provided in the 3D model rendering method embodiment, such as Figure 4 As shown, the 3D model rendering device 40 includes:
[0072] Acquisition module 410, for 3D model;
[0073] A determination module 420 is used to determine, based on the positions of the grids on the 3D model in the coordinate system of the 3D model, target grids that intersect and are perpendicular to the same coordinate axis in the coordinate system;
[0074] An offset module 430 is used to perform coordinate offset processing on the target grid to obtain the offset coordinates of the target grid;
[0075] The rendering module 440 is used to render the target grid based on the offset coordinates of the target grid.
[0076] Optionally, the determination module 420 includes a first determination unit 421 and a second determination unit 422;
[0077] A first determining unit 421 is used to determine, for any coordinate axis in the coordinate system, a grid on the 3D model that is perpendicular to the coordinate axis and a plane group containing the grid based on the position of the grid on the 3D model in the coordinate system;
[0078] The second determining unit 422 is used to determine the intersecting grids on each plane in the plane group as the target grids.
[0079] Optionally, the offset module 430 includes: a first offset unit 431;
[0080] The first offset unit 431 is used to perform offset processing on the coordinates of the target grids according to the mapping relationship between the area order of the target grids and the magnitude of the offset.
[0081] Optionally, the offset module 430 further includes: a second offset unit 432;
[0082] The second offset unit 432 is used for performing coordinate offset processing on the target grid and the grid in another plane in response to the target grid intersecting with the grid in another plane in the plane group after offset, so that the target grid does not intersect with the grid in another plane.
[0083] Figure 4The rendering device of the 3D model of the illustrated embodiment can be used to execute the technical solution of the above-mentioned method embodiment, and its implementation principle and technical effect are similar, which will not be repeated here.
[0084] Figure 5 The electronic device provided by the embodiment of the present disclosure may be a terminal as described in the above embodiment. The electronic device provided by the embodiment of the present disclosure may execute the processing flow provided by the kernel upgrade method embodiment, such as Figure 5 As shown, the electronic device 50 includes: a memory 51, a processor 52, a computer program and a communication interface 53; wherein the computer program is stored in the memory 51 and is configured so that the processor 52 executes the 3D model rendering method as described above.
[0085] In addition, an embodiment of the present disclosure further provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the 3D model rendering method described in the above embodiment.
[0086] In addition, an embodiment of the present disclosure further provides a computer program product, which includes a computer program or instructions, and when the computer program or instructions are executed by a processor, the 3D model rendering method as described above is implemented.
[0087] It should be noted that, in this article, relational terms such as "first" and "second" are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.
[0088] The above description is only a specific embodiment of the present disclosure, so that those skilled in the art can understand or implement the present disclosure. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present disclosure. Therefore, the present disclosure will not be limited to the embodiments described herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for rendering a 3D model, characterized in that: The method comprises: Get the 3D model; Determine, based on the position of the grid on the 3D model in the coordinate system of the 3D model, a target grid that intersects and is perpendicular to the same coordinate axis in the coordinate system; Performing coordinate shift processing on the target grid to obtain the offset coordinates of the target grid; Rendering the target grid based on the offset coordinates of the target grid; The determining, based on the position of the grid on the 3D model in the coordinate system of the 3D model, a target grid that intersects and is perpendicular to the same coordinate axis in the coordinate system comprises: For any coordinate axis in the coordinate system, based on the position of the grid on the 3D model in the coordinate system, determine a grid on the 3D model that is perpendicular to the coordinate axis and a plane group containing the grid; On each plane in the plane group, determining an intersecting grid as a target grid; The performing coordinate shift processing on the target grid to obtain the offset coordinates of the target grid includes: According to the mapping relationship between the area order of the target grids and the size of the offset, the coordinates of the target grids are offset.
2. The method according to claim 1, characterized in that The method further comprises: In response to the target grid intersecting with a grid in another plane in the plane group after being offset, coordinate offset processing is performed on the target grid and the grid in the another plane so that the target grid does not intersect with the grid in the another plane.
3. A 3D model rendering device, characterized in that: include: An acquisition module, used to acquire a 3D model; A determination module, configured to determine, based on the position of the grid on the 3D model in the coordinate system of the 3D model, a target grid that intersects and is perpendicular to the same coordinate axis in the coordinate system; An offset module is used to perform coordinate offset processing on the target grid to obtain the offset coordinates of the target grid; A rendering module, used for rendering the target grid based on the offset coordinates of the target grid; The determination module includes a first determination unit and a second determination unit; The first determining unit is configured to determine, for any coordinate axis in the coordinate system, a grid on the 3D model that is perpendicular to the coordinate axis and a plane group that includes the grid based on a position of the grid on the 3D model in the coordinate system; The second determining unit is used to determine the intersecting grids as the target grids on each plane in the plane group; The offset module includes: a first offset unit; The first offset unit is used to perform offset processing on the coordinates of the target grids according to the mapping relationship between the area order of the target grids and the size of the offset.
4. The device according to claim 3, characterized in that The offset module further includes: a second offset unit; The second offset unit is used to perform coordinate offset processing on the target grid and the grid in another plane in the plane group in response to the target grid intersecting with the grid in the other plane after offset, so that the target grid does not intersect with the grid in the other plane.
5. An electronic device, characterized in that: include: Memory; processor; as well as Computer programs; The computer program is stored in the memory and is configured to be executed by the processor to implement the method according to any one of claims 1 to 2.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 2 is implemented.
Citation Information
Patent Citations
Method and device for rendering virtual object in virtual environment, equipment and medium
CN112884873A
Map rendering method and device, electronic equipment and storage medium
CN114399573A
Virtual object perspective processing method and device and computer equipment
CN114452646A
Three-dimensional display method and device of asset model, storage medium and intelligent terminal
CN115761086A
Three-dimensional model rendering method and device based on cluster division, equipment and medium
CN116030176A
